Skip to main content

keygen

Function keygen 

Source
pub fn keygen<P: Params>(
    d: &[u8; 32],
    ek_out: &mut [u8],
    dk_out: &mut [u8],
) -> (usize, usize)
Expand description

Generate a K-PKE key pair (Algorithm 13).

From a 32-byte seed d, derives the public matrix A (in NTT domain), secret vector s, and error vector e using SHA3-512 and SHAKE256-based CBD sampling. Writes the encoded encapsulation key ek_pke = ByteEncode_12(t_hat) || rho into ek_out and the encoded decapsulation key dk_pke = ByteEncode_12(s_hat) into dk_out.

Secret polynomials s and e are zeroized after use.

§Arguments

  • d - 32-byte seed for deterministic key generation.
  • ek_out - Output slice for ek_pke, must be at least 384*k + 32 bytes.
  • dk_out - Output slice for dk_pke, must be at least 384*k bytes.

§Returns

A tuple (ek_len, dk_len) with the actual lengths written.