from Crypto.Util.number import * q = 37474009785980474658135106783131904659818035950984079581009709986840194575036321428945132957079423328996508289872067 a = 138681122158674534796479818810828100269024674330030901179877002756402543027343312824423418859769980312713625658733 b = 4989541340743108588577899263469059346332852532421276369038720203527706762720292559751463880310075002363945271507040 F = GF(q) E = EllipticCurve(F,[a, b]) P = E.gens()[0] print(P.order()) # 6245668297663412443022517797188650776636339325164013263502088991281378002278537965565236170652485316181515543825266 Q = 2 * P
R.<x> = PolynomialRing(GF(q)) x = R.gen() px = x^3 + a * x + b roots = px.roots() r1 = roots[0][0] r2 = roots[1][0] r3 = roots[2][0]
Qxq = F(Q[0]) Qyq = F(Q[1]) s1 = -(Qxq - r1).sqrt() # two solution, change positivity for the other solution. s2 = (Qxq - r2).sqrt() # two solution