Last active
March 3, 2019 06:18
-
-
Save Jun-Wang-2018/6527e218ccff82996763e01b8184e923 to your computer and use it in GitHub Desktop.
Double a point on a elliptic curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An example of predfined parameters | |
a = 1; b = 1 | |
P = 23 | |
x1 = 0; y1 = 1 | |
G = (x1,y1) | |
# Function | |
def ECdouble(G,a,b,P): # G = (x1,y1) where x1,y1 are integers. | |
lambda_mod = (3*G[0]** 2 + a)% P * modular_inverse(2*G[1],P) | |
x3 = (lambda_mod * lambda_mod - G[0] - G[0]) % P | |
y3 = (lambda_mod * (G[0]-x3)-G[1]) % P | |
return (x3,y3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment