Search code examples
public-key-encryptioncommand-line-toolcurve-25519

How to generate a Curve25519 key pair in Terminal?


How can we generate a Curve25519 key pair from the command line?

We have a MacBook Air with Homebrew installed.

  1. Should we use OpenSSL or another command line tool?

  2. How do we use that tool to generate a Curve25519 key pair?


Solution

  • You can use the following command for generating the key pair:

    openssl genpkey -algorithm x25519 -out x25519-priv.pem
    

    And for extracting public key:

    openssl pkey -in x25519-priv.pem -pubout -out x25519-pub.pem