4.8 KiB
4.8 KiB
Finite Field Arithmetic
- A finite field is a set containing a finite number of elements
- This is sometimes called a Galois Field
- In a Galois field you can:
- Add
- Subtract
- Multiply
- Invert (divide)
- Fields are an extension of groups and related to rings
Groups
A group is a set of elements G together with an operation \circ that combines two elements of G
- The operation
\circis closed
- i.e. for all
a,b \in Gthena\circ b=c\in G- The operation is associative
- i.e.
a\circ(b\circ c) = (a\circ b)\circ cfor alla,b,c \in G- There is an element
1\in Gcalled a neutral element such thata\circ 1 = 1\circ a = afor alla\in G- For each
a \in Gthere exists an elementa^{-1}\in Gcalled the inverse ofasuch thata\circ a^{-1} = a^{-1}\circ a = 1- A group
Gis abelian (commutative) ifa\circ b = b \circ afor alla,b\in G
Example Group
- The set of integers
\mathbb{Z}_m = \{0,1,...m-1\}with the operation addition modulo m form a group with the neutral element 0 - Every element would have an inverse where
a + (-a) = 0mod m - This group would not form a group with multiplication, as not all elements would have an inverse
- We wouldn’t have an inverse, we would need
5\times \frac15=1however\frac15 \notin \mathbb{Z}
- We wouldn’t have an inverse, we would need
Fields
A field F is a set of elements with the following properties
- All elements of
Fform an additive group with the group operation+and the neutral element 0- All elements of
Fexcept 0 form a multiplicative group with the group operation\timesand the neutral element 1- When the two group operations are mixed, the distributivity law holds.
- i.e. for all
a,b,c \in F, a\cdot(b+c) = (a\cdot b) + (a\cdot c)
Example Field
- The set of real numbers
\mathbb{R}is a field with neutral element 0 for addition and 1 for multiplication - Every real number
ahas a additive inverse-a - Every non-zero number
ahas a multiplicative inverse\frac{1}{a}
Finite Fields
A finite field only exists if it has
p^melementsWhere:
pis a primemis a positive integer
Examples
- There is a field with 11 elements:
GF(11) - There is a field with 256 elements:
GF(256)orGF(2^8) GF(12)is not a finite field(2^2 \cdot3)
Prime and Extension Fields
When m=1 it creates a prime field
When m>1 it creates an extension field
Prime Fields
- A prime field
GF(p)contains the integers\{0,1,...p-1\}
- These operations satisfy the properties of fields (closure)
Inversion in Prime Fields
a \cdot a^{-1} \equiv 1 \space (mod \space p)
- A modular inverse exists when
gcd(a,p) = 1 - Because
pis prime, every number has a multiplicative inversegcd(a,p) = 1, \forall a \neq0 \in GF(p)
a^{-1}can be calculated using the extended Euclidean algorithm
Extension Fields
- In prime fields, the elements are integers
- Elements in extension fields
GF(2^m)are polynomials of degreem
a_{m-1}x^{m-1}, ..., a_1x + a_0 = A(x) \in GF(2^m)
where a_i \in GF(2) = \{0,1\}
The coefficients of the polynomial are elements in GF(2) the sub-field
Example GF(2^3)
- The field
GF(2^3), sometimes calledGF(8)is an extension field containing elements of the form:A(x) = a_2 x^2 + a_1x^1 + a_0 - Its often easier to simply write the coefficients
(a_2, a_1, a_0)e.g. 001 or 101 GF(2^3) = \{0, 1, x, x+1, x^2, x^2+1, x^2 + x, x^2 + x + 1\}|GF(2^3)| = 8
Arithmetic in GF(2^3)
- Adding or subtracting two polynomials happens as expected, but adding the coefficients
A(x) = x^2 + x + 1B(x) = x^2 + 1A(x) + B(x) = (1+1)x^2 + (1)x + (1+1) = x
- mod 2 is simply
xor - Addition and subtraction are identical
Multiplication in GF(2^3)
A(x) = x^2 + x + 1B(x) = x^2 + 1A(x) \cdot B(x) = (x^2 + x + 1)(x^2 + 1) = x^4 + x^3 + (1+1)x^2 + x + 1x^4 + x^3 + x + 1however this is not in the field- The result must be reduced by the result modulo an irreducible polynomial
A(x) \cdot B(x) = x^4 + x^3 + x + 1\space (mod \space x^3 + x + 1)
- This means we have to do polynomial long division
Inversion
- Inversion is performed in a similar way to prime fields, we find:
A(x) \cdot A^{-1}(x) \equiv 1 \space (mod \space P(x))A^{-1}(x)is calculated using the extended euclidean algorithm
AES’ Finite Field
- AES uses the extension field
GF(2^8)for many of its operations - Operations are the same as those in other
GF(2^m)fields, using the irreducible polynomial
P(x) = x^8 + x^4 + x^3 + x + 1
- As you might expect, these polynomials are typically represented as single bytes


