Some finite field calculations
Math 202 Cryptography
September 8, 2022

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

Working with (Subscript[ℤ, 2])[x]

Not surprisingly, Mathematica can handle the calculations you’ve done by hand. 
Let’s define our polynomials and reduce them modulo 2 using the Expand[ ] command.

f = x^2+x+1
g=x^2+1
Expand[f*g, Modulus-> 2]

Working in (Subscript[ℤ, 2])[x] / q(x) = GF(8)

We need to define q(x), and then we can use the PolynomialRemainder[ ] command. 
Notice that we don’t need to expand the product in this case.

q=x^3+x+1

f=x^2+x+1;
g=x^2+1;
PolynomialRemainder[f*g, q, x, Modulus->2]

Working in (Subscript[ℤ, 2])[x] / p(x) = GF((2^8))

You can also do the same thing but working in the Galois field used in AES!
We just need to define our polynomial, and then use the same function.

p=x^8+x^4+x^3+x+1

f=x^7+x^5+x^2+1;
g=x^4+x^3+x+1;
PolynomialRemainder[ f*g, p, x, Modulus-> 2]