Skip to main content

MLKEMPublicKeyTrait

Trait MLKEMPublicKeyTrait 

Source
pub trait MLKEMPublicKeyTrait<const k: usize, const PK_LEN: usize, const T_PACKED_LEN: usize>: KEMPublicKey<PK_LEN> {
    // Required methods
    fn pk_decode(pk: &[u8; PK_LEN]) -> Result<Self, KEMError>;
    fn t_hat_packed(&self) -> &[u8; T_PACKED_LEN];
    fn rho(&self) -> &[u8; 32];
    fn compute_hash(&self) -> [u8; 32];
}
Expand description

General trait for all ML-KEM public keys types.

Required Methodsยง

Source

fn pk_decode(pk: &[u8; PK_LEN]) -> Result<Self, KEMError>

Algorithm 23 pkDecode(๐‘๐‘˜) Reverses the procedure pkEncode. Input: Public key ๐‘๐‘˜ โˆˆ ๐”น32+32๐‘˜(bitlen (๐‘žโˆ’1)โˆ’๐‘‘). Output: ๐œŒ โˆˆ ๐”น32, ๐ญ1 โˆˆ ๐‘…๐‘˜ with coefficients in [0, 2bitlen (๐‘žโˆ’1)โˆ’๐‘‘ โˆ’ 1].

Source

fn t_hat_packed(&self) -> &[u8; T_PACKED_LEN]

Get a ref to t_hat_packed byte array

Source

fn rho(&self) -> &[u8; 32]

Get a ref to rho

Source

fn compute_hash(&self) -> [u8; 32]

Get the hash of the public key

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ยง

Sourceยง

impl<const k: usize, const PK_LEN: usize, const T_PACKED_LEN: usize> MLKEMPublicKeyTrait<k, PK_LEN, T_PACKED_LEN> for MLKEMPublicKey<k, PK_LEN, T_PACKED_LEN>