Chapter 1Finite Fields and Polynomial Rings

The Target Ring $R_q$

August 25, 20269 min readbeginner

We have arrived at the construction the chapter has been pointing at. This note assembles all the pieces into a single object, computes a fully worked product inside it, lists the…

We have arrived at the construction the chapter has been pointing at. This note assembles all the pieces into a single object, computes a fully worked product inside it, lists the few properties that will matter downstream, and writes down the specific values of nn and qq that Kyber and Dilithium use.

01.Definition

For a positive integer nn and a positive integer q≥2q \ge 2, the ring RqR_q is

Rq  =  Zq[X] / (Xn+1).R_q \;=\; \mathbb{Z}_q[X] \,/\, (X^n + 1).

Read this from left to right. Start with the integers modulo qq, namely Zq={0,1,…,q−1}\mathbb{Z}_q = \{0, 1, \ldots, q-1\}. Form polynomials with coefficients in Zq\mathbb{Z}_q, namely Zq[X]\mathbb{Z}_q[X]. Quotient by the ideal generated by Xn+1X^n + 1, which means replacing every XnX^n by −1-1 during arithmetic.

Every element of RqR_q is represented uniquely by a polynomial of degree strictly less than nn:

a(X)  =  a0+a1X+a2X2+⋯+an−1Xn−1,a(X) \;=\; a_0 + a_1 X + a_2 X^2 + \cdots + a_{n-1} X^{n-1},

where each coefficient aia_i lives in Zq\mathbb{Z}_q. So an element of RqR_q is a list of nn coefficients, each one a residue in {0,1,…,q−1}\{0, 1, \ldots, q-1\}. The ring RqR_q has exactly qnq^n elements.

Two elements are added by adding their coefficient lists slot by slot, with sums reduced modulo qq. Two elements are multiplied by doing schoolbook polynomial multiplication and then reducing the result modulo Xn+1X^n + 1 using the rule Xn≡−1X^n \equiv -1.

A small worked product in R17R_{17} with n=4n = 4

Let n=4n = 4 and q=17q = 17. Elements of R17R_{17} are polynomials of degree at most 33 with coefficients in {0,1,…,16}\{0, 1, \ldots, 16\}. The reduction rule is X4≡−1≡16(mod17)X^4 \equiv -1 \equiv 16 \pmod{17}.

Take

a(X)  =  3+X+4X2+2X3,b(X)  =  1+X.a(X) \;=\; 3 + X + 4 X^2 + 2 X^3, \qquad b(X) \;=\; 1 + X.

Step 1. Schoolbook multiplication, ignoring the reduction by Xn+1X^n + 1 for now.

a(X)⋅b(X)  =  (3+X+4X2+2X3)(1+X).a(X) \cdot b(X) \;=\; (3 + X + 4X^2 + 2X^3)(1 + X).

Expand each term:

  • 3⋅1=33 \cdot 1 = 3
  • 3⋅X=3X3 \cdot X = 3X
  • X⋅1=XX \cdot 1 = X
  • X⋅X=X2X \cdot X = X^2
  • 4X2⋅1=4X24X^2 \cdot 1 = 4X^2
  • 4X2⋅X=4X34X^2 \cdot X = 4X^3
  • 2X3⋅1=2X32X^3 \cdot 1 = 2X^3
  • 2X3⋅X=2X42X^3 \cdot X = 2X^4

Group by power of XX:

  • X4X^4: 22
  • X3X^3: 4+2=64 + 2 = 6
  • X2X^2: 1+4=51 + 4 = 5
  • X1X^1: 3+1=43 + 1 = 4
  • X0X^0: 33

So before reduction, a(X)⋅b(X)=2X4+6X3+5X2+4X+3a(X) \cdot b(X) = 2X^4 + 6X^3 + 5X^2 + 4X + 3.

Step 2. Reduce modulo X4+1X^4 + 1, that is, replace every X4X^4 by −1-1.

2X4=2⋅X4≡2⋅(−1)=−22X^4 = 2 \cdot X^4 \equiv 2 \cdot (-1) = -2. The rest of the polynomial has degree at most 33, so it is left alone.

