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

asked 2017-09-12 16:43:46 +0200

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 close merge delete

Sort by ยป oldest newest most voted

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.

more