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§
Required Methods§
Sourcefn generate_keypair() -> (Self::SecretKey, Self::PublicKey)
fn generate_keypair() -> (Self::SecretKey, Self::PublicKey)
Generate a new keypair.
Derive shared secret from our secret key and their public key.
Sourcefn pubkey_from_bytes(bytes: &[u8]) -> EnvelopeResult<Self::PublicKey>
fn pubkey_from_bytes(bytes: &[u8]) -> EnvelopeResult<Self::PublicKey>
Deserialize a public key from 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.