Skip to main content

MLKEMPublicKeyTrait

Trait MLKEMPublicKeyTrait 

Source
pub trait MLKEMPublicKeyTrait<const k: usize, const PK_LEN: usize>: KEMPublicKey<PK_LEN> {
    // Required methods
    fn pk_decode(pk: &[u8; PK_LEN]) -> Result<Self, KEMError>;
    fn A_hat(&self) -> Matrix<k, k>;
    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 A_hat(&self) -> Matrix<k, k>

Get a copy of the expanded public matrix A_hat

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, PK: MLKEMPublicKeyInternalTrait<k, PK_LEN>, const PK_LEN: usize> MLKEMPublicKeyTrait<k, PK_LEN> for MLKEMPublicKeyExpanded<k, PK, PK_LEN>

Sourceยง

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