Skip to main content

Kem

Trait Kem 

Source
pub trait Kem:
    Copy
    + Clone
    + Debug
    + Default
    + Eq
    + Ord
    + Send
    + Sync
    + 'static {
    type DecapsulationKey: TryDecapsulate<Kem = Self> + Generate;
    type EncapsulationKey: Encapsulate<Kem = Self> + Clone + Debug + Eq;
    type SharedKeySize: ArraySize;
    type CiphertextSize: ArraySize;

    // Provided methods
    fn generate_keypair_from_rng<R>(
        rng: &mut R,
    ) -> (Self::DecapsulationKey, Self::EncapsulationKey)
       where R: CryptoRng { ... }
    fn generate_keypair() -> (Self::DecapsulationKey, Self::EncapsulationKey) { ... }
}
Expand description

Key encapsulation mechanism.

This trait describes the entire type family used by a KEM.

Required Associated Types§

Source

type DecapsulationKey: TryDecapsulate<Kem = Self> + Generate

KEM decryption key (i.e. private key) which can decrypt encrypted shared secret ciphertexts which were encrypted by Kem::EncapsulationKey.

Source

type EncapsulationKey: Encapsulate<Kem = Self> + Clone + Debug + Eq

KEM encryption key (i.e. public key) which encrypts shared secrets into ciphertexts which can be decrypted by Kem::DecapsulationKey.

Source

type SharedKeySize: ArraySize

Size of the shared key/secret returned by both encapsulation and decapsulation.

Source

type CiphertextSize: ArraySize

Size of the ciphertext (a.k.a. “encapsulated key”) produced by Self::EncapsulationKey.

Provided Methods§

Source

fn generate_keypair_from_rng<R>( rng: &mut R, ) -> (Self::DecapsulationKey, Self::EncapsulationKey)
where R: CryptoRng,

Generate a random KEM keypair using the provided random number generator.

Source

fn generate_keypair() -> (Self::DecapsulationKey, Self::EncapsulationKey)

Generate a random KEM keypair using the system’s secure RNG.

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§