Expand description
Number Theoretic Transform for polynomial arithmetic. Number Theoretic Transform for ML-DSA (FIPS 204, Algorithms 41-45).
Implements the forward and inverse NTT over Z_q[X]/(X^256 + 1) with
q = 8380417 and zeta = 1753 (a primitive 512th root of unity mod q).
The NTT uses 8-bit reversal (BitRev_8) and goes all the way down to
length-1 butterflies, so pointwise multiplication is simple element-wise
multiplication.
Constants§
- ZETAS
- Precomputed zeta table:
ZETAS[k] = zeta^{BitRev_8(k)} mod qfor k in 0..256.
Functions§
- mod_q
- Reduce
amodulo q to the range [0, q-1]. - mul_
mod_ q - Modular multiplication:
(a * b) mod q. - ntt
- Forward NTT (Algorithm 41 of FIPS 204).
- ntt_inv
- pointwise_
mul - Pointwise multiplication of two NTT-domain polynomials.
- poly_
add - Add two polynomials coefficient-wise, reducing each result modulo q.
- poly_
sub - Subtract two polynomials coefficient-wise, reducing each result modulo q.
- to_
mont_ poly - Convert polynomial from /R to normal domain (multiply each coeff by R).