Skip to main content

KemCore

Trait KemCore 

Source
pub trait KemCore: Sealed + Sized {
    type EncapsulationKey;
    type DecapsulationKey;
    type Ciphertext;

    const ALGORITHM_ID: &'static str;
    const OID: &'static str;

    // Required methods
    fn generate<R: RngCore + CryptoRng>(
        rng: &mut R,
    ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>;
    fn generate_from_seed(
        d: &[u8; 32],
        z: &[u8; 32],
    ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>;
}
Expand description

FIPS 203 ML-KEM parameter-set marker trait.

Implemented by the zero-sized marker types MlKem512, MlKem768, MlKem1024. Sealed — third-party crates cannot add new implementations.

Required Associated Constants§

Source

const ALGORITHM_ID: &'static str

Stable algorithm identifier per the IETF LAMPS draft — "ML-KEM-512", "ML-KEM-768", or "ML-KEM-1024".

Source

const OID: &'static str

Dotted-decimal object identifier per 2.16.840.1.101.3.4.4.{1,2,3}.

Required Associated Types§

Source

type EncapsulationKey

Encapsulation key (public side).

Source

type DecapsulationKey

Decapsulation key (secret side). Zeroized on drop.

Source

type Ciphertext

Ciphertext.

Required Methods§

Source

fn generate<R: RngCore + CryptoRng>( rng: &mut R, ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>

Generate a fresh decapsulation / encapsulation key pair.

§Errors

Returns KyberLibError::RandomBytesGeneration if the supplied RNG fails to produce randomness. All other errors are internal-invariant violations and should not occur with a well-behaved RNG.

Source

fn generate_from_seed( d: &[u8; 32], z: &[u8; 32], ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>

Derive a key pair from the seed (d, z): FIPS 203 Algorithm 16, ML-KEM.KeyGen_internal(d, z).

d ‖ z is the seed form of an ML-KEM private key: keeping these 64 bytes is enough to rebuild the key pair (for example, X-Wing stores a 32-byte seed and expands it into d and z). Both halves must come from an approved RNG and stay secret.

§Errors

None in practice: the seeded path draws no randomness. The Result matches KemCore::generate.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§