-
-
Save tarcieri/40d2eb8e4e8f9ed28b3a to your computer and use it in GitHub Desktop.
Semiprivate keys in SAGE (via DCoder)
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
# curve25519 operats on F[2^255-19] so it's not actually a 2^256 value | |
import hashlib | |
p = 2^255 - 19; | |
E = EllipticCurve(GF(p), [0,486662,0,1,0]); | |
P = E.lift_x(9); | |
l = P.order(); | |
x = ZZ.random_element(l); | |
S = x*P; | |
y = int(hashlib.sha512(str(S)).hexdigest(), 16) % l; | |
z = x*y % l; | |
R = y*S; | |
assert(R == z*P) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment