Defining AES MixColumns in Sage
AES is a famous cipher. It has an operation called MixColumns (See Wikipedia entry Rijndael MixColumns) where operations take place over finite fields.
Actually, there's a specific polynomial a(x)=a3x3+a2x2+a1x+a0 whose coefficients belong to GF(28). MixColumns is defined between a(x) and any polynomial b(x)=b3x3+b2x2+b1x+b0 (whose coefficients belong to GF(28) as well): It first multiplies a(x) by b(x) (where the algebraic rules between coefficients are governed by GF(28)), and then computes the remainder modulo x4+1.
I tried to mimic the operations in Sage as follows:
R.<x> = PolynomialRing(GF(2), 'x')
S.<y> = QuotientRing(R, R.ideal(x^8+x^4+x^3+x+1))
T.<z> = QuotientRing(S, S.ideal(y^4+1))
But Sage displays an error on the last line. The error seems to be originating from the introduction of z
. If I replace the last line with, say, T = QuotientRing(S, S.ideal(y^4+1))
, the error goes away. Yet this is not what I intended.
Furthermore, the command S.ideal(y^4+1)
outputs:
Principal ideal (1) of Univariate Quotient Polynomial Ring in y over Finite Field of size 2 with modulus x^8 + x^4 + x^3 + x + 1
I don't understand why its is the principal ideal (1) rather than the principal ideal (y^4+1).