Chapter 1Finite Fields and Polynomial Rings

The Ring $\mathbb{Z}_n$

August 25, 20268 min readbeginner

In the previous note we wrote out the addition and multiplication tables for arithmetic modulo 5.

In the previous note we wrote out the addition and multiplication tables for arithmetic modulo 55. That is enough material to sit down and start treating "the integers  mod 5\bmod 5" as a ring in its own right, with five elements instead of infinitely many. This note does the bookkeeping, names the structure Zn\mathbb{Z}_n, checks the ring axioms, and finds the criterion that decides when Zn\mathbb{Z}_n is also a field.

Definition of Zn\mathbb{Z}_n

For any integer n≥2n \ge 2, the ring of integers modulo nn is the set

Zn  =  {0, 1, 2, …, n−1}\mathbb{Z}_n \;=\; \{0,\, 1,\, 2,\, \ldots,\, n-1\}

together with addition and multiplication defined modulo nn. So in Zn\mathbb{Z}_n, the rule a+ba + b means "ordinary integer addition, then reduce modulo nn", and the rule a⋅ba \cdot b means "ordinary integer multiplication, then reduce modulo nn".

Some books write Z/nZ\mathbb{Z}/n\mathbb{Z} for the same object, with the slash explicit. The two notations mean exactly the same thing. We will write Zn\mathbb{Z}_n throughout because it is shorter and matches what cryptography papers use.

For n=5n = 5, the ring is Z5={0,1,2,3,4}\mathbb{Z}_5 = \{0, 1, 2, 3, 4\} with the tables you saw at the end of the previous note. For n=4n = 4, the ring is Z4={0,1,2,3}\mathbb{Z}_4 = \{0, 1, 2, 3\}. For n=2n = 2, the smallest non-trivial case, the ring is Z2={0,1}\mathbb{Z}_2 = \{0, 1\} and is exactly the "keep only the last bit" arithmetic from the closure note.

02.Checking the ring axioms

The ring axioms from Groups, Rings, and Fields need to be verified for Zn\mathbb{Z}_n.

The additive group (Zn,+)(\mathbb{Z}_n, +). Closure holds because the rule "reduce modulo nn" lands the answer back in {0,…,n−1}\{0, \ldots, n-1\} by construction. Associativity and commutativity are inherited from ordinary integer addition. The identity is 00, since a+0=aa + 0 = a for every aa. The additive inverse of aa is n−an - a for a≠0a \neq 0, and 00 for a=0a = 0, since a+(n−a)=n≡0(modn)a + (n - a) = n \equiv 0 \pmod n. So every element has an additive inverse. (Zn,+)(\mathbb{Z}_n, +) is an abelian group.

Multiplication. Closure holds for the same reason. Associativity and commutativity are inherited. The identity is 11, since a⋅1=aa \cdot 1 = a. So multiplication is an associative, commutative operation with an identity.

Distributivity. Inherited from integer arithmetic and preserved by reduction.

That is all four parts of "commutative ring". Zn\mathbb{Z}_n is a commutative ring for every n≥2n \ge 2.

The interesting question is whether Zn\mathbb{Z}_n is a field. Recall the extra condition: every non-zero element must have a multiplicative inverse. In Z5\mathbb{Z}_5, every non-zero residue does have one (read the multiplication table: every row past zero contains a 11). In Z4\mathbb{Z}_4, the residue 22 has no inverse: 2⋅0=02 \cdot 0 = 0, 2⋅1=22 \cdot 1 = 2, 2⋅2=02 \cdot 2 = 0, 2⋅3=22 \cdot 3 = 2, none of which is 11. So Z4\mathbb{Z}_4 is a ring but not a field.

What is special about 55 that fails for 44?

The criterion: Zn\mathbb{Z}_n is a field if and only if nn is prime

A prime is a positive integer greater than 11 whose only positive divisors are 11 and itself. The primes start 2,3,5,7,11,13,…2, 3, 5, 7, 11, 13, \ldots. The number 44 is not prime because 4=2⋅24 = 2 \cdot 2. The number 55 is prime.

The exact statement is: Zn\mathbb{Z}_n is a field if and only if nn is prime.

The intuition is short. An element a∈Zna \in \mathbb{Z}_n has a multiplicative inverse precisely when gcd⁡(a,n)=1\gcd(a, n) = 1, that is, when aa shares no common factor with nn greater than 11. If nn is prime, then for every a∈{1,2,…,n−1}a \in \{1, 2, \ldots, n-1\}, no such aa shares a factor with nn (since the only factors of nn are 11 and nn itself, and aa is strictly less than nn). So every non-zero residue is invertible, and Zn\mathbb{Z}_n is a field.

If nn is composite, say n=abn = ab with 1<a,b<n1 < a, b < n, then aa is a non-zero residue with gcd⁡(a,n)=a>1\gcd(a, n) = a > 1, so aa has no inverse. So Zn\mathbb{Z}_n is missing inverses for at least one element, which disqualifies it from being a field.

The "if and only if" part also gives a clean way to compute inverses when nn is prime: use the extended Euclidean algorithm on the pair (a,n)(a, n). Because gcd⁡(a,n)=1\gcd(a, n) = 1, the algorithm finds integers uu and vv such that

