embassy-crypto

Crates

git

Versions

default

Flavors

Skip to main content

X25519

Trait X25519 

Source
pub trait X25519 {
    // Required methods
    fn public_key(k: &X25519SecretKey) -> Result<X25519PublicKey, Error>;
    fn shared_secret(
        k: &X25519SecretKey,
        peer: &X25519PublicKey,
    ) -> Result<[u8; 32], Error>;
}
Expand description

X25519 (Curve25519 ECDH, RFC 7748) driver.

§Contract

  • No secret-dependent timing with respect to the private scalar.
  • Implementations wipe copies of secrets they materialize in RAM.

Required Methods§

Source

fn public_key(k: &X25519SecretKey) -> Result<X25519PublicKey, Error>

The public key X25519(k, 9) of the private scalar k.

Source

fn shared_secret( k: &X25519SecretKey, peer: &X25519PublicKey, ) -> Result<[u8; 32], Error>

The shared secret X25519(k, peer).

X25519 accepts every 32-byte string as a public key, so no validation is performed on peer. The public API rejects an all-zero shared secret (a low-order peer point) itself.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§