← Back to section · Hardware & Chips
The Acceleration Secret of Lattice Arithmetic: Vectorization and SIMD
The core of lattice cryptography is batch after batch of modular multiplications and number-theoretic transforms—exactly what SIMD instruction sets were built for. How AVX2, AVX-512 and NEON speed up ML-KEM and ML-DSA, and what it costs.
If you ask why lattice cryptography runs surprisingly fast on classical CPUs, a key part of the answer lives in the instruction set. The core computation of ML-KEM and ML-DSA is not tangled control flow; it is tens of thousands of structurally identical integer operations—modular multiplications, additions and reductions between polynomial coefficients. “Same operation, batches of data” is precisely the shape SIMD (single instruction, multiple data) vector instructions were designed for. Understanding how lattice arithmetic fills the vector units is understanding the main battlefield of PQC performance optimization.
The NTT: the heart of lattice schemes and the main vectorization front
Most lattice-based schemes work over polynomial rings, where naive multiplication is quadratic. The Number Theoretic Transform (NTT)—the finite-field analogue of the FFT—brings multiplication down to quasi-linear complexity and is the heart of ML-KEM and ML-DSA implementations. An NTT consists of layers of butterfly operations: within each layer, coefficients are paired up for a multiply-add and an add-subtract, with multipliers drawn from precomputed twiddle factors.
Butterflies are exceptionally SIMD-friendly: within a layer, all butterflies are independent, so 8, 16 or even 32 coefficients can be packed into one vector instruction and processed simultaneously. The difficulty is data rearrangement—pairing relationships change between layers, and vector registers need shuffle operations to realign. Excellent vectorized implementations pre-arrange twiddle factors in access order and minimize shuffles; this is one of the main sources of performance difference between open-source libraries.
More than the NTT: parallel dividends in sampling and hashing
The lattice hot-spot list has two more underestimated entries. First, pseudorandom sampling: ML-KEM and ML-DSA expand seeds into large volumes of seemingly random polynomial coefficients, using Keccak-family functions such as SHAKE underneath. The Keccak permutation itself is regular in width and can be run “multi-way”—four or eight independent hash streams in parallel—filling vector registers exactly. Second, matrix-vector multiplication: coefficients are not independent of each other, but the memory-access pattern is regular, and in the NTT domain it sustains pipeline-style continuous throughput.
Sampling also contains one less obedient operation class: rejection sampling. ML-DSA signing repeatedly generates candidate values and discards out-of-range ones, and whether a value is discarded depends on the data itself—naturally at odds with fixed-length vector pipelines. Implementers smooth out the irregularity with masked compression and generate-then-filter batching, preserving throughput without letting the filtering pattern leak secrets. This is among the most craft-intensive parts of vectorized implementations, and a reminder that an unremarkable “discard and resample” in an algorithm flowchart can be the hardest step to optimize in engineering.
At the instruction-set level, each platform brings its own assets: AVX2 on x86 offers 256-bit vectors and is today’s most widely deployed optimization target; AVX-512 doubles the width and adds conveniences such as masking, but support on recent consumer processors has been inconsistent while servers are relatively stable, so software must do runtime detection and multi-path dispatch. On the ARM side, NEON is the de facto standard across mobile and embedded devices—Apple silicon, cloud ARM servers and Android devices all rely on it—while SVE provides variable-length vectors on some server chips. Cross-platform cryptographic libraries therefore typically maintain several optimized backends plus a portable scalar fallback.
Modulus and data layout: parameters born for vectors
How fast vectorization runs depends half on whether the algorithm’s parameters are “on the way”. Take ML-KEM’s modulus 3329: it is smaller than 2^12, so the product of two coefficients fits comfortably in a 16-bit integer, and a 256-bit vector register can process 16 coefficients per multiplication; the same modulus supports a complete NTT splitting, so implementation efficiency was factored into parameter selection. ML-DSA’s modulus is far larger and needs 32-bit lanes, halving the coefficients per vector width, but the butterfly structure stays regular. At the implementation level, data layout matters too: coefficients must be stored in an order aligned with vector load patterns, the NTT’s bit-reversal permutation done once before the core loop, and twiddle-factor tables pre-expanded in access order. This “typesetting” work produces no cryptographic value, yet it decides what fraction of theoretical peak the core loop achieves.
Memory access is the other invisible threshold. Lattice working sets are small—a polynomial is only a few hundred bytes and fits entirely in L1 cache; the real cost is frequent small-block movement and rearrangement. Excellent implementations therefore focus less on the arithmetic instructions themselves and more on reducing shuffles, coalescing accesses and keeping data in registers as long as possible. This explains why two vectorized implementations of the same algorithm can differ by a substantial factor: the gap is not in knowing the instructions, but in dataflow choreography.
Vectorization and side channels: two sides of one coin
Vectorization is not free acceleration; it has a real tension with security. Cryptography has an iron rule: execution time and memory-access patterns must not depend on secret data, or attackers can measure keys out through timing and cache side channels. SIMD raises the difficulty of obeying that rule: vectorized table lookups, secret-dependent shuffle selection and early-exit optimizations can all leak. Production vectorization is therefore “constant-time vectorization”—masks and arithmetic selection instead of branches, fixed access patterns instead of data-dependent addressing—and performance work must pass the security review gate first.
The other cost is engineering complexity. Each instruction-set backend is a separately audited, separately tested body of hand-optimized code; the more backends, the larger the maintenance and error surface. That is why serious cryptographic libraries keep formally verified or widely reviewed reference paths alongside, and guard every backend’s correctness and performance with continuous benchmarking. The practical takeaway for deployers: when choosing PQC software, “which instruction-set optimizations are supported, and is the implementation constant-time” matters as much as “which algorithms are supported”—on the same CPU, swapping implementations can change performance several-fold, and the security level just as much.
Tags: Lattice cryptographySIMDNTT