Skip to main content

KeyExchange

Trait KeyExchange 

Source
pub trait KeyExchange: Send + Sync {
    type SecretKey: Zeroize + Clone;
    type PublicKey: AsRef<[u8]> + Clone;

    // Required methods
    fn generate_keypair() -> (Self::SecretKey, Self::PublicKey);
    fn derive_shared(
        secret: &Self::SecretKey,
        their_pubkey: &Self::PublicKey,
    ) -> EnvelopeResult<SharedSecret>;
    fn pubkey_from_bytes(bytes: &[u8]) -> EnvelopeResult<Self::PublicKey>;
    fn pubkey_to_bytes(pubkey: &Self::PublicKey) -> Vec<u8> ⓘ;
}
Expand description

Trait for Diffie-Hellman key exchange implementations.

This trait abstracts over Ristretto255 (default) and ECDH P-256 (FIPS mode).

Required Associated Types§

Source

type SecretKey: Zeroize + Clone

Secret key type (zeroized on drop).

Source

type PublicKey: AsRef<[u8]> + Clone

Public key type.

Required Methods§

Source

fn generate_keypair() -> (Self::SecretKey, Self::PublicKey)

Generate a new keypair.

Source

fn derive_shared( secret: &Self::SecretKey, their_pubkey: &Self::PublicKey, ) -> EnvelopeResult<SharedSecret>

Derive shared secret from our secret key and their public key.

Source

fn pubkey_from_bytes(bytes: &[u8]) -> EnvelopeResult<Self::PublicKey>

Deserialize a public key from bytes.

Source

fn pubkey_to_bytes(pubkey: &Self::PublicKey) -> Vec<u8> ⓘ

Serialize a public key to bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§