a(X)⋅b(X)  ≡  −2+6X3+5X2+4X+3  =  6X3+5X2+4X+1(modX4+1).a(X) \cdot b(X) \;\equiv\; -2 + 6X^3 + 5X^2 + 4X + 3 \;=\; 6X^3 + 5X^2 + 4X + 1 \pmod{X^4 + 1}.

Step 3. Reduce coefficients modulo 1717. None of 6,5,4,16, 5, 4, 1 exceed 1616, so the answer is already in canonical form:

a(X)⋅b(X)  =  6X3+5X2+4X+1in R17.a(X) \cdot b(X) \;=\; 6X^3 + 5X^2 + 4X + 1 \quad \text{in } R_{17}.

That is one full multiplication in RqR_q done by hand. Both reductions (by Xn+1X^n + 1 and by qq) happen at the end, and you could equally well reduce intermediate values as you go, since reduction commutes with arithmetic. In hardware, reducing as you go keeps the data path narrow.

03.A second worked product, illustrating the negacyclic flip

Stay with n=4n = 4, q=17q = 17. Take

a(X)  =  X3,b(X)  =  X2.a(X) \;=\; X^3, \qquad b(X) \;=\; X^2.

Schoolbook product: a(X)⋅b(X)=X5a(X) \cdot b(X) = X^5.

Reduce modulo X4+1X^4 + 1: X5=X⋅X4≡X⋅(−1)=−XX^5 = X \cdot X^4 \equiv X \cdot (-1) = -X. In Z17\mathbb{Z}_{17}, the coefficient −1-1 becomes 1616. So the answer is 16X16 X, or equivalently −X-X if you prefer the centred representation {−8,…,8}\{-8, \ldots, 8\} instead of {0,…,16}\{0, \ldots, 16\}.

The minus sign is the negacyclic part of the negacyclic ring. If we had quotiented by X4−1X^4 - 1 instead of X4+1X^4 + 1, the rule would be X4≡+1X^4 \equiv +1, and there would be no sign flip (that is the cyclic case). The choice of Xn+1X^n + 1 over Xn−1X^n - 1 is what makes this ring negacyclic, and it has consequences for the cryptanalysis. The schemes in this book all use Xn+1X^n + 1.

Properties of RqR_q in the cryptographic sizes

A few properties of RqR_q are worth stating, since they are what makes the cryptography possible.

RqR_q is a commutative ring with identity. It inherits its ring structure from Zq[X]\mathbb{Z}_q[X] via the quotient construction. The additive identity is the zero polynomial, and the multiplicative identity is the constant polynomial 11.

RqR_q is finite. It has qnq^n elements. For Kyber's parameters (n=256n = 256, q=3329q = 3329), this is roughly 3329256≈229803329^{256} \approx 2^{2980} elements. Each element fits in n⋅⌈log⁡2q⌉n \cdot \lceil \log_2 q \rceil bits, which for Kyber is 256⋅12=3072256 \cdot 12 = 3072 bits = 384384 bytes. A single RqR_q element is the natural unit of bandwidth in this cryptography.

RqR_q is not always a field. Even when qq is prime, the polynomial Xn+1X^n + 1 can be reducible (factor non-trivially) over Zq\mathbb{Z}_q, in which case RqR_q is a proper ring, not a field. Whether this is a feature or a bug depends on the use. For Kyber and Dilithium, Xn+1X^n + 1 over Zq\mathbb{Z}_q factors fully into linear factors thanks to a careful choice of qq, and the factorisation is exactly what makes the Number Theoretic Transform fast.

Multiplication in RqR_q has structure that hardware can exploit. A naive schoolbook multiplication of two degree-(n−1)(n-1) polynomials takes Θ(n2)\Theta(n^2) coefficient multiplications. The Number Theoretic Transform reduces this to Θ(nlog⁡n)\Theta(n \log n), which for n=256n = 256 is the difference between roughly 65,00065{,}000 and roughly 3,3003{,}300 coefficient multiplications per product. The NTT is the subject of Chapter 4 and is the central data path of the hardware.

05.NIST parameter sets

The post-quantum standards fix specific values of nn and qq.

