← Back to section · Research & Analysis
The Cost Structure of the NTT: Why Lattice Cryptography Is Fast
Most of the speed of ML-KEM and ML-DSA comes from the Number Theoretic Transform. This article breaks down where butterfly operations spend their cost, why the modulus and dimensions were reverse-engineered for the transform, and how precomputed tables trade memory for time.
Lattice cryptography often gives an odd impression: built on seemingly heavy algebraic machinery, yet surprisingly fast in practice. ML-KEM encapsulation and ML-DSA verification run in the microsecond to sub-millisecond range on ordinary processors, on par with or faster than many classical schemes. This speed is not squeezed out by implementation tricks. It comes from a structural fact: their core operation — polynomial multiplication — can be accelerated by the Number Theoretic Transform (NTT) to near optimality. To understand the performance profile of lattice cryptography, first understand what the NTT’s cost actually looks like.
Butterfly operations: where the cost goes
Naively multiplying two degree-256 polynomials takes roughly 256×256 coefficient multiplications — quadratic complexity. The NTT follows the same architecture as the Fast Fourier Transform: transform the polynomials into a “point-value representation,” multiply pointwise, then transform back. One complete forward or inverse transform contains on the order of n log₂n butterfly operations, each butterfly being one modular multiplication plus two modular additions or subtractions. For n=256, that is on the order of two thousand butterflies, versus more than sixty thousand multiplications for the naive method — a gap approaching the middle of two orders of magnitude.
But the butterfly count is only part of the ledger. The real cost of each butterfly depends on how the modular multiplication is done. When the modulus is small (3329, for instance, occupies only 12 bits), products stay within 24 bits, and lazy reduction can accumulate several multiply-adds before a single reduction, amortizing the reduction cost. With a large or awkwardly shaped modulus, every step pays the full price of modular reduction. This is why implementations of schemes that all “use the NTT” can differ in speed by a factor of several: the butterfly structure is identical, but the per-step cost is entirely different.
Parameters reverse-engineered from the transform
ML-KEM’s choice of q=3329 and n=256 is anything but arbitrary. The NTT requires the modulus q to satisfy a congruence of the form q ≡ 1 (mod 2n): q−1 must be divisible by a sufficiently large power of two, so that the multiplicative group modulo q contains roots of unity of high enough order for the transform to split recursively. Since 3329 = 13×2⁸+1, a 256-dimensional transform is exactly feasible; and 3329 is small enough that coefficient multiplication fits comfortably in 16-bit arithmetic.
There is a further detail that is often overlooked: ML-KEM’s NTT is “incomplete.” Modulo 3329, X²⁵⁶+1 splits only down to 128 quadratic factors, so the transform yields 128 pairs of coefficients of linear polynomials, and pointwise multiplication must be performed as “base multiplication” on these 128 small rings rather than as simple scalar multiplication. This extra structural complexity buys freedom in parameter selection — designers did not have to enlarge the modulus just to achieve complete splitting. ML-DSA uses the much larger modulus 8380417 (23 bits), whose roots of unity reach higher orders and whose splitting behaves differently again. When reading the NTT performance of the two schemes, look first at their respective algebraic constraints, and only then at implementation technique.
Precomputed tables: buying time with memory
The powers of the roots of unity (twiddle factors) are used repeatedly in every transform, and precomputing them into a table is standard practice. The table is small, but it opens a classic engineering trade-off: a larger table saves more computation per lookup, yet the table itself competes for cache. On cache-starved microcontrollers, arranging twiddle factors in bit-reversed order, or even computing them on the fly, are choices made to fit different memory hierarchies. The inverse transform also ends with a scaling by n⁻¹, and such “finishing costs” are a non-negligible fraction of short operations — one reason measured speedups for small parameter sets often fall short of theory: fixed overheads do not amortize.
Beyond the NTT: remember the matrix and the sampling
Perfecting the NTT does not make lattice schemes proportionally faster, because two other hard blocks remain in the total cost. The first is generating matrices and vectors: ML-KEM’s public matrix A is never transmitted; it is derived from a 32-byte seed by expanding with SHAKE128 and rejection-sampling each element. Every key generation and encapsulation therefore runs an extendable-output function plus sampling pipeline, and hash throughput directly sets this portion of the cost. The second block is noise sampling and encoding/decoding. In profiling of many public implementations, the Keccak permutation (the core of SHAKE) consumes cycles comparable to — or exceeding — the NTT itself. The practical conclusion: when evaluating a lattice scheme’s performance, look at the ratio between the two main lines, NTT and Keccak. A figure that reports NTT speed alone is reporting only half the ledger.
Optimization order, read from the shares
This three-level structure also yields an empirical order for implementation optimization: measure the shares first, then cut. The main-line ratios differ completely by operation — in key generation, matrix expansion dominates and Keccak is the first optimization target; in verification there is no matrix expansion, so the NTT’s share rises passively and vectorization pays off most visibly; encapsulation pays on both lines. Talking about “optimizing the NTT” without naming the operation is like quoting benchmarks without a scenario: for key generation it may touch only a third of the bill. The optimization history of mature implementations essentially follows this share curve: hashing first, then the transform, and finally the finishing work of encoding and packing.
The same share logic explains the non-linearity across parameter sets: from ML-KEM-512 to ML-KEM-1024, the module dimension k rises from 2 to 4, so the Keccak workload of matrix expansion grows with the square of k while the NTT workload grows linearly, and the cost ratio between the two operation sets drifts with the parameter set. Citing performance figures together with their parameter set is not pedantry — the very shape of the profile changes with the parameters.
Summary
The NTT is the speed engine of lattice cryptography, but its cost structure is determined on three levels: the magnitude of butterfly operations, the cheapness of each modular step, and the share taken by hashing and sampling outside the transform. Parameters (modulus, dimension) precede implementation; they are design choices paid for transform feasibility. When reading performance numbers for lattice schemes, separate these three levels — that way structural dividends are not misread as implementation miracles, and implementation shortcomings are not misjudged as flaws of the algorithm.
References
- FIPS 203, Module-Lattice-Based Key-Encapsulation Mechanism Standard — NTT definition and parameter tables in the appendices
- FIPS 204, Module-Lattice-Based Digital Signature Standard — on the parameter choice q=8380417
- Public pqm4 and SUPERCOP benchmark analyses on the cycle shares of Keccak versus the NTT
Tags: NTTML-KEMML-DSAPerformance Profile