Ask Your Question

neubert's profile - activity

2021-01-20 12:58:32 +0200 received badge  Famous Question (source)
2020-04-03 10:09:54 +0200 received badge  Notable Question (source)
2018-12-30 13:33:55 +0200 received badge  Popular Question (source)
2017-09-04 10:23:32 +0200 asked a question 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 = Integer(0x61661990d3b1f7a608ad095a01d727380850d2592f5b9f88f66a20e8);
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)
<ipython-input-4-dba4addbde0d> in <module>()
      2 
      3 X = Integer(Integer(0x61661990d3b1f7a608ad095a01d727380850d2592f5b9f88f66a20e8));
----> 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?

2017-09-04 10:23:31 +0200 asked a question pre-reduction multiplication result in binary field

The following will do multiplication in a finite field:

X = Integer(0x009D73616F35F4AB1407D73562C10F);
Y = Integer(0x00A52830277958EE84D1315ED31886);

F.<x> = GF(2)[];
p = x^113 + x^9 + 1;
BF = GF(2^113, 'x', modulus=p);

X_bf = BF._cache.fetch_int(X);
Y_bf = BF._cache.fetch_int(Y);

temp = Y * X; temp

The problem with this is that the result you get back has had the reduction step already ran. I'd like to see the multiplication result pre-reduction.

Any ideas?