Last active
March 3, 2019 06:18
-
-
Save Jun-Wang-2018/9ef685a7001b3ccd10b55690db82dff0 to your computer and use it in GitHub Desktop.
Add two points 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
# Predfined parameters (x1,y1,x2,y2 are integers) | |
A = (x1,y1); B = (x2,y2) | |
# Function | |
def ECadd(A,B): | |
lambda_mod = (B[1]-A[1])% P * modular_inverse(B[0]-A[0], P) | |
x3 = (lambda_mod * lambda_mod - A[0] - B[0]) % P | |
y3 = (lambda_mod * (A[0] - x3) - A[1]) % P | |
return (x3,y3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment