Skip to content
FutureBlitz

    Install

    Import std.crypto.signatures

    X25519

    std.crypto.signatures

    struct

    Public Struct X25519

    X25519 key exchange (RFC 7748): private and public keys are 32 bytes each, and so is the secret two sides share, which a KDF, like Hkdf, makes keys from.

    Examples

    Local alice = X25519.NewPrivateKey()
    Local bob = X25519.NewPrivateKey()
    Local aliceSecret = X25519.SharedSecret(alice, X25519.PublicKeyOf(bob))
    Local bobSecret = X25519.SharedSecret(bob, X25519.PublicKeyOf(alice))
    Expect(aliceSecret != Null && aliceSecret == bobSecret)

    std/crypto/signatures.fb, line 222

    • Public Static Method NewPrivateKey(): UInt8[] static method #

      A new random private key.

    • @PanicsAtCaller Public Static Method PublicKeyOf(privateKey: UInt8[]): UInt8[] static method #

      privateKey's public key, to give the other side. Panics unless privateKey is 32 bytes.

    • @PanicsAtCaller Public Static Method SharedSecret(privateKey: UInt8[], publicKey: UInt8[]): UInt8[]? static method #

      The secret of privateKey and the other side's publicKey, or Null when publicKey is one of the few that make every secret 0. Panics unless both are 32 bytes.

    Report an issue with this page or with FutureBlitz on GitHub.