Kem

Trait Kem 

Source
pub trait Kem<const EK_LEN: usize, const DK_LEN: usize, const CT_LEN: usize, const SS_LEN: usize, const RAND_KEYGEN_LEN: usize, const RAND_ENCAPS_LEN: usize> {
    // Required methods
    fn keygen(
        ek: &mut [u8; EK_LEN],
        dk: &mut [U8; DK_LEN],
        rand: &[U8; RAND_KEYGEN_LEN],
    ) -> Result<(), KeyGenError>;
    fn encaps(
        ct: &mut [u8; CT_LEN],
        ss: &mut [U8; SS_LEN],
        ek: &[u8; EK_LEN],
        rand: &[U8; RAND_ENCAPS_LEN],
    ) -> Result<(), EncapsError>;
    fn decaps(
        ss: &mut [U8; SS_LEN],
        ct: &[u8; CT_LEN],
        dk: &[U8; DK_LEN],
    ) -> Result<(), DecapsError>;
}
Expand description

A Key Encapsulation Mechanism (KEM). This trait is the most low-level and mostly used in the implementation of other, more usabe APIs on top.

Required Methods§

Source

fn keygen( ek: &mut [u8; EK_LEN], dk: &mut [U8; DK_LEN], rand: &[U8; RAND_KEYGEN_LEN], ) -> Result<(), KeyGenError>

Generate a pair of encapsulation and decapsulation keys. It is the responsibility of the caller to ensure that the rand argument is actually random.

Source

fn encaps( ct: &mut [u8; CT_LEN], ss: &mut [U8; SS_LEN], ek: &[u8; EK_LEN], rand: &[U8; RAND_ENCAPS_LEN], ) -> Result<(), EncapsError>

Encapsulate a shared secret towards a given encapsulation key. It is the responsibility of the caller to ensure that the rand argument is actually random.

Source

fn decaps( ss: &mut [U8; SS_LEN], ct: &[u8; CT_LEN], dk: &[U8; DK_LEN], ) -> Result<(), DecapsError>

Decapsulate a 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§