6. ML-KEM

Draft

The inner encryption in four lines

ML-KEM (submitted to NIST under the name Kyber) is the federal key-encapsulation standard FIPS 203, published by the United States National Institute of Standards and Technology on 13 August 2024; it implements the three-step KEM interface of Section 1.1 (key generation, encapsulation, decapsulation) and ran on the first screen of the introduction.NIST, FIPS 203, "Module-Lattice-Based Key-Encapsulation Mechanism Standard", 13 August 2024 (nvlpubs.nist.gov). The inner encryption is its Section 5, Algorithms 13 to 15; the mechanism built around it is its Sections 6 and 7. Kyber is the name under which the scheme was submitted to NIST's process. Sections 4 and 5 have already assembled all of its mathematical ingredients. At its core sits an inner public-key encryption scheme called K-PKE: the noisy linear equations of Section 4.3 translated into the polynomial ring of Section 5, where sender and receiver independently compute two noisy approximations, \(t^{\top} r\) and \(s^{\top} u\), to the same shared polynomial \(s^{\top} A^{\top} r\). A single polynomial carries all 256 bits of a message at once, encoding each 0 bit at 0 and each 1 bit halfway around the modulus at \(\lceil q/2 \rceil = 1{,}665\) so that small residual errors cannot flip a bit. Two outer engineering steps then turn those four equations into ML-KEM: the ciphertext is rounded to save bytes, and decapsulation wraps decryption in a re-encryption check that renders malformed ciphertexts useless to an active attacker.

Definition 6.1.1 (the inner encryption, K-PKE). Let \(R_q = \mathbb Z_q[X]/(X^{256} + 1)\) with \(q = 3329\), and let \(k\) be the rank, 3 in ML-KEM-768. Call a polynomial, or a vector of polynomials, small when its coefficients are drawn independently from the centered binomial law on \(\{-2, \dots, 2\}\), whose probabilities are 1, 4, 6, 4 and 1 sixteenths (the law of ML-KEM-768 and ML-KEM-1024; the smallest set draws \(s\), \(e\) and \(r\) a little wider, Section 6.6). The key holder draws a uniformly random matrix \(A \in R_q^{k \times k}\) and small \(s, e \in R_q^k\), publishes \(A\) and \(t\), and keeps \(s\). To send a message \(m\) of 256 bits, the sender draws small \(r, e_1 \in R_q^k\) and a small \(e_2 \in R_q\), lets \(\mu \in R_q\) have the coefficient 1,665 wherever the bit of \(m\) is 1 and the coefficient 0 elsewhere, and sends \(u\) and \(v\). The key holder computes \(w\):

\[\begin{aligned} t &= A s + e, \\ u &= A^{\top} r + e_1, \\ v &= t^{\top} r + e_2 + \mu, \\ w &= v - s^{\top} u, \end{aligned} \tag{6.1}\]

and reads bit \(i\) of the message as 1 if the coefficient \(w_i\) lies above 832 and below 2,497, that is, nearer to 1,665 than to 0 around the circle of residues modulo \(q\), and as 0 otherwise.

Two names change from Section 4: FIPS 203 writes \(t\) for the public vector called \(b\) there, and it calls the public and private keys of the outer KEM the encapsulation key and the decapsulation key. One letter differs from FIPS 203 itself: the sender's secret vector, written \(r\) here as in the Kyber specification, is written \(y\) in the standard and in the code below. Rather than drawing and transmitting the \(k \times k\) polynomial matrix \(A\) entry by entry, both parties expand \(A\) deterministically from a 32-byte public seed with a hash function (Remark 5.1.1), so the encapsulation key of ML-KEM-768 consists of the 1,152 bytes of \(t\) plus that 32-byte seed, or 1,184 bytes in total. Leaving aside ciphertext rounding until Section 6.3, the JavaScript implementation running in these pages executes the four lines of (6.1) in 14 lines by keeping vectors in the Number-Theoretic Transform (NTT) domain of Section 5.4, marking transformed polynomials with Hat so that polynomial multiplications become fast elementwise products:

var sHat = s.map(ntt), eHat = e.map(ntt);
var tHat = matVec(A, sHat, k, false);                      // t-hat = A-hat o s-hat + e-hat
for (i = 0; i < k; i++) tHat[i] = addPoly(tHat[i], eHat[i]);
// ...
var yHat = y.map(ntt);
var Aty = matVec(A, yHat, k, true);                        // A^T o y-hat
var u = [];
for (i = 0; i < k; i++) u.push(addPoly(nttInverse(Aty[i]), e1[i]));   // u = NTT^-1(A^T o y) + e1
var mu = decompressPoly(byteDecode(1, m), 1);              // Decompress_1(ByteDecode_1(m))
var tTy = new Int16Array(256);
for (i = 0; i < k; i++) tTy = addPoly(tTy, multiplyNTTs(tHat[i], yHat[i]));
var v = addPoly(addPoly(nttInverse(tTy), e2), mu);         // v = NTT^-1(t^T o y) + e2 + mu
// ...
for (i = 0; i < k; i++) su = addPoly(su, multiplyNTTs(sHat[i], ntt(uPrime[i])));
var w = subPoly(vPrime, nttInverse(su));                   // w = v' - s^T u'
var mBits = compressPoly(w, 1), m = byteEncode(1, mBits);

Three lines of code generate \(t\), eight form \(u\) and \(v\), and three compute \(w\) and recover the message. Here ntt maps a polynomial into the transform domain and nttInverse maps it back, multiplyNTTs multiplies two transformed polynomials, and matVec multiplies a matrix by a vector with a boolean flag selecting \(A\) or \(A^{\top}\). The matrix A needs no call to ntt because seed expansion samples its entries directly in transformed form (Remark 5.4.2), while uPrime and vPrime denote the received vectors \(u\) and \(v\) after decompression. Message encoding and decoding reuse the one-bit case of Section 6.3's rounding functions: decompressPoly at one bit maps 0 to 0 and 1 to 1,665, and compressPoly at one bit applies the quarter-modulus threshold rule of Definition 6.1.1.R. Avanzi and nine others, "CRYSTALS-Kyber Algorithm Specifications and Supporting Documentation", version 3.02 of 4 August 2021, the submission to the third round of NIST's process (pq-crystals.org); below, the Kyber specification. Its Section 1.1, on this second use of the two functions that Section 6.3 uses to shrink the ciphertext: decompression is used "to create error tolerance gaps by sending the message bit 0 to 0 and 1 to ⌈q/2⌋", which is 1,665.

