Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to solve raising a polynomial to the power of a number mod something

I want to raise the polynomial vec1[0] to the power of a number mod x

(vec1[0])^Binv[0][0], however when I do that, I receive the following message:

unsupported operand type(s) for &: 'sage.rings.finite_rings.integer_mod.IntegerMod_gmp' and 'int'

When I change Binv[0][0] to be an integer, everything works fine, however, this is not what I want to achieve. Is there any workaround to this?

How to solve raising a polynomial to the power of a number mod something

I want to raise the polynomial vec1[0] to the power of a number mod x

(vec1[0])^Binv[0][0], however when I do that, I receive the following message:

unsupported operand type(s) for &: 'sage.rings.finite_rings.integer_mod.IntegerMod_gmp' and 'int'

When I change Binv[0][0] to be an integer, everything works fine, however, this is not what I want to achieve. Is there any workaround to this?

Z3 = Integers(2^(e*m)-1); B = matrix(ZZ,2,2); F11 = 50; F12 = 24; F21 = 7; F22 = 88; B[0,0] = 2^F11; B[0,1] = 2^F12; B[1,0] = 2^F21; B[1,1] = 2^F22;

print B[0][0]

B_mod = B.mod(2^(e*m)-1)

print B_mod

Binv = matrix(Z3,2,2); Binv = B_mod.inverse();

R = PolynomialRing(K,'X'); R.inject_variables();

Find irreducible polynomial of degree 3

while True: c = K.random_element(); d = K.random_element(); f = K.random_element();

IP3 = X^3 + c*X^2 + d*X + f;
if IP3.is_irreducible():
    break;

RRR = R.quotient(IP3,'Y') RRR.inject_variables()
vec1 = X^2 * x[0] + X * x[1] + x[2]

result1 = RRR(vec1[0])^Binv[0][0]

How to solve raising a polynomial to the power of a number mod something

I want to raise the polynomial vec1[0] to the power of a number mod x

(vec1[0])^Binv[0][0], however when I do that, I receive the following message:

unsupported operand type(s) for &: 'sage.rings.finite_rings.integer_mod.IntegerMod_gmp' and 'int'

When I change Binv[0][0] to be an integer, everything works fine, however, this is not what I want to achieve. Is there any workaround to this?

Z3 = Integers(2^(e*m)-1);
B = matrix(ZZ,2,2);
F11 = 50;
F12 = 24;
F21 = 7;
F22 = 88;
B[0,0] = 2^F11;
B[0,1] = 2^F12;
B[1,0] = 2^F21;
B[1,1] = 2^F22;

print B[0][0]

2^F22; #print B[0][0] B_mod = B.mod(2^(e*m)-1)

print B_mod

B.mod(2^(e*m)-1) #print B_mod Binv = matrix(Z3,2,2); Binv = B_mod.inverse();

B_mod.inverse(); R = PolynomialRing(K,'X'); R.inject_variables();

Find R.inject_variables(); #Find irreducible polynomial of degree 3

3 while True: c = K.random_element(); d = K.random_element(); f = K.random_element();

K.random_element();

    IP3 = X^3 + c*X^2 + d*X + f;
 if IP3.is_irreducible():
     break;

RRR = R.quotient(IP3,'Y') RRR.inject_variables()
vec1 = X^2 * x[0] + X * x[1] + x[2]

x[2] result1 = RRR(vec1[0])^Binv[0][0]

RRR(vec1[0])^Binv[0][0]