createSharedSecret
Compute a secret suitable for secretbox given a recipient's public key and a sender's secret key.
Function parameters
Parameters
- public_key:[public_length]u8
- secret_key:[secret_length]u8
The XSalsa stream cipher, combined with the Poly1305 MAC
Types
- XSalsa20Poly1305
- The XSalsa stream cipher, combined with the Poly1305 MAC
- SecretBox
- NaCl-compatible secretbox API.
- Box
- NaCl-compatible box API.
- SealedBox
- libsodium-compatible sealed boxes
The Salsa stream cipher.
Functions
Source
Implementation
pub fn createSharedSecret(public_key: [public_length]u8, secret_key: [secret_length]u8) (IdentityElementError || WeakPublicKeyError)![shared_length]u8 {
const p = try X25519.scalarmult(secret_key, public_key);
const zero = [_]u8{0} ** 16;
return SalsaImpl(20).hsalsa(zero, p);
}