u⋅a+v⋅n  =  1.u \cdot a + v \cdot n \;=\; 1.

Reducing modulo nn kills the v⋅nv \cdot n term, leaving u⋅a≡1(modn)u \cdot a \equiv 1 \pmod n. So u mod nu \bmod n is the inverse of aa in Zn\mathbb{Z}_n.

A small worked example. Find the inverse of 33 in Z5\mathbb{Z}_5. The extended Euclidean algorithm on (3,5)(3, 5):

5=1⋅3+25 = 1 \cdot 3 + 2, then 3=1⋅2+13 = 1 \cdot 2 + 1, then 2=2⋅1+02 = 2 \cdot 1 + 0. Reading back: 1=3−1⋅2=3−1⋅(5−1⋅3)=2⋅3−1⋅51 = 3 - 1 \cdot 2 = 3 - 1 \cdot (5 - 1 \cdot 3) = 2 \cdot 3 - 1 \cdot 5. So u=2u = 2 and v=−1v = -1, and 2⋅3≡1(mod5)2 \cdot 3 \equiv 1 \pmod 5. Therefore 3−1=23^{-1} = 2 in Z5\mathbb{Z}_5.

You can check this against the multiplication table: row 33, column 22 is 11. So multiplying 33 by 22 gives the multiplicative identity, exactly as the algorithm predicted.

A second worked example: Z17\mathbb{Z}_{17}

The next prime after 55 that we will see in cryptographic worked examples is 1717. The ring Z17\mathbb{Z}_{17} has 1717 elements: {0,1,2,…,16}\{0, 1, 2, \ldots, 16\}. It is a field because 1717 is prime.

A 17×1717 \times 17 multiplication table is too big to enjoy, but we can spot-check a row. Take a=5a = 5 and compute 5⋅k mod 175 \cdot k \bmod 17 for k=0,1,…,16k = 0, 1, \ldots, 16:

kk001122334455667788991010111112121313141415151616
5k mod 175k \bmod 17005510101515338813131166111116164499141422771212

Every entry from 00 through 1616 appears exactly once, which is the same hallmark we noticed for Z5\mathbb{Z}_5. So 55 is a unit (an element with a multiplicative inverse) in Z17\mathbb{Z}_{17}, and the inverse is read off the table as the value of kk that gives 5k≡1(mod17)5k \equiv 1 \pmod{17}. Looking at the row, that is k=7k = 7, since 5⋅7=35=2⋅17+15 \cdot 7 = 35 = 2 \cdot 17 + 1. So 5−1=75^{-1} = 7 in Z17\mathbb{Z}_{17}.

05.Why finite fields, why now

We have just constructed an infinite family of finite fields, one for each prime nn:

F2,  F3,  F5,  F7,  F11,  F13,  F17,  …\mathbb{F}_2,\; \mathbb{F}_3,\; \mathbb{F}_5,\; \mathbb{F}_7,\; \mathbb{F}_{11},\; \mathbb{F}_{13},\; \mathbb{F}_{17},\; \ldots

The notation Fp\mathbb{F}_p (with pp prime) is the standard one for "the finite field with pp elements". The notation Zp\mathbb{Z}_p for the same object is also standard. We will use Zq\mathbb{Z}_q throughout for the cryptographic case, since that is what the post-quantum literature uses.

For Kyber, the field is Zq\mathbb{Z}_q with q=3329q = 3329, a prime. For Dilithium, it is Zq\mathbb{Z}_q with q=8 380 417q = 8\,380\,417, also prime. The schemes work because these moduli are primes: arithmetic is invertible everywhere except at zero, and the polynomial machinery built in the next notes goes through cleanly.

For now, the takeaway is that we have moved from a casual "wrap around at nn" picture to a rigorous structure Zn\mathbb{Z}_n that is always a ring and is a field exactly when nn is prime. Every later structure in this chapter will be built using Zn\mathbb{Z}_n as a starting ingredient.

06.A short exercise

In each case, decide whether the ring is a field, and if so, compute the requested inverse.

  1. Is Z6\mathbb{Z}_6 a field? No: 6=2⋅36 = 2 \cdot 3, so 22 has no inverse modulo 66. The non-zero element 22 in Z6\mathbb{Z}_6 multiplied by anything gives 0,2,4,0,2,40, 2, 4, 0, 2, 4, never 11.
  2. Is Z7\mathbb{Z}_7 a field? Yes: 77 is prime. Find 3−13^{-1} in Z7\mathbb{Z}_7. Try multiples of 33 modulo 77: 3,6,2,5,13, 6, 2, 5, 1. The fifth multiple, 3⋅5=15≡13 \cdot 5 = 15 \equiv 1, gives 3−1=53^{-1} = 5.
  3. Is Z10\mathbb{Z}_{10} a field? No: 10=2⋅510 = 2 \cdot 5. The element 55 in Z10\mathbb{Z}_{10} multiplied by anything gives 00 or 55, never 11.

These cases show the criterion in action and how a single "missing inverse" is enough to disqualify a ring from being a field.

The next note moves from numbers to polynomials. Polynomials whose coefficients live in Zq\mathbb{Z}_q are the basic objects of post-quantum schemes, and they form a ring of their own.

FeedbackBook mode
post-quantum-cryptographycryptographymathematics