
260 Cryptography with Open-Source Software
Also as with Rijndael, this S-box is generated by an affine transformation of
inverses in the field. Suppose that n is a given nybble, which corresponds to
an element of F . Define
n
′
=
0 if n = 0
n
−1
otherwise.
Then
s
n
= an
′
+ b mod (y
4
+ 1)
where
a = y
3
+ y
2
+ 1, b = y
3
+ 1
and both a and b are considered as elements of the ring Z
2
[y]/(y
4
+ 1). This
is not a field as not all elements are invertible.
For example, consider the nybble 4 = 0 100, which corresponds to polyno-
mial x
2
. In F its inverse is x
3
+ x
2
+ 1:
sage: F.<x> = GF(16,name=’x’)
sage: p = 1/x^2; p
x^3 + x^2 +1
Then:
sage: R.<y> = PolynomialRing(GF(2))
sage: a = y^3+y^2+1 ...