The below code is for point doubling arithmetic of elliptic curve but it is got stuck when i run the code on SAGE math cloud due to gcd operation #point Doubling import time p =2^192-2^64-1;#p A=6277101735386680763835789423207666416102355444464034512892 B=2455155546008943817740293915197451784769108058161191238065 print"\n p=",p print"\n A=",A print"\n B=",B
F = GF(p , proof=False) E = EllipticCurve( F, [A,B] );
S. = PolynomialRing( F ) K. = GF( p^2);#K.modulus#, modulus=W^2+W+1 ) print "\n Modulus of K is =", K.modulus()
R.<z> = PolynomialRing( K, sparse=True )
x= (2092367245128893587945263141069222138694636233463441653760a + 4184734490257787175890526282138444277389272466926883307520)z^6277101735386680763835789423207666416083908700390324961279 + (4184734490257787175890526282138444277389272466926883307519a + 2092367245128893587945263141069222138694636233463441653760)z
y= (4184734490257787175890526282138444277389272466926883307520a + 2092367245128893587945263141069222138694636233463441653760)z^6277101735386680763835789423207666416083908700390324961279 + (2092367245128893587945263141069222138694636233463441653759a + 4184734490257787175890526282138444277389272466926883307519)z
f=(697455748376297862648421047023074046231545411154480551253a + 3487278741881489313242105235115370231157727055772402756266)z^18831305206160042291507368269622999248251726101170974883837 + (4184734490257787175890526282138444277389272466926883307519a + 2092367245128893587945263141069222138694636233463441653759)z^12554203470773361527671578846415332832167817400780649922559 + 4184734490257787175890526282138444277389272466926883307519z^12554203470773361527671578846415332832167817400780649922558 + (2092367245128893587945263141069222138694636233463441653760a + 4184734490257787175890526282138444277389272466926883307519)z^6277101735386680763835789423207666416083908700390324961281 + 4184734490257787175890526282138444277389272466926883307520z^6277101735386680763835789423207666416083908700390324961280 + (4184734490257787175890526282138444277383123552235646790315a + 2092367245128893587945263141069222138682338404080968619351)z^6277101735386680763835789423207666416083908700390324961279 + (5579645987010382901187368376184592369852363289235844410026a + 2789822993505191450593684188092296184926181644617922205013)z^3 + 4184734490257787175890526282138444277389272466926883307519z^2 + (2092367245128893587945263141069222138700785148154678170964a + 4184734490257787175890526282138444277383123552235646790315)*z + 3821946189377736946095495508010214631314800642229133723214
print "\n Elliptic Curve fE(z) = ", f
P = E.random_point()
Q = E.random_point()
print "\n point1 =", P.xy()
print "\n point2 =", Q.xy()
start1 = time.time() H = P + P; end1 = time.time() Hx, Hy = H.xy() print "\n H = P + P has the components:\nHx = %s\nHy = %s" % ( Hx, Hy ) print "\n Time for this operation (existing approach): %s" % ( end1 - start1 )
start = time.time() g = ((2P[1]y)-((3P[0]^2)+A)x -(-P[0]^3+(AP[0])+2B))
g = ( ( 2 * P[1] * y ) - ( ( 3 * P[0]^2) + A) * x
#-(-P[0]^3 + ( A * P[0] ) + 2 * B) )
print "\n Line equation =", g
f1 = gcd( f , g )#.monic() print "\n f1 = gcd (fE,fL) = ", f1
f2 = ( z - P[0] - P[1]a ) # ( z - Q[0] - Q[1]*a ) print "\n point equation =", f2
f3 = f1 // f2 print "\n Division of two polynomials f1 & f2 =", f3
c = f3.constant_coefficient() f4=(-c) M0, M1 = S(f4).coefficients()
G = E.point( ( M0, -M1 ) ) end = time.time()
Gx, Gy = G.xy() print "\n G = P + Q has the components:\nGx = %s\nGy = %s" % ( Gx, Gy ) print "\n Time for this operation (new approach): %s" % ( end - start )code here