sharedSecret = crypto.x25519.shared(secretKey, peerPublicKey)
| Parameter | Description |
|---|---|
| secretKey | a uint8 vector of 32 bytes or 64 hexadecimal characters: your private key. |
| peerPublicKey | a uint8 vector of 32 bytes or 64 hexadecimal characters: the other party public key. |
| Parameter | Description |
|---|---|
| sharedSecret | a character vector: 64 lowercase hexadecimal characters (32 bytes). |
crypto.x25519.shared computes the Diffie-Hellman shared secret (RFC 7748) from your secret key and a peer public key. Both parties obtain the same value.
Do not use the raw shared secret as an encryption key: hash it first, for example with crypto.blake2b(shared, [], 32).
[aPub, aSec] = crypto.x25519.keypair();
[bPub, bSec] = crypto.x25519.keypair();
isequal(crypto.x25519.shared(aSec, bPub), crypto.x25519.shared(bSec, aPub))
| Version | Description |
|---|---|
| 2.0.0 | initial version |