LPsLux Proposals
Q-Chain
LP-4076

lp-4076-ntt-number-theoretic-transform


lp: 4076 title: NTT — Number Theoretic Transform description: The radix-2 Number Theoretic Transform, the arithmetic primitive that turns O(n²) polynomial multiplication into O(n log n) for every lattice scheme in the corpus, plus its EVM precompile author: Lux Core Team (@luxfi) discussions-to: https://github.com/luxfi/lps/discussions status: Final implementation-rust: none implementation-cpp: partial implementation-go: shipped type: Standards Track category: Core tags: [ntt, lattice, post-quantum, arithmetic, polynomial, precompile]

  • lp-4040

Abstract

The Number Theoretic Transform is the arithmetic primitive underneath every post-quantum operation in Lux. It is the FFT with roots of unity taken in Z_q instead of C, and its job is the same one: turn convolution into pointwise multiplication. That converts polynomial multiplication in Z_q[X]/(X^n + 1) from O(n²) to O(n log n).

ML-DSA (FIPS 204, signatures), ML-KEM (FIPS 203, key encapsulation) and NTRU (encryption) all depend on it for their performance-critical arithmetic. When a lattice scheme is fast, this is why.

Specification

Parameters

SchemenqPrimitive root
ML-KEM-768256332917
ML-DSA-6525683804171753

Forward NTT

Take a(X) = Σ a_i X^i from coefficient form to NTT form:

a_hat[i] = sum(a[j] * omega^(j * bit_rev(i))) for j in 0..n-1

where omega is a primitive 2n-th root of unity in Z_q. Implemented as an in-place butterfly network with log₂(n) layers — 8 layers for n = 256.

Inverse NTT

a[i] = n^(-1) * sum(a_hat[j] * omega^(-j * bit_rev(i))) for j in 0..n-1

Polynomial multiplication

c = a * b mod (X^n + 1)
  = INTT(NTT(a) . NTT(b))

where . is pointwise multiplication in the NTT domain. Total cost: two forward transforms, one pointwise multiply, one inverse transform — O(n log n).

GPU acceleration

Nodes with GPU support use CUDA or Metal kernels for batch NTT:

  • Batch size: 1024 transforms per kernel launch
  • Throughput: >1M NTTs/second on RTX 4090
  • Use case: validator signature verification during high-throughput periods

CPU fallback uses AVX2/NEON vectorized butterflies at roughly 50K NTTs/second per core.

Note the shape of that ratio. The GPU win is entirely in the batch — a single transform on the GPU loses to Go (see LP-4044). Batch size is not an optimization detail here; it is the precondition.

Above N = 2^16 the radix-2 path becomes memory-bandwidth-bound on every backend. LP-4078 takes over from there.

EVM precompile

Address 0x0200000000000000000000000000000000000010:

Input:  [4 bytes: n] [4 bytes: q] [n * 8 bytes: coefficients] [1 byte: direction (0=forward, 1=inverse)]
Output: [n * 8 bytes: transformed coefficients]
Gas:    100 + 2 * n

This lets a contract perform lattice arithmetic for on-chain PQ verification.

Security Considerations

  1. Constant-time butterflies. NTT butterflies use constant-time modular arithmetic so the transform leaks nothing through timing.
  2. Parameter validation. The precompile rejects non-power-of-two n and non-prime q. Both would silently produce a transform that is not an NTT.
  3. Overflow. Intermediate products are computed in 64-bit arithmetic, which is sufficient for any valid q < 2^32.

Reference

ResourceLocation
NTT implementationgithub.com/luxfi/node/crypto/ntt/
GPU kernelsgithub.com/luxfi/node/crypto/ntt/gpu/
EVM precompilegithub.com/luxfi/evm/precompile/contracts/ntt/

Copyright (C) 2024-2026, Lux Industries Inc. All rights reserved.

Licensed under the MIT License.