SchemennqqCoefficient bitsElement size
ML-KEM (FIPS 203, formerly Kyber)256256332933291212384384 bytes
ML-DSA (FIPS 204, formerly Dilithium)2562568 380 4178\,380\,4172323736736 bytes

Both schemes use n=256n = 256. That is a deliberate design choice: a single hardware NTT of length 256256 is enough to serve both schemes, and is the basis of every "unified accelerator" paper in the post-quantum literature. The two values of qq differ. Kyber's q=3329q = 3329 is small enough that a coefficient fits in 1212 bits, which is friendly to small-FPGA deployment. Dilithium's q=8 380 417q = 8\,380\,417 is larger, requiring 2323 bits per coefficient, but it is still less than a 3232-bit word.

Both moduli are prime, and both satisfy

q  ≡  1(modn),n=256,q \;\equiv\; 1 \pmod{n}, \qquad n = 256,

since 3329=13⋅256+13329 = 13 \cdot 256 + 1 and 8 380 417=32,736⋅256+18\,380\,417 = 32{,}736 \cdot 256 + 1.

Only one of them satisfies the stronger congruence modulo 2n=5122n = 512, and the difference matters more than anything else on this page. Working it out:

8 380 417  ≡  1(mod512),but3329  ≡  257(mod512).8\,380\,417 \;\equiv\; 1 \pmod{512}, \qquad \text{but} \qquad 3329 \;\equiv\; 257 \pmod{512}.

The condition q≡1(mod2n)q \equiv 1 \pmod{2n} is exactly what a primitive 2n2n-th root of unity needs in order to exist in Zq\mathbb{Z}_q, and that root is what the fast transform runs on. So ML-DSA gets the complete transform and ML-KEM does not.

That is not a defect in ML-KEM. It is a deliberate trade, and the NTT chapter explains both the workaround and why a modulus small enough to fit a coefficient in twelve bits was judged worth it.

06.Why this ring, not some other

Three properties make Rq=Zq[X]/(Xn+1)R_q = \mathbb{Z}_q[X] / (X^n + 1) the right home for module-lattice cryptography.

The first is compactness. Each RqR_q element packs nn coefficients into a single algebraic object. A vector of kk such elements (the secret key in Kyber is such a vector) shrinks key sizes by a factor of nn compared to a flat vector of knkn scalars. That compactness is what makes lattice cryptography practical at all. RSA keys are around 2,0002{,}000 to 4,0004{,}000 bits. Kyber keys are around 10,00010{,}000 to 25,00025{,}000 bits. Larger, but not impossibly larger, and that is the difference between deployable and not.

The second is fast multiplication. The NTT exploits the structure of Xn+1X^n + 1 to multiply two RqR_q elements in Θ(nlog⁡n)\Theta(n \log n) time instead of Θ(n2)\Theta(n^2). Without this speedup, the cryptography would be slow enough to be unusable. The NTT lives inside this ring. It does not work for arbitrary polynomial moduli.

The third is security reduction. Deciding whether a given pair (a,b)∈Rq×Rq(a, b) \in R_q \times R_q has the form (a,a⋅s+e)(a, a \cdot s + e) for some short secret ss and small noise ee is conjectured to be as hard as the worst-case Shortest Vector Problem on lattices. This is the Ring-LWE problem, and it is the assumption on which Kyber's security rests. The structure of RqR_q gives the proof. Switching to a different ring would invalidate the security argument.

These three properties are what the chapter has been building towards. Now that the ring is in hand, the cryptography itself, and the question of why lattices, can be tackled. That is the subject of the remaining chapters.

07.Chapter summary, in three lines

A ring is a set with two compatible operations. The integers modulo a prime form a finite field. Polynomials with coefficients in that field, quotiented by Xn+1X^n + 1, form the ring RqR_q where Kyber and Dilithium do their work.

If the symbol Rq=Zq[X]/(Xn+1)R_q = \mathbb{Z}_q[X] / (X^n + 1) at the top of this chapter feels different now from how it looked at the start, the chapter has done its job. Chapter 2 explains why lattice-based cryptography exists in the first place: what the public-key cryptography of the last fifty years looked like, what Shor's algorithm broke, and how the NIST competition arrived at module-lattice schemes as the replacement.

FeedbackBook mode
post-quantum-cryptographycryptographymathematics