Chapter 4Ring-LWE, Module-LWE, and the Number Theoretic Transform

Roots of Unity in a Finite Field

August 25, 20266 min readbeginner

The classical Fast Fourier Transform evaluates at complex numbers e^2i k / n. There are no complex numbers in Z_q.

The classical Fast Fourier Transform evaluates at complex numbers e2πik/ne^{2\pi i k / n}. There are no complex numbers in Zq\mathbb{Z}_q. This note finds replacements inside the field itself, and discovers a condition on qq that decides whether the whole method is available at all.

01.What we are looking for

An element ω\omega of Zq\mathbb{Z}_q is a primitive mmth root of unity when

ωm=1,andωj≠1 for every 0<j<m.\omega^m = 1, \qquad \text{and} \qquad \omega^j \neq 1 \text{ for every } 0 < j < m .

The first condition says ω\omega returns to 11 after mm steps. The second says it does not do so any earlier. The number mm is called the order of ω\omega.

The second condition matters as much as the first. The element 11 satisfies 1m=11^m = 1 for every mm and is useless, because its powers are all the same value and evaluating at the same point nn times determines nothing.

02.When they exist

Theorem. The non-zero elements of Fq\mathbb{F}_q under multiplication form a cyclic group of order q−1q - 1. It contains an element of order mm if and only if mm divides q−1q - 1.

Cyclic means there is a single element gg, called a generator, whose powers g0,g1,…,gq−2g^0, g^1, \ldots, g^{q-2} run through every non-zero element exactly once. Given a generator, an element of order mm is

ω  =  g(q−1)/m,\omega \;=\; g^{(q-1)/m},

and that exponent is a whole number precisely when mm divides q−1q - 1. That is the whole content of the theorem.

Working it out in F17\mathbb{F}_{17}

Take q=17q = 17, so q−1=16q - 1 = 16. The divisors of 1616 are 1,2,4,8,161, 2, 4, 8, 16, so F17\mathbb{F}_{17} contains primitive roots of unity of exactly those orders and no others. There is no primitive cube root of unity in F17\mathbb{F}_{17}, because 33 does not divide 1616.

A generator is 33. Its powers, which appeared in Chapter 2, are

3,  9,  10,  13,  5,  15,  11,  16,  14,  8,  7,  4,  12,  2,  6,  1,3,\; 9,\; 10,\; 13,\; 5,\; 15,\; 11,\; 16,\; 14,\; 8,\; 7,\; 4,\; 12,\; 2,\; 6,\; 1,

which is all sixteen non-zero residues, confirming it generates.

So a primitive 88th root is 316/8=32=93^{16/8} = 3^2 = 9, and a primitive 44th root is 316/4=34≡133^{16/4} = 3^4 \equiv 13.

But 99 is not the only element of order 88. Check 22:

21=2,22=4,24=16≡−1,28=256≡1(mod17).2^1 = 2, \quad 2^2 = 4, \quad 2^4 = 16 \equiv -1, \quad 2^8 = 256 \equiv 1 \pmod{17}.

The value 28=12^8 = 1 shows the order divides 88, and 24=−1≠12^4 = -1 \neq 1 rules out order 44 or less. So 22 has order exactly 88 as well, and it is the one this chapter uses, because its powers are pleasant to compute with by hand.

04.The negacyclic requirement

Evaluation and Interpolation ended on a mismatch. The natural construction computes modulo Xn−1X^n - 1, and RqR_q needs modulo Xn+1X^n + 1.

The fix is to evaluate not at the nnth roots of unity but at the roots of Xn+1X^n + 1, which are the elements whose nnth power is −1-1 rather than +1+1.

Here is where to find them. Let ζ\zeta be a primitive 2n2nth root of unity. Then ζ2n=1\zeta^{2n} = 1, so (ζn)2=1(\zeta^n)^2 = 1, so ζn\zeta^n is either +1+1 or −1-1. It cannot be +1+1, because that would make the order at most nn rather than 2n2n. Therefore

ζn=−1.\zeta^n = -1 .

Now take the odd powers ζ1,ζ3,ζ5,…,ζ2n−1\zeta^1, \zeta^3, \zeta^5, \ldots, \zeta^{2n-1}. Each raised to the nnth power gives

