← Back to section · Post-Quantum Cryptography

NTT Arithmetic in Detail: Why ML-KEM Is Fast — the Secret Is the Modulus 3329

Polynomial multiplication is the performance lifeline of lattice cryptography: how the number theoretic transform cuts convolution from O(n²) to O(n log n), why q=3329 was chosen, and what the incomplete-splitting NTT and base-case multiplication are about.

Published 22 November 2026 · 6 min read · PQ Frontier

NTT Arithmetic in Detail: Why ML-KEM Is Fast — the Secret Is the Modulus 3329
AI-generated site artwork
Video explainer · ML-KEM: one complete key exchange

The performance lifeline: polynomial multiplication

Open any step of ML-KEM — Â ∘ ŝ in key generation, the matrix–vector product in encryption, the inner product in decryption — and the core operation is the same: multiplication in the polynomial ring R_q = Z_q[X]/(X^256 + 1). Done naively, multiplying two degree-256 polynomials is a convolution of 256 × 256 ≈ 65,000 coefficient multiplications, followed by reduction modulo X^256 + 1. A single encapsulation needs several such products; doing them naively is slow and power-hungry, a burden for gateways, phones and IoT devices alike.

The fix borrows the fast Fourier transform idea from signal processing, transplanted to a finite field as the number theoretic transform (NTT): transform both polynomials into the “NTT domain”, where multiplication degenerates into component-wise simple products, then transform back. The complexity drops from O(n²) to O(n log n); a degree-256 transform takes on the order of a thousand butterfly operations. This is why lattice cryptography collectively moved to NTT-friendly parameters in the late 2010s, and the root reason ML-KEM runs in tens of microseconds on ordinary CPUs.

q = 3329: a modulus tailor-made for the NTT

The NTT only works if the multiplicative group modulo q contains roots of unity of sufficiently high order. For n = 256, one needs conditions of the shape q ≡ 1 (mod 256). ML-KEM’s q = 3329 satisfies 3329 = 2^8 × 13 + 1, i.e. 256 divides q − 1, so 256th roots of unity exist in the field (FIPS 203 takes ζ = 17 as the primitive root generating all the twiddle factors).

But the order condition is only the entry ticket; the specific value 3329 serves three further goals. First, it is prime, so Z_q is a field and arithmetic has no zero-divisor headaches. Second, it is small: a coefficient needs only 12 bits of encoding (2^12 = 4096 > 3329), and packing every public-key coefficient at 12 bits is the direct reason public keys stay at the kilobyte scale. Third, it leaves room for noise: secret and noise coefficients are single-digit in size, and decapsulation decides bits by whether a value lies closer to 0 or to q/2 — the ratio of q to the noise sets the decision margin and hence the failure probability. A larger modulus is not impossible, but it would inflate encoding sizes and rewrite all the security estimates — the parameters form a single whole, and 3329 is the balance point the Kyber team chose in the security/size/speed triangle.

Incomplete splitting: 128 linear components and base-case multiplication

One detail often confuses newcomers: X^256 + 1 does not factor completely into 256 linear factors modulo 3329 — it factors into 128 quadratic factors. ML-KEM’s NTT is therefore “incompletely splitting”: the transform’s output is not 256 scalars but 128 linear polynomials (each holding two coefficients). Multiplication in the NTT domain accordingly becomes 128 base-case multiplications (BaseCaseMultiply): products of two linear polynomials taken modulo X² − γ, where γ is the constant of the corresponding quadratic factor, each costing a handful of coefficient multiplications. The inverse NTT then maps the result back to ordinary coefficient form.

This “half step” is deliberate: forcing a complete split would demand a larger modulus or extension-field arithmetic, costing far more than a few extra base-case multiplications. In implementations, the butterfly structure of the NTT and inverse NTT and every base-case constant are fixed by the appendices of FIPS 203 (including the complete twiddle-factor table), and implementations in every language must match item for item — one wrong constant here and the keys you produce interoperate with nothing.

Encoding and compression: the other half of the data layer

Beyond the NTT, ML-KEM’s data representation has two more layers. Byte encoding: coefficients are packed d bits at a time (public-key coefficients at d = 12, ciphertext components at d = du or dv), and ByteEncode/ByteDecode convert between byte strings and coefficient arrays — they also define the serialisation formats of keys. Compression: before transmission, ciphertext components are compressed from mod q down to mod 2^d (Compress_d performs a rounding rescale), and the receiver decompresses back to an approximation. The error compression introduces is charged against the total noise budget — which is why du/dv affect the failure probability. The bugs that bite in practice live precisely in these two layers: bit-packing order, rounding direction, the normalisation scaling after the inverse transform (multiplication by constants such as 3303 ≡ 128^-1 mod q). Any single deviation yields an implementation that “runs but does not interoperate”, so the official test vectors must be matched byte for byte.

Squeezing out more at the implementation layer: lazy reduction and vectorisation

The standard guarantees interoperability, not speed; speed is squeezed out at the implementation layer. Three families of technique are common. First, lazy reduction: let coefficients grow through a run of multiply–accumulates (as long as the machine word does not overflow) and reduce modulo q once every few steps, saving large numbers of modular reductions — at the price of having to bound every coefficient’s maximum exactly, where a miscalculation becomes a hidden correctness bug. Second, choice of reduction algorithm: replace division-based modular reduction with Barrett or Montgomery reduction, trading division instructions for multiplications and shifts, which pays off especially on embedded cores without fast dividers. Third, vectorisation: the NTT’s butterflies are mutually independent, so AVX2/NEON implementations process several coefficients in parallel, and with precomputed twiddle-factor layouts the throughput multiplies again. The binding constraint on all of this is that results must agree with the standard bit for bit: one wrong bound or one misplaced constant produces keys that interoperate with nothing. That is why the release process of a high-performance implementation treats the official test vectors and cross-implementation interoperability testing as unskippable gates — correct first, fast second is the house rule of this layer.

Summary

ML-KEM’s speed comes not from hardware brute force but from parameters and algorithm designed together: 3329 makes the NTT possible and the encoding compact, the incompletely splitting NTT plus base-case multiplication brings polynomial products down to an acceptable cost, and byte encoding with compression guards the sizes. For implementers this layer leaves no room for improvisation — copy the constant tables verbatim, match the test vectors, and spend the remaining optimisation effort on instruction-level work and constant-time discipline.

References

  1. NIST, FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard, 2024 (Appendix A gives the NTT twiddle-factor table). https://doi.org/10.6028/NIST.FIPS.203
  2. CRYSTALS Team, CRYSTALS-Kyber Algorithm Specifications and Supporting Documentation, Round 3 submission, 2021. https://pq-crystals.org/kyber/

Tags: ML-KEMNTTPolynomial ArithmeticLattice Cryptography