Ask Your Question
0

how to solve the errorOverflowError: cannot fit 'long' into an index-sized integer 122

asked 2017-09-12 09:43:46 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

The following code of elliptic curve gives me above error.

p =2^31-1   # prime number
k.<a> = FiniteField (p^2) ; Finite Field in a of size 2147483647^2
R.<z> = k[];R#PolynomialRing(k);Univariate Polynomial Ring in z over Finite Field in a of size 2147483647^2

i have computed from my code B1

B1 =  858993459*a + 429496730

I want to compute

x= R(B_1*z+(B_1*z)^p);X

but it gives me above error how to solve it for large prime number.strong text

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-09-12 10:24:49 -0500

dan_fulea gravatar image

The following works for me:

sage: p = 2^31 - 1
sage: p.is_prime()
True
sage: k.<a> = GF( p^2 )
sage: R.<z> = PolynomialRing( k, sparse=True )
sage: R
Sparse Univariate Polynomial Ring in z over Finite Field in a of size 2147483647^2
sage: B1 = 858993459*a + 429496730
sage: B1^p
1288490188*a + 1717986918
sage: B1*z + (B1*z)^p
(1288490188*a + 1717986918)*z^2147483647 + (858993459*a + 429496730)*z

The only important place is the one with PolynomialRing( k, sparse=True ), so that a sparse polynomial of high power can be stored.

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

Stats

Asked: 2017-09-12 09:43:46 -0500

Seen: 54 times

Last updated: Sep 12