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 . That is enough material to sit down and start treating "the integers " as a ring in its own right, with five elements instead of infinitely many. This note does the bookkeeping, names the structure , checks the ring axioms, and finds the criterion that decides when is also a field.
Definition of
For any integer , the ring of integers modulo is the set
together with addition and multiplication defined modulo . So in , the rule means "ordinary integer addition, then reduce modulo ", and the rule means "ordinary integer multiplication, then reduce modulo ".
Some books write for the same object, with the slash explicit. The two notations mean exactly the same thing. We will write throughout because it is shorter and matches what cryptography papers use.
For , the ring is with the tables you saw at the end of the previous note. For , the ring is . For , the smallest non-trivial case, the ring is 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 .
The additive group . Closure holds because the rule "reduce modulo " lands the answer back in by construction. Associativity and commutativity are inherited from ordinary integer addition. The identity is , since for every . The additive inverse of is for , and for , since . So every element has an additive inverse. is an abelian group.
Multiplication. Closure holds for the same reason. Associativity and commutativity are inherited. The identity is , since . 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". is a commutative ring for every .
The interesting question is whether is a field. Recall the extra condition: every non-zero element must have a multiplicative inverse. In , every non-zero residue does have one (read the multiplication table: every row past zero contains a ). In , the residue has no inverse: , , , , none of which is . So is a ring but not a field.
What is special about that fails for ?
The criterion: is a field if and only if is prime
A prime is a positive integer greater than whose only positive divisors are and itself. The primes start . The number is not prime because . The number is prime.
The exact statement is: is a field if and only if is prime.
The intuition is short. An element has a multiplicative inverse precisely when , that is, when shares no common factor with greater than . If is prime, then for every , no such shares a factor with (since the only factors of are and itself, and is strictly less than ). So every non-zero residue is invertible, and is a field.
If is composite, say with , then is a non-zero residue with , so has no inverse. So 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 is prime: use the extended Euclidean algorithm on the pair . Because , the algorithm finds integers and such that
Reducing modulo kills the term, leaving . So is the inverse of in .
A small worked example. Find the inverse of in . The extended Euclidean algorithm on :
, then , then . Reading back: . So and , and . Therefore in .
You can check this against the multiplication table: row , column is . So multiplying by gives the multiplicative identity, exactly as the algorithm predicted.
A second worked example:
The next prime after that we will see in cryptographic worked examples is . The ring has elements: . It is a field because is prime.
A multiplication table is too big to enjoy, but we can spot-check a row. Take and compute for :
Every entry from through appears exactly once, which is the same hallmark we noticed for . So is a unit (an element with a multiplicative inverse) in , and the inverse is read off the table as the value of that gives . Looking at the row, that is , since . So in .
05.Why finite fields, why now
We have just constructed an infinite family of finite fields, one for each prime :
The notation (with prime) is the standard one for "the finite field with elements". The notation for the same object is also standard. We will use throughout for the cryptographic case, since that is what the post-quantum literature uses.
For Kyber, the field is with , a prime. For Dilithium, it is with , 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 " picture to a rigorous structure that is always a ring and is a field exactly when is prime. Every later structure in this chapter will be built using 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.
- Is a field? No: , so has no inverse modulo . The non-zero element in multiplied by anything gives , never .
- Is a field? Yes: is prime. Find in . Try multiples of modulo : . The fifth multiple, , gives .
- Is a field? No: . The element in multiplied by anything gives or , never .
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 are the basic objects of post-quantum schemes, and they form a ring of their own.