(ζ2k+1)n  =  (ζn)2k+1  =  (−1)odd  =  −1.(\zeta^{2k+1})^n \;=\; (\zeta^n)^{2k+1} \;=\; (-1)^{\text{odd}} \;=\; -1 .

So all nn of them are roots of Xn+1X^n + 1, and they are distinct because ζ\zeta has order 2n2n.

Those are the evaluation points. Evaluating at the roots of the reduction polynomial is what makes the reduction invisible to the transform, and therefore what makes pointwise multiplication compute the correct negacyclic product.

The requirement is now explicit:

2n   must divide   q−1.2n \;\text{ must divide }\; q - 1 .

Check it for the running example. With n=4n = 4, we need 8∣168 \mid 16, which holds, and ζ=2\zeta = 2 is the primitive 88th root found above. The four evaluation points are

ζ1=2,ζ3=8,ζ5=ζ4ζ=(−1)(2)≡15,ζ7=ζ4ζ3=(−1)(8)≡9.\zeta^1 = 2, \qquad \zeta^3 = 8, \qquad \zeta^5 = \zeta^4 \zeta = (-1)(2) \equiv 15, \qquad \zeta^7 = \zeta^4 \zeta^3 = (-1)(8) \equiv 9 .

Verify each is a root of X4+1X^4 + 1 modulo 1717:

24=16≡−1,84≡−1,154≡(−2)4=16≡−1,94≡(−8)4≡−1.2^4 = 16 \equiv -1, \qquad 8^4 \equiv -1, \qquad 15^4 \equiv (-2)^4 = 16 \equiv -1, \qquad 9^4 \equiv (-8)^4 \equiv -1 .

All four check out. The evaluation grid is (2,8,15,9)(2, 8, 15, 9).

The q=3329q = 3329 quirk

Now apply the same test to the modulus ML-KEM actually uses, and it fails.

For ML-KEM, q=3329q = 3329 and n=256n = 256. Then

q−1  =  3328  =  28⋅13.q - 1 \;=\; 3328 \;=\; 2^8 \cdot 13 .

The requirement is that 2n=512=292n = 512 = 2^9 divides 33283328. It does not, because 33283328 carries only eight factors of two and 512512 needs nine.

So F3329\mathbb{F}_{3329} contains no primitive 512512th root of unity, and the full length-256256 negacyclic transform this chapter is building does not exist for ML-KEM's parameters.

What does exist is a primitive 256256th root, since 256=28256 = 2^8 divides 33283328 exactly. FIPS 203 uses ζ=17\zeta = 17, and it can be checked that 1717 has order exactly 256256 modulo 33293329, with 17128≡3328≡−117^{128} \equiv 3328 \equiv -1.

That is enough to run the transform for seven levels instead of eight. Rather than splitting all the way down to 256256 single values, the recursion stops one level early, leaving 128128 polynomials of degree less than 22. Pointwise multiplication is then not quite pointwise: each of the 128128 pairs is a small product of linear polynomials rather than a single coefficient multiplication.

This is the incomplete NTT, and every ML-KEM implementation in existence carries it. It costs roughly a factor of two against what a complete transform would achieve.

It is reasonable to ask why NIST accepted a modulus that does not quite fit. The answer is that 33293329 is small, small enough that a product of two residues fits in 2424 bits and a coefficient in 1212. That keeps multipliers narrow, keeps memory small, and keeps vectorised software fast. A modulus one bit larger with a friendlier factorisation would have paid for its clean transform everywhere else.

06.ML-DSA has no such problem

For ML-DSA, q=223−213+1=8380417q = 2^{23} - 2^{13} + 1 = 8380417, and

q−1  =  8380416  =  213⋅3⋅11⋅31.q - 1 \;=\; 8380416 \;=\; 2^{13} \cdot 3 \cdot 11 \cdot 31 .

Thirteen factors of two, and only nine are needed. So 512∣q−1512 \mid q - 1 comfortably, a primitive 512512th root exists, FIPS 204 uses ζ=1753\zeta = 1753, and the complete length-256256 negacyclic transform runs exactly as described in this chapter.

The modulus was chosen with the transform in mind, which is what the special form 223−213+12^{23} - 2^{13} + 1 is for. It also makes reduction cheap, as Chapter 7 will show.

With the evaluation points in hand, the next note defines the transform and computes one.

FeedbackBook mode
post-quantum-cryptographycryptographymathematics