Skip to main content

keygen

Function keygen 

Source
pub fn keygen<P: Params>(
    rng: &mut impl CryptoRng,
) -> Result<(Vec<u8>, Vec<u8>), MlKemError>
Expand description

Generate an ML-KEM key pair (Algorithm 19).

Draws 32-byte seeds d and z from the RNG, delegates to keygen_internal, then zeroizes both seeds. This is the recommended entry point for key generation.

§Arguments

  • rng - A cryptographic random number generator implementing CryptoRng.

§Returns

A tuple (encapsulation_key, decapsulation_key) as byte vectors.

§Errors

Returns MlKemError::RngFailure if the RNG fails to produce bytes.