Compared with the integer toy scheme of Section 4.3, the sender's randomness now mirrors the key holder's. Instead of summing a plain subset of public equations, the sender takes a small random linear combination \(r\) and adds fresh small errors \(e_1\) and \(e_2\), making \(u = A^{\top} r + e_1\) and \(v - \mu = t^{\top} r + e_2\) into \(k + 1\) noisy inner products in the unknown \(r\). Ciphertext secrecy therefore rests twice on the Module-LWE decision problem of Definition 5.3.1. First, if Module-LWE is hard, an eavesdropper cannot distinguish \(t = A s + e\) from a uniformly random vector. Second, once \(t\) is replaced by a uniform vector, \((u, v - \mu)\) becomes another Module-LWE sample with \(k + 1\) outputs and looks uniformly random as well, hiding \(\mu\) completely. That gives K-PKE chosen-plaintext security: secrecy against an adversary who only listens and encrypts.

Turning those four passive equations into a deployable standard takes five further steps: following how noise builds on a single coefficient (Section 6.2), discarding low-order ciphertext bits while keeping decryption failures negligibly rare (Section 6.3), watching an active attacker extract a reused key through malformed ciphertexts and adding the re-encryption wrapper that stops the attack (Sections 6.4 and 6.5), and measuring what the finished standard costs on real TLS connections and in constant-time code (Sections 6.6 and 6.7).

One coefficient, followed

Following a single message bit through one run of ML-KEM-768 shows how the four equations work on concrete numbers, with 256 coefficients in every polynomial.

key generation   A                   3 × 3 polynomials of 256 coefficients, uniform mod 3,329, public
the key holder   s                   3 polynomials, coefficients −2 to 2: the secret
                 e                   3 polynomials, as small: an error
                 t = A·s + e         public, looks uniform
encryption       r, e₁, e₂           small, the sender's own
the sender       u = Aᵀ·r + e₁       sent at 10 bits a coefficient
                 μ = 1,665 · m       the 256 message bits, a bit a coefficient
                 v = tᵀ·r + e₂ + μ   coefficient 18:  1,075 (the mask, tᵀ·r) + 0 + 1,665 = 2,740
                 c₂ = Compress₄(v)   sent at 4 bits: 13 of 0 to 15, read back as 2,705
decryption       w = v′ − sᵀ·u′      2,705 − 1,186 (the mask again, as sᵀ·u′) = 1,519
the key holder   m = Compress₁(w)    1,519 is 1,665 − 146: nearer 1,665 than 0, the bit is 1
noise            −146 for this coefficient (−60 from eᵀ·r + e₂ − sᵀ·e₁, −86 from rounding u and v);
                 184 at most over the 256; a bit can flip only once it reaches 832, a quarter of the modulus
code             beside each station, the 21 lines of the page's ML-KEM that compute it
(the live figure needs JavaScript; it runs ML-KEM-768 in the page and loads no data)
One run of the inner encryption of ML-KEM-768, station by station. Green: the followed coefficient, with its value beside each strip; a strip is a polynomial, a bar one of its 256 coefficients. The mask stands twice, as the sender computes it and as the key holder does. Step through the computation or play it; beside each station stand the lines of the page's own code that compute it. Point at a bar to follow another coefficient, or pick one whose message bit is 0; new run draws fresh keys and a message. Hatched: noise beyond 832, where a bit would flip.

The message is never multiplied by anything secret. Each bit, as 0 or 1,665, is added to a coefficient of \(t^{\top} r\), a number that looks uniformly random to everyone, and the sum is what travels. Only the holder of \(s\) can compute nearly the same number again, as \(s^{\top} u\), and subtract it. A product of polynomials mixes all 256 coefficients of both of its factors, but the message is added and not multiplied, so bit \(i\) stays in coefficient \(i\) from the sender's line to the key holder's: 256 bits ride side by side on one mask, each in the slot that Section 5.1 counted for it.

One line of algebra measures how closely the two masks agree. Because polynomial multiplication is commutative and associative, \((A s)^{\top} r\) and \(s^{\top} A^{\top} r\) are the exact same polynomial; substituting the first three lines of (6.1) into the fourth cancels it completely:

\[w \;=\; (A s + e)^{\top} r + e_2 + \mu \;-\; s^{\top}\bigl(A^{\top} r + e_1\bigr) \;=\; \mu \;+\; \underbrace{e^{\top} r + e_2 - s^{\top} e_1}_{\text{the noise}} . \tag{6.2}\]

What remains on top of \(\mu\) consists solely of products of small polynomials: since \(e\) and \(r\) each hold \(k = 3\) polynomials of 256 coefficients, each coefficient of \(e^{\top} r\) sums \(3 \times 256 = 768\) products of two integers in \(\{-2, \dots, 2\}\), and so does each coefficient of \(s^{\top} e_1\). As long as the combined noise on a coefficient stays below 832 in magnitude, a quarter of the modulus \(q = 3{,}329\), a 0 stays nearer to 0 than to 1,665 and a 1 stays nearer to 1,665 than to 0, matching the error budget of Section 4.4.

In the run shown above, the followed coefficient arrives 146 short of 1,665, yet less than half of that discrepancy comes from the LWE noise in (6.2). The larger share comes from the ciphertext rounding that Definition 6.1.1 left out.

The noise budget, and the bits thrown away

A noise of a hundred or two under a budget of 832 leaves comfortable headroom, so the next question is how often the tail of that distribution crosses 832. Being rare in everyday traffic is not enough: because the noise depends on the secret key \(s\), observing which ciphertexts fail to decrypt would leak information about \(s\), so Section 6.5's security proof requires failures to be cryptographically negligible, well below \(2^{-128}\). Because every small secret and error draw comes from a known finite table of probabilities, the exact probability distribution of a single noise coefficient can be computed directly rather than estimated by simulation.

chart     the size of the noise of one coefficient, 0 to 1,664 (half the modulus 3,329), against its
          probability, exact, on a logarithmic scale down to 2^-220; from 832 on, decryption fails
          ML-KEM-512    2^-138.8   fails about once in 2^139 ciphertexts
          ML-KEM-768    2^-164.8   fails about once in 2^165 ciphertexts: 256 coefficients, each
                                   reaching 832 with probability 2^-172.8, added up (a union bound)
          ML-KEM-1024   2^-174.8   fails about once in 2^175 ciphertexts
