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 readJump to the quiz ↓
An irreducible polynomial does for polynomials what a prime does for integers
04-06 ended with failing to be a field: has no multiplicative inverse mod , because
and share a factor. Enlarging the modulus only helps 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: the elements become polynomials,
reduced by an irreducible polynomial that plays the role a prime plays for ordinary integers. Every nonzero
byte then gets an inverse, and that inverse is the entire mathematical content of the AES S-box.
A prime field , also written , is the set with addition and
multiplication taken modulo a prime . 04-06’s is one instance. 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” means it cannot be factored into polynomials of lower degree using coefficients from the base field. is irreducible over the real numbers, but not over the complex numbers, where it factors as . Irreducibility is always relative to a base field.
In GF(2^3), addition cancels matching terms and multiplication reduces by x^3 + x + 1
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 .
Try it — worked example
List the eight elements of GF(2^3) as polynomials and as 3-bit strings.
Show answer and steps
AnswerThe eight elements of GF(2^3)
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.
Try it — worked example
In GF(2^3), compute (x^2 + x) + (x + 1).
Show answer and steps
Answer(x^2 + x) + (x + 1) = x^2 + 1
- .
- in , since coefficients add mod .
- .
Try it — worked example
In GF(2^3) with p(x) = x^3 + x + 1, compute x(x + 1).
Show answer and steps
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.
Try it — worked example
In GF(2^3) with p(x) = x^3 + x + 1, compute x^2(x + 1).
Show answer and steps
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.
GF(2^8) is the field AES runs on, and its byte inverse is the S-box
is 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.
Addition in is bitwise XOR, the same rule as , applied across all eight bit positions independently, with no carrying between them.
Try it — worked example
In GF(2^8), add a = 01010100 and b = 10011010.
Show answer and steps
Answer01010100 XOR 10011010 = 11001110
Let (binary ) and (binary ).
- Line up the bits: , .
- XOR bit by bit: .
- , which is .
Multiplication combines shifting (to multiply by ) with conditional reduction whenever the shift overflows the field’s 8-bit width. AES’s SubBytes and MixColumns steps mostly need it in its simplest form: multiplying a byte by alone.
Try it — worked example
In AES’s GF(2^8), multiply 11000000 by x.
Show answer and steps
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 .
Multiplying by this way is often called . Multiplying by any other byte decomposes into calls and conditional XORs, one pair per bit of the second operand, the same shift-and-add pattern as the examples with eight bit positions instead of three. The calculator below shows every step for any pair of bytes.
AES’s S-box, the nonlinear step in SubBytes, is defined 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 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.