Ask Your Question

Arithmetic operation is not working in finite field GF(4091^2)?

asked 2021-01-25 14:31:08 +0100

anonymous user


updated 2021-01-25 14:31:44 +0100

I am facing problem during arithmetic operation in $ GF(4091^2)$. But everything working fine in $ GF(13^2)$ as

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

How can I fix this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2021-01-25 20:31:55 +0100

slelievre gravatar image

The difference comes from different methods being available depending on the underlying finite field implementation.

The givaro implementation, available only for prime powers less than 2^16, provides a fetch_int method.

Below we illustrate this and propose a fetch_int function to provide the functionality in other cases.


sage: p = 13
sage: F.<a> = GF(p^2)
sage: b = F.fetch_int(150)
sage: c = F.fetch_int(97)
sage: b, c, b + c
(11*a + 7, 7*a + 6, 5*a)

sage: pp = 4091
sage: FF.<aa> = GF(pp^2)
sage: FF.fetch_int(150)

sage: type(F)
<class 'sage.rings.finite_rings.finite_field_givaro.FiniteField_givaro_with_category'>
sage: type(FF)
<class 'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>

sage: FF.<aa> = GF(pp^2, impl='givaro')
Traceback (most recent call last)
ValueError: q must be < 2^16

sage: F.fetch_int??
    Given an integer `n` return a finite field element in ``self``
    which equals `n` under the condition that :meth:`gen()` is set to

Define fetch_int as a function:

def fetch_int(F, n):
    return FF(n.digits(base=F.characteristic()))

Then use it as follows:

sage: fetch_int(FF, 12275)
3*a + 2
sage: 3*pp + 2
sage: n

Making all finite fields provide fetch_int regardless of the implementation is the object of

edit flag offensive delete link more

answered 2021-01-25 17:54:29 +0100

tmonteil gravatar image

the following answer explains how to set the givaro implementation to benefit from the fetch_int method. Unfortunately, in this case, the number 4091^2 is too large for givaro implementation, so that the default implementation (pari) can not be replaced with givaro, which can only handle fields of size less than 2^16:

sage: type(GF(4091^2))
<class 'sage.rings.finite_rings.finite_field_pari_ffelt.FiniteField_pari_ffelt_with_category'>

sage: GF(4091^2, impl='givaro')
ValueError: q must be < 2^16
edit flag offensive delete link more



@ tmonteil What is the solution then?

MKS gravatar imageMKS ( 2021-01-25 18:04:36 +0100 )edit

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 14:31:08 +0100

Seen: 366 times

Last updated: Jan 25 '21