docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

core::crypto::x25519

On this page

X25519 (RFC 7748): Diffie-Hellman on Curve25519's u coordinate.

Structs

PrivateKeySource

pub struct PrivateKey

A private key: 32 bytes in secret storage (clamped when used, as RFC 7748 says). It has one owner (let b = a moves it); wipe and its release clear it.

  • pub fn from_bytes<B: AsBytes>(bytes: B) throws (ValueError) -> PrivateKey§

    Source

    The key of 32 bytes; throws ValueError on another length.

  • pub fn to_secret(self) -> Secret§

    Source

    A copy of the 32 bytes.

  • pub fn public_key(self) -> PublicKey§

    Source

    The public key that pairs with this one.

  • pub fn diffie_hellman(self, peer: PublicKey) -> Secret | none§

    Source

    The shared secret with peer; none when it is all zero (a small-order peer key, RFC 7748 6.1).

  • pub fn wipe(self)§

    Source

    Overwrite the key with zeros now (every copy shares it).

Trait implementations 3
  • impl !Sync for PrivateKey
  • impl Drop for PrivateKey
  • impl Debug for PrivateKey

PublicKeySource

pub struct PublicKey

A public key: a 32-byte u coordinate.

  • pub fn from_bytes<B: AsBytes>(bytes: B) throws (ValueError) -> PublicKey§

    Source

    Any 32 bytes (RFC 7748 5: every u coordinate is accepted).

  • pub const fn to_bytes(self) -> [u8; 32]§

    Source

    The key's 32 bytes.