method x25519.shared
The shared secret of your private key and the public key of the peer (32 bytes, kept in a secret). Both sides derive the same value.
Example:
use std.crypto { x25519 }
fn main() io, rand {
let a = x25519.generate()
let b = x25519.generate()
let secret = x25519.shared(&a.secretKey, b.publicKey)!
print("{secret}")
}Output
***
pub(api) static fn shared(secretKey: &secret<bytes>, peerPublic: bytes) -> secret<bytes> | CryptoErrorSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
secretKey | &secret<bytes> |
peerPublic | bytes |
Returns
secret<bytes>
Errors
CryptoError@error- `CryptoError` for a key of the wrong size or a low-order peer key.
Effects
none declared (pure unless the body says otherwise)
Defined in: std/crypto/crypto.oxl:723