Finite fields, GF(p) and GF(2^n)
Prime fields and extension fields, the complete GF(2^3) table built on x^3+x+1, GF(2^8) addition and multiplication with AES's irreducible polynomial, and why the AES S-box is a multiplicative inverse in that field.
- Define a prime field GF(p) and an extension field GF(p^n), and explain what an irreducible polynomial is for.
- Build the complete eight-element table of GF(2^3) under x^3 + x + 1, in binary and polynomial form.
- Add and multiply elements of GF(2^3), including a reduction step when a product overflows the field.
- Add two GF(2^8) bytes by XOR and multiply by x with the AES reduction polynomial, showing every step.
- Explain why the AES S-box is built from a multiplicative inverse in GF(2^8).
22 min read
Intuition
04-06 ended with failing to be a field: has no multiplicative inverse mod , because
and share a factor. Enlarging the modulus does not fix this in general: it only works when the modulus is
prime. AES needs a field with exactly elements, one for every possible byte, and is about as
far from prime as a number gets. Finite fields solve this by changing what “multiply and reduce” means:
instead of integers reduced by a composite modulus, the elements become polynomials, reduced by an
irreducible polynomial that plays the same role a prime plays for ordinary integers. That one substitution
is what turns bytes into a genuine field, and every nonzero byte gets an inverse. That inverse is the
entire mathematical content of the AES S-box.
Mechanism
A prime field , also written , is the set with addition and
multiplication taken modulo a prime . 04-06’s is one instance of this. has
characteristic : the smallest number of copies of any element that sum to .
An extension field , for , has elements. It is built by adjoining to the roots of a degree- polynomial that cannot be reduced further, an irreducible polynomial over . “Irreducible” here means the same thing it means for ordinary polynomials: it cannot be factored into polynomials of lower degree using coefficients from the base field. is irreducible over the real numbers (no real polynomials of lower degree multiply to give it), but not over the complex numbers, where it factors as . Irreducibility is always relative to a base field.
Mechanism
Building : start from , where addition and multiplication are mod . Choose an irreducible polynomial of degree over : the lecture uses , which has no root in and cannot be factored over . The field then has elements: every polynomial of degree less than with coefficients in .
Worked example
AnswerThe eight elements of GF(2^3)
Mechanism
Addition and multiplication both work modulo on the coefficients, and multiplication additionally reduces modulo whenever a product’s degree reaches or higher. Since coefficients are mod , addition is the same operation as subtraction: , so “adding” two polynomials just cancels any term that appears in both.
Worked example
Answer(x^2 + x) + (x + 1) = x^2 + 1
- .
- in , since coefficients add mod .
- .
Worked example
Answerx(x+1) = x^2 + x
- .
- Degree is below the field’s degree bound of , so no reduction is needed. The product is already one of the eight elements.
Worked example
Answerx^2(x+1) reduces to x^2 + x + 1
- .
- Degree overflows the field, so reduce modulo . Since , , and in , subtraction is the same as addition, so .
- Substitute: .
- in .
Pitfall
“Subtracting” a polynomial modulo is not a separate operation to learn: it is addition, because every coefficient is its own additive inverse in (, so ). Reduction by an irreducible polynomial is always carried out by XOR-ing bit patterns, never by a signed subtraction.
Mechanism
is the field AES runs on, chosen for two reasons the lecture gives directly: it balances security against efficiency (large enough for real cryptographic strength, small enough to implement efficiently in hardware and software), and its elements map naturally onto a byte, since digital systems already work in binary. Every element is a polynomial of degree less than with coefficients in : The irreducible polynomial AES reduces by is written in binary as , or .
Formula
AES irreducible polynomial
- the modulus every GF(2^8) multiplication in AES reduces by
Binary 100011011, hex 0x11B.
Mechanism
Addition in is bitwise XOR, the same rule as , applied across all eight bit positions independently, with no carrying between them.
Worked example
Answer01010100 XOR 10011010 = 11001110
Let (binary ) and (binary ).
- Line up the bits: , .
- XOR bit by bit: .
- , which is .
Mechanism
Multiplication combines shifting (to multiply by ) with conditional reduction whenever the shift overflows the field’s 8-bit width. AES’s own SubBytes and MixColumns steps mostly need this in its simplest form: multiplying a byte by alone.
Worked example
Answer11000000 x x reduces to 10011011
Let , binary .
- Multiplying by shifts every bit left by one place: , a 9-bit result, since ‘s top bit was set and the shift pushed a new bit past position . This is the polynomial .
- Degree overflows the field, so reduce modulo , written as the 9-bit pattern .
- XOR the two 9-bit values: .
- Dropping the leading zero, the result fits in 8 bits: , the polynomial .
Aside
Multiplying by this way is often called , and every other multiplication in can be built from it: multiplying by any byte decomposes into a sequence of calls and conditional XORs, one pair per bit of the second operand, the same shift-and-add pattern as the examples above, just with eight bit positions instead of three. The calculator below shows every step of that pattern for any pair of bytes, not only multiplication by .
Mechanism
AES’s S-box, the nonlinear step in SubBytes, is defined mathematically as: take a byte’s multiplicative inverse in (the byte , which has no inverse, maps to itself), then apply a fixed affine transformation on top. The inverse step is the one that matters algebraically: the affine transformation is linear and adds no cryptographic strength on its own, it exists to remove certain algebraic simplicities the raw inverse function would otherwise have.
Exam detail
The inverse step only works because is a genuine field: every one of the nonzero bytes
has exactly one multiplicative inverse, guaranteed by the same field axiom 04-06 builds up to. That
guarantee is what makes SubBytes invertible, which is what makes AES decryption possible at all: a
substitution built on a function without guaranteed inverses could not be undone. See
AES for the S-box in the context of the full cipher, including SubBytes,
ShiftRows, MixColumns and AddRoundKey together.
Recall
Why does GF(2^8) need an irreducible polynomial at all, when GF(256) as plain integers mod 256 would also have 256 elements?
is not prime, so integers mod would only ever be a commutative ring, the same way
is on 04-06, and most elements would have no multiplicative inverse. Representing elements as
degree- polynomials over , and reducing products by an irreducible polynomial instead of a
composite integer, is what actually delivers a field with elements. The irreducible polynomial does for
polynomial arithmetic exactly what a prime modulus does for integer arithmetic.