Skip to content

Instantly share code, notes, and snippets.

@AndyNovo
Created April 25, 2016 15:01
Show Gist options
  • Save AndyNovo/6a7f847760532b69576803733317d483 to your computer and use it in GitHub Desktop.
Save AndyNovo/6a7f847760532b69576803733317d483 to your computer and use it in GitHub Desktop.
def invMod(x, p):
return pow(x, p-2, p)
def addECC(x1,y1,x2,y2,a,b,p):
s = (invMod(x2-x1, p)*(y2-y1)) % p
if ((x1 - x2) % p == 0) and ((y1-y2) % p == 0):
s=(invMod(2*y1, p)*(3*x1*x1 + a)) % p
x3 = (s*s -x1 -x2) %p
y3 = (s*(x1-x3) -y1) % p
return x3,y3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment