Skip to main content

KEMDecapsulator

Trait KEMDecapsulator 

Source
pub trait KEMDecapsulator<SK: KEMPrivateKey<SK_LEN>, const SK_LEN: usize, const CT_LEN: usize, const SS_LEN: usize>: Sized {
    // Required method
    fn decaps(sk: &SK, ct: &[u8]) -> Result<KeyMaterial<SS_LEN>, KEMError>;
}
Expand description

A Key Encapsulation Mechanism (KEM) is defined as a set of three operations: key generation, encapsulation, and decapsulation.

This trait represents the decapsulation operation performed by the holder of the private key. Encapsulation operations are performed by the corresponding KEMEncapsulator trait, and key generation is provided as an inherent associated function directly on the algorithm struct. There are several reasons for this split: first is architectural; some complex algorithms may benefit from having the encapsulation and decapsulation implementations split into separate modules. Second is for compliance: sometimes a policy soft-deprecates an algorithm so that new ciphertexts can no longer be created, but existing ciphertexts can still be decapsulated. Splitting the traits makes this policy easier to enforce.

The arrays used to encode private keys, ciphertexts, and shared secrets are statically-sized because this allows us to safely remove runtime checks for array lengths, which overall reduces the fallibility of the library. This design choice could make this trait complicated to apply to a KEM algorithm that does not have fixed sizes for the encodings of these objects.

Required Methods§

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", so this trait is not object safe.

Implementors§