Ask Your Question

Revision history [back]

The modulus should be a polynomial over the prime field.

R.<x> = PolynomialRing(GF(2))
G = GF(2^8, name='x', modulus=x^8 + x^5 + x^3 + x + 1)
F = GF(2^3, name='x', modulus=x^3 + x^2 + 1)

for i in range(2^3):
    print G.fetch_int(i).integer_representation(), '=', G.fetch_int(i)
    print F.fetch_int(i).integer_representation(), '=', F.fetch_int(i)

To get the generator of, say, F, use F.gen(). Or give them different names like so (still using x in R):

G.<a> = GF(2^8, modulus=x^8 + x^5 + x^3 + x + 1)
F.<b> = GF(2^3, modulus=x^3 + x^2 + 1)