Processing math: 100%
Ask Your Question
1

Computing the inverse of a generic element in a finite field extension

asked 2 years ago

Wimet gravatar image

updated 2 years ago

FrédéricC gravatar image

I am working in the following field extension:

p = 2**64-2**32+1
P.<X,A,B,C> = PolynomialRing(GF(p))
GF.<x,a,b,c> = P.quotient_ring(X^3-X-1)

My objective is to take a generic element of this field p(x) = a + b*x + c*x^2 and compute its inverse, where its coefficients are a function of a,b,c.

However, if I try to directly do it:

q = x^2
qinv = 1 / q

I get a singular error. I get an error (ArithmeticError: Division failed. The numerator is not a multiple of the denominator.) if I change the prime to, say, 5. If I do not use the variables to express the generic coefficients of p(x), then clearly it works, but I do not get the desired result.

Is there any way I can achieve what I need?

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 2 years ago

dan_fulea gravatar image

You can extract the inverse from the following code:

sage: p = 2**64 - 2**32 + 1
sage: p
18446744069414584321
sage: F.<x> = GF(p^3, modulus=X^3 - X - 1)
sage: y, z = [root for root in (X^3 - X - 1).roots(ring=F, multiplicities=False) if root != x]
sage: R.<a,b,c> = PolynomialRing(F)
sage: e = a + b*x + c*x^2
sage: f = a + b*y + c*y^2
sage: g = a + b*z + c*z^2
sage: e*f*g
a^3 - a*b^2 + b^3 + 2*a^2*c + 18446744069414584318*a*b*c + a*c^2 - b*c^2 + c^3

Here, the number efg is in the field FFq, q=p3, if the elements a,b,c are also there. So multiplying e with fg delivers the above element. So the inverse of e is: 1e=fga3+b3+c3ab2bc2+ac2+2a2c3abc . Of course, we have "ugly" expressions for f,g in the numerator, which involve y,z and their squares:

sage: y
6700183068485440219*x^2 + 8396469466686423992*x + 7831040667286096068
sage: z
11746561000929144102*x^2 + 10050274602728160328*x + 10615703402128488253

sage: y^2
10050274602728160328*x^2 + 3915520333643048034*x + 11746561000929144103
sage: z^2
8396469466686423992*x^2 + 14531223735771536287*x + 6700183068485440220

(There are alternative solutions, but this works for me in a simplest manner.)

Preview: (hide)
link

Comments

Thank you very much! I think that there is a missing line of code that defines the "X". Something like:

P.<X> = PolynomialRing(GF(p))

Follow-up question: Is there any way I can compute the inverse of the denominator of 1/e? I want to know if it is possible to obtain an expression that avoids computing inverses of elements in Fp; so 1/e=fg(something1), instead of 1/e=fg/(something), where something is the denominator that you obtained through efg.

Wimet gravatar imageWimet ( 2 years ago )
0

answered 2 years ago

Max Alekseyev gravatar image

This looks like a simplest solution:

p = 2**64-2**32+1
P.<a,b,c> = PolynomialRing(GF(p))
Q.<X> = PolynomialRing(P.fraction_field())
R.<x> = Q.quotient_ring(X^3-X-1)

print( 1 / (a + b*x + c*x^2) )
Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2 years ago

Seen: 805 times

Last updated: May 27 '22