OxL Reference

data x25519

X25519 key agreement (RFC 7748). Hash the shared secret (or use HKDF) before using it as a key.

Example:

oxl✓ checked in CI
use std.crypto { x25519 }

fn main() io, rand {
  let alice = x25519.generate()
  let bob = x25519.generate()
  let a = x25519.shared(&alice.secretKey, bob.publicKey)!
  let b = x25519.shared(&bob.secretKey, alice.publicKey)!
  print("{a.reveal() == b.reveal()}")
}
Output
true
pub(api) data x25519

Thread safety. pure functions apart from `generate`; safe from any task.

Since. 1.0.0-beta

Methods

generate() -> KeyPair rand
A new random X25519 key pair.
shared(secretKey: &secret<bytes>, peerPublic: bytes) -> secret<bytes> | CryptoError
The shared secret of your private key and the public key of the peer (32 bytes, kept in a secret).

Defined in: std/crypto/crypto.oxl:683

See also