Expand description
ML-KEM-768 (FIPS-203) keygen / encapsulation / decapsulation as a Rust composition of the
verified native kernels in crate::ntt (NTT, base-multiply, CBD, compress, byte-encode,
4-way AVX2 matrix expansion) and crate::keccak (SHA3-256/512, SHAKE256). This is the exact
same primitive set the assets/std/crypto.lg Logos ML-KEM orchestrates and that the
logicaffeine-tests AOT gates prove bit-exact vs the FIPS-203 reference — here orchestrated in
Rust so the post-quantum channel (logicaffeine_compile::concurrency::channel) can run the
handshake. Coefficients ride the fast Word16 carrier throughout.
Enums§
Constants§
- CT_
BYTES ct= K·(32·du) + 32·dv (ciphertext).- DK_
BYTES dk= dk_pke ‖ ek ‖ H(ek) ‖ z (decapsulation / secret key).- EK_
BYTES ek= K·384 + 32 (encapsulation / public key).- SS_
BYTES - Shared secret length.
Functions§
- decaps
- ML-KEM.Decaps(dk, c) → shared secret, with the Fujisaki-Okamoto implicit reject. The FIPS 203 §7.3 input checks run first, the key’s before the ciphertext’s, so a malformed key is reported whatever ciphertext arrives with it.
- encaps
- ML-KEM.Encaps(ek, m) → (ciphertext, shared secret).
mis the 32-byte message randomness. Anekthat fails the FIPS 203 §7.2 input checks is refused. - keygen
- ML-KEM.KeyGen(d, z) → (ek, dk) where dk = dk_pke ‖ ek ‖ H(ek) ‖ z.
- mlkem_
decaps_ seq mlkemDecapsKem(dk, ct)→ shared_secret(32). The ciphertext is the peer’s: one of the wrong length is answered with an empty sequence; a malformed decapsulation key fails the program.- mlkem_
encaps_ seq mlkemEncapsKem(ek, m)→ ciphertext(1088) ‖ shared_secret(32). The ek is the peer’s: one that fails FIPS 203’s checks is answered with an empty sequence, never encapsulated to.- mlkem_
keypair_ seq mlkemKeypair(d, z)→ ek(1184) ‖ dk(2400).- mlkem_
noise_ batch_ from_ int mlkemNoiseBatch(seed, base, count)→count·256raw CBD_2 Word16 coefficients (noncesbase..base+count, no NTT), the flat concatenation ofcountnoise polynomials. The fast primitive the Logosmlkem768Keygen/mlkemEncryptcall once instead ofcountscalarmlkemPrfNoises — one 4-way SHAKE256 permutation covers four PRF streams (seenoise_batch_raw).