Revision history [back]

calculating the modulo of a "number" in a binary finite field

Polynomial equations in binary finite fields are often represented as numbers. eg. $x^2 + 1$ is basically the same thing as $1x^2 + 0x^1 + 1x^0$ and thus would be represented as $101_2$ or $5_{10}$.

In that spirit I'm trying to use a hexadecimal number to represent a polynomial equation. The polynomial equation is larger than the modulo I'm using ($x^{113} + x^9 + 1$) so I'm trying to get the result of the modulo operation.

Here's what I've tried:

BF.<a> = FiniteField(2^113);

X_bf = BF._cache.fetch_int(X);

X_bf.mod(x^113 + x^9 + 1)


Unfortunately, this doesn't seem to work and instead gets me the following error messages:

TypeError                                 Traceback (most recent call last)
2
----> 4 X_bf = BF._cache.fetch_int(X);
5
6 X_bf.mod(x**Integer(113) + x**Integer(9) + Integer(1))

/home/sage/sage-8.0/src/sage/rings/finite_rings/element_ntl_gf2e.pyx in sage.rings.finite_rings.element_ntl_gf2e.Cache_ntl_gf2e.fetch_int (/home/sage/sage/src/build/cythonized/sage/rings/finite_rings/element_ntl_gf2e.cpp:7596)()
400         raise ValueError("Cannot coerce element %s to this field." % e)
401
--> 402     cpdef FiniteField_ntl_gf2eElement fetch_int(self, number):
403         """
404         Given an integer less than p^n with base 2

/home/sage/sage-8.0/src/sage/rings/finite_rings/element_ntl_gf2e.pyx in sage.rings.finite_rings.element_ntl_gf2e.Cache_ntl_gf2e.fetch_int (/home/sage/sage/src/build/cythonized/sage/rings/finite_rings/element_ntl_gf2e.cpp:7212)()
431
432         if number < 0 or number >= self.order():
--> 433             raise TypeError("n must be between 0 and self.order()")
434
435         if isinstance(number, int) or isinstance(number, long):

TypeError: n must be between 0 and self.order()


I realize that what I'm doing isn't technically a finite field but idk how else I might get a "number" turned into a polynomial equation.

Any ideas?