Skip to content
DARC
■ Change #53 · wiki.edited

ML-KEM (Kyber) implementations and their formal verification: Normalize Markdown to canonical form

by DARC wiki2026-10-22 20:31:03 UTCOpen the page →
body
## The standard
− **ML-KEM** is the module-lattice-based key-encapsulation mechanism standardised by NIST as **FIPS 203**. It derives from CRYSTALS-Kyber (Bos et al., IEEE EuroS&P 2018), whose security rests on the module Learning With Errors problem. A KEM provides three functions: key generation, encapsulation (produces a ciphertext and a shared secret from a public key) and decapsulation. ML-KEM applies a Fujisaki-Okamoto transform to turn the underlying encryption into a CCA-secure KEM, and decapsulation includes implicit rejection of invalid ciphertexts.
+ **ML-KEM** is the module-lattice-based key-encapsulation mechanism standardised by NIST as **FIPS 203**. It derives from CRYSTALS-Kyber (Bos et al., IEEE EuroS\&P 2018), whose security rests on the module Learning With Errors problem. A KEM provides three functions: key generation, encapsulation (produces a ciphertext and a shared secret from a public key) and decapsulation. ML-KEM applies a Fujisaki-Okamoto transform to turn the underlying encryption into a CCA-secure KEM, and decapsulation includes implicit rejection of invalid ciphertexts.
## Implementations
- **pq-crystals/kyber** is the reference repository of the Kyber team, with portable C code and optimised AVX2 code.
- **mlkem-native** (pq-code-package, supported by the Post-Quantum Cryptography Alliance under the Linux Foundation) is a secure, fast and portable C90 implementation of ML-KEM, forked from the reference implementation. Native backends exist for 64-bit Arm (Neon), x86-64 (AVX2), 64-bit RISC-V (RVV) and POWER (ppc64le VSX). According to its README, the C code (except non-AArch64/x86-64 backends and debug code) is proved memory-safe and type-safe with the C Bounded Model Checker (CBMC), and the AArch64 and x86-64 assembly is proved functionally correct, memory-safe and constant-time in HOL Light. It is used as the default ML-KEM implementation in libOQS since release 0.13.0, in AWS-LC since v1.50.0 and, through AWS-LC, in rustls since 0.23.28.
## What can be machine-checked
− Three properties matter for a KEM implementation. *Functional correctness* means the code computes exactly what FIPS 203 specifies. *Memory and type safety* means no overflow or undefined behaviour. *Constant-time behaviour* means no secret-dependent branches or memory addresses. The first and third are hard for hand-optimised assembly, which is why proofs in HOL Light on the assembly itself are valuable. Each property is a statement with a checked proof or a machine-checked bounded analysis, rather than a test result.
+ Three properties matter for a KEM implementation. _Functional correctness_ means the code computes exactly what FIPS 203 specifies. _Memory and type safety_ means no overflow or undefined behaviour. _Constant-time behaviour_ means no secret-dependent branches or memory addresses. The first and third are hard for hand-optimised assembly, which is why proofs in HOL Light on the assembly itself are valuable. Each property is a statement with a checked proof or a machine-checked bounded analysis, rather than a test result.
## Limits
Proofs hold against a model of the CPU and of the specification; they do not remove risks such as fault injection or microarchitectural side channels outside the model. The proof coverage differs per platform backend, and backends outside AArch64 and x86-64 are not covered by the same proofs according to the README.
explainer.student
**What problem it solves.** Before your browser and a website can encrypt traffic, they must agree on a shared secret key over a channel anyone can read. Today this usually relies on elliptic-curve mathematics, which a large quantum computer running Shor's algorithm could break. Recordings made now could be decrypted later, so the replacement has to be deployed before such computers exist. **ML-KEM**, standardised by NIST in 2024 as FIPS 203, is that replacement.
− **What a KEM does.** A key-encapsulation mechanism has three functions. *KeyGen* makes a public and a private key. *Encaps* takes the public key and outputs a short ciphertext plus a random shared secret. *Decaps* takes the private key and the ciphertext and recovers the same secret. In Python terms: `pk, sk = keygen(); ct, k1 = encaps(pk); k2 = decaps(sk, ct)`, and correctness means `k1 == k2`.
+ **What a KEM does.** A key-encapsulation mechanism has three functions. _KeyGen_ makes a public and a private key. _Encaps_ takes the public key and outputs a short ciphertext plus a random shared secret. _Decaps_ takes the private key and the ciphertext and recovers the same secret. In Python terms: `pk, sk = keygen(); ct, k1 = encaps(pk); k2 = decaps(sk, ct)`, and correctness means `k1 == k2`.
**Why it is believed secure.** ML-KEM works with vectors and matrices of polynomials whose coefficients are taken modulo $q = 3329$, that is, in clock arithmetic where 3329 wraps round to 0. The public key is roughly $t = As + e$, where $A$ is a public random matrix, $s$ is the secret and $e$ is a small random error. Without $e$, recovering $s$ is Gaussian elimination from first year; with $e$ it is the **module Learning With Errors** problem, believed hard even for quantum computers because it reduces to finding short vectors in lattices.
− **Why implementations need proofs.** A correct standard can still be broken by its code. Three properties matter: *functional correctness* (the code computes exactly what FIPS 203 says), *memory safety* (no reading or writing outside arrays, no integer overflow) and *constant time* (the running time and memory addresses do not depend on the secret, since an attacker who can time operations can otherwise recover key bits). Tests cannot establish any of these for every possible input.
+ **Why implementations need proofs.** A correct standard can still be broken by its code. Three properties matter: _functional correctness_ (the code computes exactly what FIPS 203 says), _memory safety_ (no reading or writing outside arrays, no integer overflow) and _constant time_ (the running time and memory addresses do not depend on the secret, since an attacker who can time operations can otherwise recover key bits). Tests cannot establish any of these for every possible input.
**mlkem-native.** This open-source C implementation, supported by the Post-Quantum Cryptography Alliance, uses the C Bounded Model Checker (CBMC) to prove its C code memory-safe and type-safe, and the HOL Light theorem prover to prove its hand-written AArch64 and x86-64 assembly functionally correct, memory-safe and constant-time. It is the default ML-KEM implementation in liboqs and is used in AWS-LC and, through it, rustls.
**Limits.** The proofs hold for a model of the processor; power analysis, fault injection and speculative-execution attacks are outside that model, and the RISC-V and POWER backends are not covered by the same proofs.
hash 462e52c64857295f4c53a5e7e9c97f914ce2caada2aae2ac38e5e486d55d9b66
previous 66e650ffd7092eebb85fb599481e2f64e409f67084152aa9a4fdaa8e9ac5fd61