strip     2,000 real decryptions of ML-KEM-768 run in the page: 0 failed; the largest noise seen was 292
          of the 832 at which one fails; standard deviation 76.4 measured, 76.5 exact. Their 512,000
          coefficients show no size rarer than one in 512,000: they check the bulk of the curve, not
          its tail (the bound expects 10^-46 failures among them)
controls  the error width η (1, 2, 3) and the bits kept of each coefficient of u (7 to 11) and of v
          (2 to 5) compute the curve again and run 2,000 real decryptions with them; at 7 bits of u
          the ciphertext is 800 bytes and about 1 in 25 fails, in the real decryptions too;
          [run to 100,000] decrypts on
(the live figure needs JavaScript and loads about 0.05 MB of data)
How likely each size of noise is for one coefficient, computed exactly. Green: ML-KEM-768 with the parameters the controls set; thin ink: ML-KEM-512 and 1024. From 832, a quarter of the modulus, decryption fails: for ML-KEM-768 about once in 2165 ciphertexts, a union bound over the 256 coefficients with the parts of the noise taken as independent. The dots and the strip are real decryptions run in the page, 2,000 at first: they check the bulk of the curve, not its tail. The controls change the error width and the bits kept of u and v; run decrypts on to 100,000.

That exact distribution is computed by discrete convolution. Once ciphertext rounding is included, one coefficient of the decryption noise is a sum of 1,537 pieces (768 products from \(e^{\top} r\), 768 products from \(s^{\top}\) times the error on \(u\), and one additive error term on \(v\)), each with a short, explicit probability table. Treating those pieces as independent, adding two random integers combines their probability tables by summing over every pair of values that yields a given total; repeating that table-combining operation across all 1,537 pieces tracks tail probabilities down to levels no experiment could ever sample. For ML-KEM-768, a single coefficient reaches 832 with probability \(2^{-172.8}\). Across all 256 coefficients of a ciphertext, a union bound multiplies that figure by 256 to give at most \(2^{-164.8}\), or about one failure in \(2^{165}\) ciphertexts.

FIPS 203 calls an honest run in which the two sides end with different keys a decapsulation failure, and states its probability for the three parameter sets as \(2^{-138.8}\), \(2^{-164.8}\) and \(2^{-174.8}\). The convolution as it runs in these pages gives \(2^{-138.77}\), \(2^{-164.81}\) and \(2^{-174.76}\).FIPS 203, Section 3.2, under "Decapsulation failures", and Table 1. What is computed here is a bound: the probability for one coefficient times 256, with a noise of exactly 832 counted as a failure, although the reading rule then errs only on a bit of 1 with noise \(+832\). The products of secrets and errors are independent of one another; treating the two rounding errors as independent of them is a modeling step, since the rounded values are built from the same secrets and errors. For the details the standard refers to published scripts (its reference 15, by L. Ducas and J. Schanck, 2021); the computation in these pages was written to the same recipe and reproduces the three figures to the digit printed. The standard adds that its figures treat the hash functions as uniformly random functions. None of this is measured, and none of it could be. Run on to 100,000 real decryptions, the page counts no failure and no noise beyond 336, and the standard deviation it measures, 76.5, is the computed one. The runs check the bulk of the law. The number that matters lies about 150 doublings further down the same curve, where only the computation reaches.

Most of that noise is added deliberately by the sender to shrink the ciphertext. Transmitting raw residues modulo \(q = 3{,}329\) requires 12 bits per coefficient, or 1,536 bytes for \((u, v)\), and leaves decryption failing less than once in \(2^{300}\) ciphertexts. Because security needs nothing remotely as small as \(2^{-300}\), the sender trades away that excess margin by discarding the low-order bits of every coefficient before transmission.

staircases   a coefficient, 0 to 3,328, against what is read back after Compress and Decompress; under each,
             the rounding error: what is read back, less what was sent
             v    4 bits kept of 12      16 levels, error up to 104    2,740 is sent as 13, read back as 2,705: error −35
             u   10 bits kept of 12   1,024 levels, error up to 2      1,929 is sent as 593, read back as 1,928: error −1
             the error of v enters the noise once, as it is; that of u 768 times, each time times a
             coefficient of the secret
saves        every coefficient at 12 bits    u 1,152 + v 384 = 1,536 bytes
             as sent                         u   960 + v 128 = 1,088 bytes: 448 fewer
costs        the variance of the decryption noise of one coefficient, by where it comes from:
             secrets and errors 26 % · rounding of u 12 % · rounding of v 62 %: the rounding supplies 74 %
             standard deviation 76.5 with rounding, 39.2 without; decryption fails about once in 2^165
             ciphertexts (2^-164.8)
