Skip to content

Instantly share code, notes, and snippets.

@notcod
Created August 1, 2021 09:54
Show Gist options
  • Select an option

  • Save notcod/e3d93e9eb1457aa870d6e4ff2ae35c68 to your computer and use it in GitHub Desktop.

Select an option

Save notcod/e3d93e9eb1457aa870d6e4ff2ae35c68 to your computer and use it in GitHub Desktop.
def func():
z = "01010011100101"
l = len(z)
p = 115792089237316195423570985008687907853269984665640564039457584007908834671663
x = Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
y = Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424
for i in range(1, l):
lm, hm = 1, 0
lw, hg = 2*y % p, p
while lw > 1:
ro = hg//lw
nm, nw = hm-lm*ro, hg-lw*ro
lm, lw, hm, hg = nm, nw, lm, lw
R = lm % p
o = 3*x*x*R % p
u = o*o-2*x
y = (o*(x-u % p)-y) % p
x = u % p
if z[i] == "1":
lm, hm = 1, 0
lw, hg = (Gx - x) % p, p
while lw > 1:
ro = hg//lw
nm, nw = hm-lm*ro, hg-lw*ro
lm, lw, hm, hg = nm, nw, lm, lw
R = lm % p
o = (Gy-y)*R % p
u = o*o-x-Gx
y = (o*(x-u % p)-y) % p
x = u % p
return (x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment