Ask Your Question

How to do arithmetic operation of elements in finite field?

asked 2021-01-25 13:35:17 +0200

anonymous user


updated 2021-01-25 13:46:40 +0200

Let us consider an example:

F.<x> = GF(13^2)

We consider two elements 2*x + 11, 3*x + 2 corresponding to the integers 37 and 41 respectively. Now we can operate them as


We have a=4*x + 10 , m= 4*x + 10

In reverse way we can get the corresponding integers as :


That is, ai=65, mi=62

How can I do the same for the field GF(251) using the same function?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-01-25 17:48:43 +0200

tmonteil gravatar image

updated 2021-01-25 17:55:46 +0200

Because 251 is prime, Sage choose a different implementation for GF(13^2) and GF(251), see:

sage: 251 in Primes()

sage: type(GF(13^2))
<class 'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>

sage: type(GF(251))
<class 'sage.rings.finite_rings.finite_field_prime_modn.FiniteField_prime_modn_with_category'>

As you can see, the field GF(13^2) is handled by givaro. If you look to the documentation of the GF constructor:

sage: GF?

you can see that you can chose the implementation yourself instead of relying to Sage best guess. Hence you can construct the field GF(251) using the givaro backend, which provides the fetch_int method:

sage: F.<x> = GF(251^2, impl='givaro') 
sage: a=F.fetch_int(37)+F.fetch_int(41)
sage: m=F.fetch_int(37)*F.fetch_int(41)
sage: ai=a.integer_representation()
sage: mi=m.integer_representation()
sage: ai,mi
(78, 11)

By the way, Var('x') is if no use here, since F.<x> = defines both F and x (and the var function name is lowercase).

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2021-01-25 13:35:17 +0200

Seen: 548 times

Last updated: Jan 25 '21