Caloogy Article
中文

The Finite Field Inside AES: The S-box Is Really an Inverse in F28\mathbb{F}_{2^8}

Date
Oct 29, 2025
Series
Cryptography
Reading
4 min
Topics
AESFinite fieldGF(256)S-box

The one-sentence version

AES treats each byte as an element of the finite field F28=F2[x]/(x8+x4+x3+x+1)\mathbb{F}_{2^8} = \mathbb{F}_2[x]/(x^8+x^4+x^3+x+1). Its S-box is "take the multiplicative inverse, then apply an affine transformation"; MixColumns is a polynomial multiplication. Designing with algebraic structure rather than an arbitrarily drawn table gives AES provable resistance to known attacks.

This article has three layers:

  1. The intuition: confusion and diffusion, and what each AES round does
  2. Real-world use: AES is everywhere, and why it isn't afraid of quantum computers
  3. The mathematics: constructing F28\mathbb{F}_{2^8}, the S-box, MixColumns and worked examples from the FIPS 197 standard

Layer 1: The Intuition

1.1 Symmetric encryption has two jobs

Shannon proposed in 1949 that a good block cipher must achieve both:

AES is a machine that does these two things over and over for 10 to 14 rounds.

1.2 One round of AES

AES arranges 16 bytes of data into a 4×44 \times 4 square, and each round has four steps:

Step What it does Purpose
SubBytes Replaces each byte using the S-box Confusion: the only nonlinear step
ShiftRows Rotates row ii left by ii positions Diffusion: spreads bytes across columns
MixColumns Multiplies each column by a fixed matrix Diffusion: every byte in a column affects the whole column
AddRoundKey XORs with this round's subkey Brings in the key

After two rounds, any single input byte already affects all 16 output bytes.

1.3 Why use a finite field

A byte has 256 possible values. We want to "multiply" and "divide" bytes and still get a byte. Ordinary integer multiplication overflows, and modulo 256 isn't a field (2×128≡02 \times 128 \equiv 0 means zero divisors, so division fails).

The solution is to treat a byte as a polynomial with coefficients 0 or 1, and compute modulo an irreducible polynomial. Then the 256 bytes form exactly a field: you can add, subtract, multiply and divide, and every nonzero element has an inverse.


Layer 2: Real-World Use

AES is the standard chosen by the US NIST through an open competition in 2001 (originally called Rijndael, designed by two Belgian cryptographers). Today it is nearly everywhere:

Hardware acceleration: Intel and AMD's AES-NI instructions and ARM's cryptography extensions implement an AES round directly on the chip, reaching several GB per second.

Quantum computers: AES has no algebraic trapdoor like RSA's, so Shor's algorithm doesn't apply; Grover's algorithm only reduces brute force from 21282^{128} to about 2642^{64}. So AES-256 is enough to cope. See "Post-Quantum Cryptography" for details.

The real risk is in the implementation

AES itself has had no practical attacks in over twenty years. The incidents all come from how it is used: ECB mode (identical plaintext blocks give identical ciphertext blocks, the famous "penguin still clearly visible after encryption"), nonce reuse in GCM mode, and cache-timing side channels from table-based implementations.


Layer 3: The Mathematics

3.1 Constructing F28\mathbb{F}_{2^8}

Take F2={0,1}\mathbb{F}_2 = \{0, 1\} (where addition is XOR). The polynomial

m(x)=x8+x4+x3+x+1m(x) = x^8 + x^4 + x^3 + x + 1

is irreducible over F2\mathbb{F}_2, so (m(x))(m(x)) is a maximal ideal of F2[x]\mathbb{F}_2[x], and the quotient ring

F28=F2[x]/(m(x))\mathbb{F}_{2^8} = \mathbb{F}_2[x] / (m(x))

is a field with 28=2562^8 = 256 elements (abstract algebra: F[x]/(f)F[x]/(f) is a field if and only if ff is irreducible).

A byte b7b6⋯b0b_7 b_6 \cdots b_0 corresponds to the polynomial b7x7+⋯+b1x+b0b_7 x^7 + \cdots + b_1 x + b_0. For example 0x57 =010101112= 01010111_2 corresponds to x6+x4+x2+x+1x^6 + x^4 + x^2 + x + 1.

3.2 A worked example: multiplication

{57} · {83} = {C1} (the example from FIPS 197)

{57} =x6+x4+x2+x+1= x^6 + x^4 + x^2 + x + 1 and {83} =x7+x+1= x^7 + x + 1.

