Ask Your Question
1

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

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

anonymous user

Anonymous

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

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

Var('x')
F.<x> = GF(13^2)
a=F.fetch_int(150)+F.fetch_int(97)
print a

How can I fix this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

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

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.

Illustration

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
    :meth:`characteristic()`.
...

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
12275

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

edit flag offensive delete link more
0

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

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

Comments

1

@ tmonteil What is the solution then?

MKS gravatar imageMKS ( 2021-01-25 18:04:36 +0200 )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

Stats

Asked: 2021-01-25 14:31:08 +0200

Seen: 65 times

Last updated: Jan 25