Currently I am investigating https://github.com/orlp/ed25519 , and it has example for signing but how to use it for encrypting/decrypting data? Thanks
Asked
Active
Viewed 8,980 times
2 Answers
8
Assuming you want to send a message to Alice who has the public key A
.
- Generate a new ephemeral key pair
e
,E
- Compute the shared DH secret between
e
andA
using theed25519_key_exchange
function. - Use some kind of of KDF of that secret. In the simplest case a hash.
- Use the value derived in step 3 as key in a symmetric algorithm
NaCl's crypto_box
works almost like this. The main differences are that it uses Montgomery form public keys and uses HSalsa20 as hash in step 3.
Some people don't feel comfortable with using the same keypair for signing and encryption. Use at your own risk. If you don't need this key reuse, I'd recommend LibSodium as an alternative.

Community
- 1
- 1

CodesInChaos
- 106,488
- 23
- 218
- 262
5
You don't. ED25519 is a public-key signature system, not an encryption system. Trying to use it for a purpose it was not designed for is likely to introduce security vulnerabilities.
-
2You cannot use Ed25519, but you can use Ed25519 public keys. – CodesInChaos Nov 17 '14 at 17:27