First, ordinary polynomial multiplication (coefficients modulo 2): (x6+x4+x2+x+1)(x7+x+1)=x13+x11+x9+x8+x6+x5+x4+x3+1.(x^6 + x^4 + x^2 + x + 1)(x^7 + x + 1) = x^{13} + x^{11} + x^9 + x^8 + x^6 + x^5 + x^4 + x^3 + 1.

Then reduce modulo m(x)m(x): repeatedly lower the degree using x8≡x4+x3+x+1x^8 \equiv x^4 + x^3 + x + 1, finally getting x7+x6+1=110000012=C1.x^7 + x^6 + 1 = 11000001_2 = \texttt{C1}.

(Checked with Python.)

3.3 The S-box = inverse + affine transformation

For each byte aa:

  1. Invert: b=a−1b = a^{-1} in F28\mathbb{F}_{2^8} (by convention 0−1=00^{-1} = 0);
  2. Affine transformation: treat bb as a vector in F28\mathbb{F}_2^8 and compute s=Mb⊕63s = Mb \oplus \texttt{63}, where MM is a fixed 8×88 \times 8 circulant matrix: si=bi⊕bi+4⊕bi+5⊕bi+6⊕bi+7⊕ci(indices modulo 8, c=63).s_i = b_i \oplus b_{i+4} \oplus b_{i+5} \oplus b_{i+6} \oplus b_{i+7} \oplus c_i \quad (\text{indices modulo } 8,\ c = \texttt{63}).

S(53) = ED (the example from FIPS 197)

  • Inverse: the inverse of {53} is {CA}; you can verify that {53}·{CA} = {01}
  • The affine transformation then gives {ED}

Also, S(00) = 63: the "inverse" of 00 is still 00, leaving only the constant 63. (Checked with Python.)

Why use inversion: x↦x−1x \mapsto x^{-1} is highly nonlinear on F28\mathbb{F}_{2^8}. Nyberg (1993) proved that such maps have near-optimal resistance to differential attacks and linear attacks: any input difference produces a given output difference with probability at most 4/2564/256.

Why add an affine transformation too: the algebraic structure of pure inversion is too "clean" and might be exploited by algebraic attacks (such as interpolation attacks), and 00 and 11 are fixed points. The affine transformation disrupts this structure and ensures the S-box has no fixed points or "opposite fixed points".

3.4 MixColumns = polynomial multiplication modulo x4+1x^4 + 1

The 4 bytes of each column are treated as a cubic polynomial with coefficients in F28\mathbb{F}_{2^8}, a(y)=a3y3+a2y2+a1y+a0a(y) = a_3 y^3 + a_2 y^2 + a_1 y + a_0, and then

a(y)↦c(y)⋅a(y) mod (y4+1),c(y)=03 y3+01 y2+01 y+02.a(y) \mapsto c(y) \cdot a(y) \bmod (y^4 + 1),\qquad c(y) = \texttt{03}\,y^3 + \texttt{01}\,y^2 + \texttt{01}\,y + \texttt{02}.

Because y4≡1y^4 \equiv 1, this is a cyclic convolution, which as a matrix is

(c0c1c2c3)=(02030101010203010101020303010102)(a0a1a2a3).\begin{pmatrix} c_0 \\ c_1 \\ c_2 \\ c_3 \end{pmatrix} = \begin{pmatrix} 02 & 03 & 01 & 01 \\ 01 & 02 & 03 & 01 \\ 01 & 01 & 02 & 03 \\ 03 & 01 & 01 & 02 \end{pmatrix} \begin{pmatrix} a_0 \\ a_1 \\ a_2 \\ a_3 \end{pmatrix}.

Note that y4+1=(y+1)4y^4 + 1 = (y+1)^4 is reducible in characteristic 2, so this quotient ring isn't a field, but c(y)c(y) is coprime to y4+1y^4 + 1 and therefore invertible; decryption just multiplies by its inverse c−1(y)c^{-1}(y).

This matrix is also an MDS matrix (the same concept as MDS codes in Reed–Solomon error correction): the total number of nonzero bytes in input and output is at least 5. This guarantees the speed of diffusion, and is the core of the AES designers' "wide trail strategy".


Summary

Layer Key points
Intuition Confusion comes from the S-box, diffusion from ShiftRows and MixColumns, repeated for a dozen or so rounds
Algebra A byte == an element of F2[x]/(m(x))\mathbb{F}_2[x]/(m(x)); an irreducible polynomial gives a field
Design S-box == inverse + affine, resisting differential and linear attacks; MixColumns is MDS
Engineering The algorithm is solid; the risks are misused modes and side channels; AES-256 withstands quantum computers