(the live figure needs JavaScript; it runs ML-KEM-768's compression in the page and loads no data)
What ML-KEM-768 drops from its ciphertext. Each staircase sends a coefficient through Compress and Decompress: 4 bits kept of 12 for v, 10 for u. Green: the rounding error, under each staircase on one scale, and its share of the noise variance in the bar. Dropping the low bits saves 448 of 1,536 bytes and supplies 74 % of the variance of the decryption noise. u keeps more bits because its error enters the noise 768 times, each time multiplied by a coefficient of the secret. Point at a staircase to read a coefficient; the controls change the bits kept.

Compressing a coefficient to \(d\) bits rounds it to the nearest of \(2^d\) evenly spaced levels around the modulus and sends only the \(d\)-bit index. ML-KEM-768 keeps 10 of the 12 bits in each coefficient of \(u\) and only 4 bits in each coefficient of \(v\), shrinking the ciphertext by 448 bytes from 1,536 bytes to 1,088. Why \(v\) can drop eight bits while \(u\) drops only two becomes clear as soon as the receiver decompresses them to \(u^{\prime} = u + c_u\) and \(v^{\prime} = v + c_v\), with rounding errors \(c_u\) and \(c_v\): in the noisy difference (6.3), \(c_v\) enters each coefficient once on its own, whereas \(c_u\) is multiplied by the secret vector \(s\) and contributes 768 error products per coefficient:

\[w \;=\; v^{\prime} - s^{\top} u^{\prime} \;=\; \mu \;+\; e^{\top} r + e_2 + c_v - s^{\top}\bigl(e_1 + c_u\bigr). \tag{6.3}\]

Example 6.3.1 (the variance of the noise, by hand). Adding the variances of the independent terms in (6.3) shows where the spread of a single noise coefficient in ML-KEM-768 comes from. Each draw from the centered binomial law of Definition 6.1.1 has mean 0 and variance 1, so the product of two independent draws also has variance 1, and \(e^{\top} r\), \(s^{\top} e_1\), and \(e_2\) together contribute \(768 + 768 + 1 = 1{,}537\). Rounding a coefficient of \(u\) to 10 bits introduces an error of at most 2 with variance 0.92; multiplying by \(s\) sums 768 products of variance \(1 \times 0.92\), adding about 710. Rounding a coefficient of \(v\) to 4 bits introduces an error nearly uniform between \(-104\) and 104, contributing variance 3,608 on its own. Summing all three parts gives a variance of about 5,855, or a standard deviation of 76.5, compared with 39.2 from the LWE secrets and errors alone. Those LWE terms supply 26% of the total variance, rounding \(u\) supplies 12%, and rounding \(v\) supplies 62%. ◁

Compression is neither free nor small, then: three quarters of the variance that decryption has to survive is rounding that the sender added, to save 448 bytes. What it does not do is bring a failure within reach. With all 12 bits kept, the same computation puts a failure below once in \(2^{300}\) ciphertexts; as sent, about once in \(2^{165}\). The margin between the two was of no use to anyone, and the designers spent it on bytes. The tutorial by one of them is candid about how the two numbers of bits are found:

In some cases it may also make sense to use a similar bit reduction procedure on the ciphertext part U. Here, though, one cannot remove bits without noticeably increasing the decryption error because any error added to U will get multiplied by S, and so we would get an additional E′′S term in (19), where E′′ is defined analogously to E′. But because U is the dominant source of ciphertext size, reducing the number of bits in U even by a little bit, could make a noticeable difference as well. The trick is then to balance the decryption error and the ciphertext size using trial-and-error.

—V. Lyubashevsky, "Basic Lattice Cryptography: The concepts behind Kyber (ML-KEM) and Dilithium (ML-DSA)" (2024). ePrint 2024/1287, Section 2.5.1. The tutorial writes \(U\), \(V\) and \(S\) for the \(u\), \(v\) and \(s\) of this part; \(E^{\prime}\) and \(E^{\prime\prime}\) are the rounding errors of \(V\) and \(U\), and its equation (19) is (6.3) without the term in \(c_u\).

The trial and error can be repeated on the chart of the noise. With the error width held at 2, no pair of bit counts gives a smaller ciphertext and keeps the bound under the \(2^{-128}\) below which Kyber's designers kept all three sets: the best at 1,056 bytes, 10 bits of \(u\) and 3 of \(v\), fails with probability \(2^{-123.5}\).Computed for these pages with the same convolution, over every pair from 7 to 11 bits of \(u\) and from 1 to 11 bits of \(v\). The Kyber specification, Section 1.4, notes that all three of its parameter sets fail with probability below \(2^{-128}\), with some margin. Further down the failures become visible. At 7 bits of \(u\) the ciphertext is 800 bytes, the bound says one failure in 25, and of 2,000 real decryptions run with that setting 73 fail.

Remark 6.3.2 (a tail is not a variance). It is tempting to estimate the failure probability directly from the standard deviation 76.5. The threshold 832 lies 10.9 standard deviations out, where a Gaussian bell curve would put the tail at about \(2^{-89}\), wildly far from the true \(2^{-172.8}\). Example 6.3.1 shows why: 62% of the variance comes from the single rounding error \(c_v\), which is strictly bounded by 104. Even if \(c_v\) hits 104, the remaining terms, whose combined standard deviation is only 47.4, must still reach \(832 - 104 = 728\), more than 15 of their own standard deviations out, where a Gaussian tail sits near \(2^{-174}\). Even that gives only the rough order of magnitude, because a sum of products of bounded draws has a slightly heavier far tail than a Gaussian while \(c_v\) rarely hits 104 at the same moment. Bounded rounding noise inflates the middle of the distribution without stretching its extreme tail, which is why dropping eight bits of \(v\) saves so many bytes at negligible risk, and why ML-KEM's parameters are chosen by exact convolution rather than Gaussian approximation.

Noisy linear equations, polynomial rings, and asymmetric rounding complete the inner encryption scheme K-PKE. One outer layer is still missing before it is safe to deploy.

ML-KEM, from the inside outfour layers, each built on the one above it; the first three are the encryption of Sections 6.1 to 6.3, the last is what Sections 6.4 and 6.5 add

FROM NOISY EQUATIONS TO ML-KEM

  1. 6.1noisy equations Section 4 · The key is t = A s + e: a secret behind small errors. Each message bit, as 0 or 1,665, rides on a mask that only the holder of s can compute again, up to a noise that must stay under 832.

  2. 6.2polynomials Section 5 · Every entry is a polynomial of 256 coefficients, three to a vector. One product carries 256 message bits side by side, and the key is 1,184 bytes.

  3. 6.3compression the sender · Keep 10 of the 12 bits of each coefficient of u and 4 of v: 1,088 bytes instead of 1,536. The rounding is noise too, most of it, and the budget still holds.

  4. 6.5the wrapper the key holder · Decrypt, encrypt again, compare. A ciphertext that does not match is answered with a key that looks real and matches nothing. Without this layer 3,072 chosen ciphertexts read out a reused key.

green: the layer still missing, the wrapper

Why encryption alone is not enough

Raw K-PKE decryption trusts its input blindly. Nothing in (6.1) checks whether \(u\) and \(v\) were computed honestly from the sender's equations, and a key holder who decrypts arbitrary inputs and lets the sender observe whether the resulting key matched expectations leaks the private key \(s\) in a few thousand queries. Suppose a server reuses one static key pair across many client connections, and an attacker sends a hand-crafted pair \((u, v)\) while acting as if the shared message were all zeros. Even though the server never sends the decrypted message back, the session succeeds when \(w = v - s^{\top} u\) rounds to all zeros and aborts as soon as any bit of \(w\) rounds to 1. Every handshake attempt thus acts as a yes-or-no decryption oracle.

key     one ML-KEM-768 key, generated in the page and used again and again; its secret s has 768
        coefficients, each −2, −1, 0, 1 or 2
attack  a ciphertext that is all zeros but for two numbers: 104 in u, and v at the coefficient under attack.
        Decryption computes v − 104·s there and reads a bit: 1 if the value is above 832 and below 2,497.
        The attacker asks: did it decrypt to all zeros? Four values of v name the coefficient:
                    if s were  −2      −1       0       1       2
        v =   832           1,040     936     832     728     624      no  no  yes yes yes
        v = 1,040           1,248   1,144   1,040     936     832      no  no  no  no  yes
        v = 2,289           2,497   2,393   2,289   2,185   2,081      yes no  no  no  no
        v = 2,497           2,705   2,601   2,497   2,393   2,289      yes yes yes no  no
grid 1  against the inner encryption alone: 3,072 ciphertexts, 768 of 768 coefficients named,
        the recovered key equals the real one (1,152 bytes)
grid 2  against ML-KEM, the same 3,072 ciphertexts: the answer is no 3,072 times, 0 coefficients named
(the live figure needs JavaScript; it loads no data)
A reused ML-KEM-768 key, read out by an attacker who learns only yes or no. Green: the coefficients the answers have named; the wash is the real key. First grid: the inner encryption says whether each crafted ciphertext decrypted to all zeros; four ciphertexts name a coefficient, as the table shows for the one in hand (washed: reads as 1; boxed: what decryption computed). Second grid: the same ciphertexts go to ML-KEM, which answers no every time. Run sends them all, step one; point at a cell to see its four ciphertexts. Every decryption runs in the page, on a key generated there.

The attacker's ciphertexts do not encrypt any message at all; they isolate one coefficient of \(s\) at a time. Set \(u\) to zero everywhere except for the constant polynomial 104 in one of its three slots, and set \(v\) to zero everywhere except for a chosen level \(V\) in coefficient \(i\) (both 104 and the four levels \(V\) used below are exact values representable by the 10-bit and 4-bit compressed ciphertext formats). Because multiplying by a constant polynomial never mixes indices, the inner product \(s^{\top} u\) equals \(104\, s_j\) at every position \(j\) of the targeted polynomial of \(s\). At all 255 positions \(j \neq i\), decryption computes \(w_j = -104\, s_j\), whose magnitude is at most \(104 \times 2 = 208 < 832\) and therefore always decodes to 0. Only at the targeted index \(i\) does decryption form \(w_i = V - 104\, s_i\), so the whole 256-bit output is all zeros if and only if \(w_i\) falls outside the 1-bit interval \((832, 2{,}497)\). Sliding \(V\) near the two ends of that interval turns each handshake into a threshold test on \(s_i \in \{-2, -1, 0, 1, 2\}\): \(V = 832\) tests whether \(s_i \ge 0\), \(V = 1{,}040\) tests whether \(s_i = 2\), \(V = 2{,}289\) tests whether \(s_i = -2\), and \(V = 2{,}497\) tests whether \(s_i \le 0\). Four yes-or-no answers identify \(s_i\) uniquely, so \(4 \cdot 768 = 3{,}072\) queries read out the entire secret key.

Nothing in this is costly or subtle, and the lattice problem of Sections 3 and 4 is as hard as it was: the attack never meets it. The 3,072 ciphertexts here are fixed in advance, the same for every key. An attacker who chooses each question after the last answer needs fewer: on average 2.3125 a coefficient, which makes 1,776 for the key.Q. Guo, E. Mårtensson and A. Åström, "The Perils of Limited Key Reuse: Adaptive and Parallel Mismatch Attacks with Post-processing Against Kyber", IACR Communications in Cryptology 1(3), 2024. Its Section 3.1 describes this attack on one coefficient at a time, which comes from earlier work that it cites, and gives the average; 1,776 is 768 times that, multiplied out here. With the probabilities of Definition 6.1.1, a first question that splits the values into \(\{-2, -1\}\) and \(\{0, 1, 2\}\) and a second that settles 0 leave a third only for 1 and 2: \((2 \cdot 5 + 2 \cdot 6 + 3 \cdot 5)/16 = 2.3125\). The paper's own attacks learn about several coefficients from one question and need fewer still. The fixed questions of these pages come to 3,072 for ML-KEM-512 as well, six a coefficient for its seven possible values, and to 4,096 for ML-KEM-1024. The literature has a name for the setting:

A particularly relevant attack type to the CPA-secure KEMs without CCA security is keypair-reuse attacks. In 2016, Fluhrer initiated key-reuse attacks against lattice-based encryption [Flu16]. Later, Ding, Fluhrer, and Saraswathy extended these attacks to lattice-based key exchange and introduced the concept of a key mismatch attack [DFR18]. In a key mismatch attack, one communicating party’s public key is reused. An adversary impersonates the other party, sends maliciously formed responses and recovers the secret key bit by bit, by repeatedly verifying if the two derived shared keys match. This type of attack can be applied to many lattice-based KEMs, with subsequent improvements in query complexities reported in various studies [BBLP18, BGRR19, BDH+19, QCD19, OWT20, GMR20, HV20, QCZ+21, GM23].

—Q. Guo, E. Mårtensson and A. Åström, "The Perils of Limited Key Reuse" (2024). Section 1 of the paper; the keys in brackets are its references. A KEM that is CPA-secure withstands a chosen-plaintext attack, which for a public-key scheme means an attacker who only listens and encrypts; CCA security, against chosen ciphertexts, is what the rest of this part builds.

FIPS 203 draws the consequence in one sentence: "The scheme K-PKE is not IND-CCA2-secure and shall not be used as a stand-alone scheme". IND-CCA2 names the stronger security guarantee needed when keys are reused: an attacker learns nothing about a target session's shared secret even after submitting arbitrary other ciphertexts to a decapsulation oracle and observing the keys that come back. ML-KEM is wrapped to enforce that guarantee. When the same 3,072 crafted ciphertexts are submitted to full ML-KEM, the attacker can only check whether the returned 32-byte key matches what an honest sender of the all-zero message would derive. None of the 3,072 ever matches, not even on the 1,144 ciphertexts that raw K-PKE decrypted to all zeros in the run above. FIPS 203 therefore presents ML-KEM in two stages:

The ML-KEM construction. At a high level, the construction of the scheme ML-KEM proceeds in two steps. First, the ideas discussed previously are used to construct a public-key encryption (PKE) scheme from the MLWE problem. Second, this PKE scheme is converted into a key-encapsulation mechanism using the so-called Fujisaki-Okamoto (FO) transform [11, 12]. Due to certain properties of the FO transform, the resulting KEM provides security in a significantly more general attack model than the PKE scheme. As a result, ML-KEM is believed to satisfy so-called IND-CCA2 security [1, 4, 13, 14].

—NIST, FIPS 203, "Module-Lattice-Based Key-Encapsulation Mechanism Standard" (2024). Section 3.2, the paragraph headed "The ML-KEM construction"; the sentence on K-PKE stands in the same section. MLWE is module learning with errors, the problem of Definition 5.3.1; the numbers in brackets are the standard's references.

The Fujisaki-Okamoto transform: decrypt, encrypt again, compare

The mismatch attack worked because K-PKE let the sender pick arbitrary ciphertexts independent of any message. The Fujisaki-Okamoto transform removes that freedom in a way the receiver can verify. Instead of choosing the encryption coins \((r, e_1, e_2)\) freely, the sender draws a random 32-byte value \(m\) and hashes \(m\) together with the hash of the encapsulation key into 64 bytes: the first 32 bytes become the shared secret \(K\), and the remaining 32 bytes form the seed that deterministically generates every random draw of K-PKE encryption in Definition 6.1.1. Because valid encryption is now a deterministic function of \(m\) and the public key, the receiver can decrypt \(c\) to a candidate \(m^{\prime}\), recompute the seed, run encryption a second time, and check whether the re-encrypted ciphertext matches \(c\) bit for bit.

sender      m ← 32 random bytes;  (K, r) ← G(m ‖ H(ek));  c ← Encrypt(ek, m, r): 1,088 bytes, 8,704 bits
                                           the ciphertext as sent          the same with bit 1 flipped
key holder  m′ ← Decrypt(dk, c)            = m                             = m
            (K′, r′) ← G(m′ ‖ H(ek))       = K, r                          = K, r
            c′ ← Encrypt(ek, m′, r′)       = c as sent                     = c as sent
            compare c′ with the c received equal: all 8,704 bits           differ: 1 bit of 8,704
            returns                        K′ = K, the shared secret       J(z ‖ c): 32 pseudorandom bytes,
                                                                           135 of 256 bits from K, no error
bit 1       is the lowest of the 10 bits of a coefficient of u: it moves that coefficient by 3 (modulus 3,329)
census      each of the 8,704 bits flipped alone: 8,704 are caught; 6,013 still decrypt to the sender's message
(the live figure needs JavaScript and shows the real bytes of every station; it loads no data)
ML-KEM's decapsulation, station by station, on real bytes. Green: the comparison of the ciphertext encrypted again with the one received, with a tick wherever the two differ. The key holder decapsulates the ciphertext as sent and, beside it, the same ciphertext with one bit flipped: decrypt, hash, encrypt again, compare, then return the shared secret or 32 pseudorandom bytes; the blocks are the 256 bits of each key. Click or drag on the ciphertext to choose the bit; tamper flips one at random; new run draws a new key and message. A mark under a bit: flipped alone, it changes the decrypted message.

A ciphertext is accepted only if it is, bit for bit, what the sender's computation yields for the message it decrypts to. Whoever can make such a ciphertext knows \(m\), and so knows \(K\) already: the answer tells them nothing, and that is the sense in which the transform makes the oracle of Section 6.4 useless.Lyubashevsky's tutorial, Section 4.8, gives this as the intuition of the transform: "to make the decapsulation oracle “useless” to the adversary". Every other ciphertext is answered with 32 bytes that look like a key and match nothing.

Decryption by itself could never spot tampering, because a decoder built to absorb lattice noise absorbs small adversarial edits right along with it: flipping any single bit of the 8,704-bit ciphertext shown above leaves the decrypted message unchanged in 6,013 of the 8,704 positions, whereas re-encrypting and comparing catches all 8,704. Whenever the re-encrypted cPrime differs from the received c, decapsulation avoids returning an explicit error flag and instead outputs a pseudorandom fallback key Kbar derived from c and a secret 32-byte seed z inside the decapsulation key. In the page's implementation, the entire wrapper takes seven lines:

var mPrime = kpkeDecrypt(P, dkPKE, c, trace && (trace.dec = {}));
var g = HASH.sha3_512(bytes.concat(mPrime, h));            // (K', r') = G(m' || h)
var KPrime = g.subarray(0, 32), rPrime = g.subarray(32, 64);
var Kbar = HASH.shake256(bytes.concat(zz, c), 32);         // J(z || c)
var cPrime = kpkeEncrypt(P, ekPKE, mPrime, rPrime);
var match = bytes.equal(c, cPrime);
var K = match ? KPrime : Kbar;

g is the hash \(G\) of the decrypted message and of h, the stored hash of the encapsulation key; its halves are the candidate key and the seed (the last argument of the first line only records values for the figures). Kbar is the key for the other case, a hash \(J\) of the ciphertext with 32 secret bytes \(z\) that were drawn at key generation, and it is computed every time, before the comparison is made. \(G\), \(H\) and \(J\) are the standard's names for three hash functions of the SHA-3 family. This is also why a decapsulation key is 2,400 bytes long: the 1,152 bytes of \(s\), then the whole encapsulation key, 1,184 bytes, to encrypt again with, its hash and \(z\), 32 bytes each. FIPS 203 says the same in prose:

Informal description. The algorithm ML-KEM.Decaps_internal begins by parsing out the components of the decapsulation key dk of ML-KEM. These components are an (encryption key, decryption key) pair for K-PKE, a hash value ℎ, and a random value 𝑧. The decryption key of K-PKE is then used to decrypt the input ciphertext 𝑐 to get a plaintext 𝑚′. The decapsulation algorithm then re-encrypts 𝑚′ and computes a candidate shared secret key 𝐾′ in the same manner as should have been done in encapsulation. Specifically, 𝐾′ and the encryption randomness 𝑟′ are computed by hashing 𝑚′ and the encryption key of K-PKE, and a ciphertext 𝑐′ is generated by encrypting 𝑚′ using randomness 𝑟′. Finally, decapsulation checks whether the resulting ciphertext 𝑐′ matches the provided ciphertext 𝑐. If it does not, the algorithm performs an “implicit rejection”: the value of 𝐾′ is changed to a hash of 𝑐 together with the random value 𝑧 stored in the ML-KEM secret key (see the discussion of decapsulation failures in Section 3.2). In either case, decapsulation outputs the resulting shared secret key 𝐾′.

—NIST, FIPS 203 (2024). Section 6.3: the paragraph that describes the internal decapsulation algorithm, Algorithm 18, in words. The primes mark the key holder's copies of the sender's values. The paragraph that follows calls the outcome of the comparison a secret piece of intermediate data, to be destroyed before the algorithm ends and not to be returned in any form.

Remark 6.5.1 (not a check of the format). The comparison is easily read as validation, a test that the ciphertext is well formed. It is not: every string of 1,088 bytes is a well-formed ciphertext and decrypts to some message. What the comparison tests is that the sender knew the message and followed the recipe, so that every ciphertext the key holder answers with the real key is one whose answer the sender could have computed alone.

Returning a plausible key and no error is called implicit rejection, and it is why the exchange of the introduction did not fail when a bit of its ciphertext was flipped. The mismatch shows only later, when the two sides find that their keys differ, and the standard forbids letting even the outcome of the comparison out. In the security argument the choice removes a question that an attacker could otherwise ask, whether a ciphertext is valid, and with it an assumption about what the answer gives away. Whether it matters in practice is not settled: the tutorial quoted in Section 6.3 calls the reasoning "somewhat technical" and adds that "it is not really clear whether this adds any security in practice".

What is proved about the construction is a conditional reduction. Modeling the hash functions as ideal random oracles, any attacker who breaks ML-KEM with access to a decapsulation oracle can be converted into a passive attacker who breaks K-PKE while only listening. That reduction loses an additive term proportional to the decryption failure probability of Section 6.3 multiplied by the number of hash and decapsulation queries the attacker can afford: if an attacker could find an honest message \(m\) whose valid encryption fails to decrypt back to \(m\), the re-encryption check would reject a legitimate ciphertext and leak information about \(s\), which is why failures had to sit near \(2^{-165}\) rather than merely being rare.D. Hofheinz, K. Hövelmanns and E. Kiltz, "A Modular Analysis of the Fujisaki-Okamoto Transformation", TCC 2017 (ePrint 2017/604), Section 1.2, for the transform in two steps and its variants with implicit and explicit rejection; the variant with an explicit error needs the inner scheme to withstand, in addition, an oracle that says whether a ciphertext is valid. Against an attacker who evaluates the hash functions in quantum superposition, the paper proves the second step only for a variant that adds a hash to the ciphertext, which ML-KEM does not send, and with reductions that all lose large factors. ML-KEM uses a variant of its own, which differs in what is hashed into the key (Section 6.7). Everything outside that reduction remains an assumption: that Module-LWE (Definition 5.3.1) resists passive attacks as discussed in Sections 4.5, 4.6, and 5.6, that SHA-3 has no exploitable algebraic shortcut, and that the running code leaks nothing through timing or power. FIPS 203 words its claim accordingly: ML-KEM "is believed to satisfy" IND-CCA2 security.

The wrapper is paid for by the key holder alone: one more encryption in every decapsulation, and a longer key to keep. It adds no byte to what crosses the wire.

Three sizes, and what crosses the wire

The standard has three parameter sets, one for each of the three ranks of Section 5.3, and in the code they are three rows of a table. The rank \(k\) sets the dimension; the smallest set draws its secrets a little wider, and the largest keeps one more bit of every coefficient of the ciphertext.

parameter set category rank \(k\) error widths bits kept of \(u\), \(v\) encapsulation key, bytes ciphertext, bytes failure probability
ML-KEM-512 1 2 3, 2 10, 4 800 768 \(2^{-138.8}\)
ML-KEM-768 3 3 2, 2 10, 4 1,184 1,088 \(2^{-164.8}\)
ML-KEM-1024 5 4 2, 2 11, 5 1,568 1,568 \(2^{-174.8}\)
The parameter sets of ML-KEM, from FIPS 203, Tables 1 to 3, and its Section 8 for the categories; in bold, the set that the figures of this part run. A category is NIST's measure of what a break must cost: at least as much as a search for the key of the block cipher AES-128, AES-192 or AES-256 for categories 1, 3 and 5. The first error width bounds the coefficients of \(s\), \(e\) and \(r\), the second those of \(e_1\) and \(e_2\). The shared secret is 32 bytes in all three sets; the decapsulation keys, which are never sent, are 1,632, 2,400 and 3,168 bytes.

A category is a claim about the best attacks known and not a theorem: Section 4.6 has the estimates behind it, Section 5.6 what is known about the structure of these lattices, and Section 10.4 how categories are assigned. The smallest set shows the dials of Section 6.3 being turned. For the third round of NIST's process its designers widened the secrets from 2 to 3 to raise the estimated cost of attacks, which raised the noise, and they paid for that by keeping one more bit of \(v\): 768 bytes of ciphertext where there had been 736.The Kyber specification, version 3.02, in the list of changes at its head: the binomial width of the key and of the sender's secret went from 2 to 3 for Kyber512, that of \(e_1\) and \(e_2\) stayed, and one bit less is dropped from the second part of the ciphertext. The share of rounding in the variance of the noise, by the computation of Example 6.3.1, is 69% in ML-KEM-512, 74% in ML-KEM-768 and 39% in ML-KEM-1024. In speed there is little to pay: the introduction has the rates of ML-KEM-768 beside those of X25519, the elliptic-curve key agreement of Section 1.3, measured on one core.

On the web the two travel together. TLS 1.3, the protocol under HTTPS, has a way of agreeing on a key named X25519MLKEM768, a hybrid: the client sends an ML-KEM-768 encapsulation key and an X25519 value side by side, and the server answers with a ciphertext and an X25519 value of its own. Six of eight well-known sites tried for this series on 30 November 2026 agreed to it, and the bytes of those handshakes can be laid beside the bytes of handshakes with the same sites over X25519 alone.

bytes on the wire, in TLS records, of handshakes captured with OpenSSL's client (no packets were captured)
                      the client's first flight   the server's flight         segments of 1,448 bytes (assumed)
                      X25519     hybrid           X25519     hybrid           the server's flight needs
www.google.com           240      1,416            2,779      3,867           2, then 3
www.cloudflare.com       244      1,420            2,843      3,931           2, then 3
www.facebook.com         242      1,418            3,273      4,360           3, then 4
www.apple.com            239      1,415            3,805      4,881           3, then 4
www.youtube.com          241      1,417            3,854      4,941           3, then 4
www.amazon.com           240      1,416            4,841      5,929           4, then 5
hybrid  X25519MLKEM768: the client's key share is 1,216 bytes (ML-KEM-768 encapsulation key 1,184, X25519 32),
        the server's 1,120 (ML-KEM-768 ciphertext 1,088, X25519 32); with X25519 alone both are 32
cost    1,176 bytes more from the client at all 6 sites, still one segment (1,415 to 1,429 bytes in 18 captures);
        1,076 to 1,088 more from the server, one more segment at 6 of 6; 2,252 to 2,264 bytes a handshake
secret  ML-KEM's 32 bytes, then X25519's 32, concatenated: 64 bytes into HKDF-Extract (neither is ever sent)
(the live figure needs JavaScript and loads about 0.2 MB of data)
TLS 1.3 handshakes with six sites, captured with OpenSSL's client: X25519 alone above, the hybrid X25519MLKEM768 below, in bytes to scale. Green: the ML-KEM bytes, an encapsulation key from the client and a ciphertext from the server; ink: the X25519 bytes; shades: the other TLS records. No packets were captured: the dashed hairlines are assumed 1,448-byte segments, and the hatching marks bytes in a segment that X25519 alone did not need. The slider changes the assumption; point at a field to read its host, time and bytes. A browser's first message, which can carry a second key share for X25519 alone, was not measured.

With the client of the OpenSSL library, the hybrid adds 1,176 bytes to the client's first flight, the messages it sends before it waits for an answer, and 1,076 to 1,088 bytes to the server's: about 2.3 kilobytes a handshake. The client's larger message still fits one packet if a packet carries 1,448 bytes, which is assumed here and was not captured; the server's flight then needs one more packet at each of the six sites. A browser's first message can offer X25519 alone as well, beside the hybrid, and holds more; it was not measured. The two secrets never travel: each side ends with 32 bytes from ML-KEM and 32 from X25519, which go end to end into the key derivation of TLS, so that the session key is meant to hold as long as either scheme does. Section 11.1 has the construction, what that claim assumes and the reasons for running both, and Section 11.2 follows how it spread.

In this exchange the client is the key holder, and a client that makes a fresh key pair for every connection leaves the attack of Section 6.4 no reused key. ML-KEM is wrapped all the same, and the Kyber specification gives two reasons for defining nothing weaker: the wrapper "allows (intentional or accidental) caching of ephemeral keys", and its second encryption catches a partner whose implementation draws wrong noise, "for example, all-zero noise", which a scheme that only decrypts would never notice.The Kyber specification, Section 1.5, under "Active security". An ephemeral key is one made for a single exchange. TLS 1.3 does not require a fresh one for every connection, and for that reason the document that fits hybrids into it, which recommends one, demands that a KEM used this way stay secure when its key is used again (D. Stebila, S. Fluhrer and S. Gueron, "Hybrid Key Exchange in TLS 1.3", RFC 9954, July 2026, Section 2).

Where implementations slipped, and what the standard changed

The wrapper removes the oracle from the algorithm. An implementation can put it back, and in 2023 the reference implementation of Kyber was found to have done so, through a flaw since named KyberSlash. The last line of the listing of Section 6.1 rounds each coefficient of \(w\) to a bit: double it, add half the modulus, divide by 3,329. The reference code, written in C, wrote the division as a division, ((t << 1) + KYBER_Q/2)/KYBER_Q. A compiler usually turns a division by a constant into a multiplication; asked to optimize for size, it may emit a division instruction, and that instruction takes longer for some numbers than for others. The number divided here is \(w\), the message plus the noise of (6.3): a function of the secret key and of a ciphertext that the attacker chose.

First, this paper describes two variants of the KyberSlash vulnerability present in the November 2023 version of the Kyber reference implementation: KyberSlash1 is present in the decryption of the CPA-secure encryption scheme underlying Kyber and directly leaks information about the secret key. KyberSlash2 is present in the encryption of the CPA-secure encryption scheme and leaks information about the ciphertext. While this is unproblematic inside encapsulation as the ciphertext is public, it can be used to construct a plaintext-checking (PC) oracle in decapsulation allowing key recovery.

—D. J. Bernstein and nine co-authors, "KyberSlash: Exploiting secret-dependent division timings in Kyber implementations" (2025). D. J. Bernstein, K. Bhargavan, S. Bhasin, A. Chattopadhyay, T. K. Chia, M. J. Kannwischer, F. Kiefer, T. B. Paiva, P. Ravi and G. Tamvada, IACR Transactions on Cryptographic Hardware and Embedded Systems 2025(2), pp. 209 to 234; the first paragraph of Section 1.2, and Section 1.1 for the compilers. A plaintext-checking oracle is the oracle of Section 6.4. The paragraphs that follow and Table 1 report the attacks as run: through the first variant, a Kyber512 key recovered in ten experiments of ten, within two to four hours, on a Raspberry Pi 2; through the second, on a small processor, an Arm Cortex-M4, a Kyber768 key recovered from 24,576 decapsulations, within four minutes, again in ten of ten.

The first variant sat in the decryption and was noticed while a formally verified implementation was being written; the reference code was patched on 1 December 2023. The divisions were announced as a possible security issue on 15 December, and the second variant, in the encryption that every decapsulation runs again, on 30 December.The section "History" of the papers page of the KyberSlash site (kyberslash.cr.yp.to/papers.html), version of 23 August 2025. The scheme on paper was untouched: the leak was in how one line of C became machine code. The code in these pages divides at the same places, and it compares the two ciphertexts of Section 6.5 with a loop that stops at the first difference. It is written to be read, as the introduction says, and Section 10.5 measures what such a loop gives away.

What FIPS 203 itself changed from the third-round Kyber submission is small on paper. The lattice, the parameter sets, and the byte sizes stayed identical, while the domain-separation hashes and input checks around them were tightened:

  Kyber, third round (2021) ML-KEM, FIPS 203 (2024)
the shared secret a further hash, of any length, of the first half of \(G(m \,\Vert\, H(ek))\) and of a hash of the ciphertext that first half as it is, 32 bytes
the key for a rejected ciphertext a hash of \(z\) and of a hash of the ciphertext \(J(z \,\Vert\, c)\)
the sender's 32 random bytes hashed once before use used as drawn
what comes in taken as it comes checked: an encapsulation key must decode to residues below \(q\)
key generation expands its seed alone hashes the rank \(k\) in with the seed
The differences between the Kyber of the third round and ML-KEM that change what the three algorithms output, from FIPS 203, Appendix C, and from the specification of Kyber, version 3.02; \(ek\) is the encapsulation key and \(\Vert\) joins two strings of bytes. The draft of the standard, posted on 24 August 2023, had all but the last row.

By the first row alone, a library that speaks Kyber and one that speaks ML-KEM do not arrive at the same shared secret; Section 11.2 has the switch that this forced on the web.

ML-KEM is the noisy equations of Section 4 in the polynomials of Section 5, with a ciphertext rounded until the rounding is most of the noise, inside a wrapper that answers only the ciphertexts a sender could have computed from the message alone. Each layer has a price that can be stated as a number: about a kilobyte each way on the wire, a failure once in 2165 ciphertexts, a second encryption in every decapsulation.

Section 7 builds signatures on the same lattices. There the care is of another kind: it is the honest signer's own answers that leak.

← Back to all posts