*Dr. Dobb's Journal* October 1997

# The Galois Field GF(2^{8})

Two byte values can be combined in many different ways to result in a third value. In general, a rule to combine two values to obtain a third value is called a "composition law." Some obvious examples of composition laws that are applicable to byte values are modular addition and multiplication, and the bitwise logical OR, AND, and XOR operations. The combination of a set and two composition laws is called an "algebra." If the laws obey certain rules, one of the laws can be seen as "additive" and the other as "multiplicative." Mathematicians have developed powerful tools to derive and prove nonobvious properties for these algebras. A particularly relevant property of such an algebra is the ability to solve *x* from the equation *a*+*b* *x*=0 for any value of *a* and any nonzero value of *b*. An algebra exhibiting these properties is called a field.

### Finite Field

A field with a finite number of elements is called a "finite field" or "Galois Field" (GF()), after the mathematician Evariste Galois.

The most obvious candidates for the two composition laws on bytes are addition modulo 256 and multiplication modulo 256. Unfortunately, the resulting algebra is not a field. For instance, the equation 1+2 *x*=0 has no solution.

Still, 2^{8} is a prime power and it is therefore possible to define two composition laws such that the resulting algebra is the field GF(2^{8}). For the additive law we take the bitwise XOR. The multiplicative is more involved, and is constructed as follows: The bits in the bytes are considered as coefficients of polynomials of degree smaller than 8 and the composition law is the multiplication of polynomials modulo some irreducible polynomial (with no other divisors than 1 and itself, similar to prime number). In practice, the multiplication can be easily implemented using table lookup methods.

-- J.D., L.K., and V.R.

*Copyright © 1997, Dr. Dobb's Journal*