OxL Reference

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:

oxl✓ checked in CI
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> | CryptoError

Since. 1.0.0-beta

Parameters

NameType
secretKey&secret<bytes>
peerPublicbytes

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

See also