Galois Field tower field representation
I'm trying to create some galois field (GF4, GF16 and GF256) using a tower field representation, as described here:
GF(4) := GF(2)[a] / (a^2 + a+ 1)
GF(16) := GF(4)[b] / (b^2 + b + a)
GF(256) := GF(16)[c] / (c^2 + c + a*b)
I've tried doing that using field extensions, but i've been bumping in errors and dead ends so far. For example, i tried doing something like this:
GF2.<a> = GF(2)
GF4.<b> = GF(4, modulus=a^2+a+1)
But of course i'm getting this error, since the modulus simply evaluates to 1:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-ca2ad50ca645> in <module>
----> 1 GF4 = GF(Integer(2)**Integer(2), modulus=a**Integer(2)+a+Integer(1), names=('b',)); (b,) = GF4._first_ngens(1)
~/sage/sage-9.6/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/structure/factory.pyx in sage.structure.factory.UniqueFactory.__call__ (build/cythonized/sage/structure/factory.c:2264)()
365 False
366 """
--> 367 key, kwds = self.create_key_and_extra_args(*args, **kwds)
368 version = self.get_version(sage_version)
369 return self.get_object(version, key, kwds)
~/sage/sage-9.6/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage/rings/finite_rings/finite_field_constructor.py in create_key_and_extra_args(self, order, name, modulus, names, impl, proof, check_irreducible, prefix, repr, elem_cache, **kwds)
651
652 if modulus.degree() != n:
--> 653 raise ValueError("the degree of the modulus does not equal the degree of the field")
654 if check_irreducible and not modulus.is_irreducible():
655 raise ValueError("finite field modulus must be irreducible but it is not")
ValueError: the degree of the modulus does not equal the degree of the field
Do you have any idea on how to achieve this?