Skip to main content

KEM

Trait KEM 

Source
pub trait KEM<PK: KEMPublicKey<PK_LEN>, SK: KEMPrivateKey<SK_LEN>, const PK_LEN: usize, const SK_LEN: usize, const CT_LEN: usize, const SS_LEN: usize>: Sized {
    // Required methods
    fn keygen() -> Result<(PK, SK), KEMError>;
    fn encaps(pk: &PK) -> Result<(KeyMaterial<SS_LEN>, [u8; CT_LEN]), KEMError>;
    fn decaps(sk: &SK, ct: &[u8]) -> Result<KeyMaterial<SS_LEN>, KEMError>;
}
Expand description

A Key Encapsulation Mechanism

Required Methods§

Source

fn keygen() -> Result<(PK, SK), KEMError>

Generate a keypair. Error condition: Basically only on RNG failures

Source

fn encaps(pk: &PK) -> Result<(KeyMaterial<SS_LEN>, [u8; CT_LEN]), KEMError>

Performs an encapsulation against the given public key. Returns the ciphertext and derived shared secret.

Source

fn decaps(sk: &SK, ct: &[u8]) -> Result<KeyMaterial<SS_LEN>, KEMError>

Performs a decapsulation of the given ciphertext. Returns the derived shared secret.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§