import os from curvedh import * g = basepoint() print "g:", g.encode("hex") # Make a secret key from 32 random bytes x = makesecret(os.urandom(32)) y = makesecret(os.urandom(32)) print "x:", x.encode("hex") print "y:", y.encode("hex") # Do the exponentiation operation. Note: first exponent, then base X = curvedh(x, g) Y = curvedh(y, g) print "X:", X.encode("hex") print "Y:", Y.encode("hex") s1 = curvedh(x, Y) s2 = curvedh(y, X) print "s:", s1.encode("hex") print "s:", s2.encode("hex") assert s1 == s2 print "DH Success!"
import os from curvedh import * g = basepoint() print "g:", g.encode("hex") # Make a secret key from 32 random bytes x = makesecret(os.urandom(32)) y = makesecret(os.urandom(32)) print "x:", x.encode("hex") print "y:", y.encode("hex") # Do the exponentiation operation. Note: first exponent, then base X = curvedh(x,g) Y = curvedh(y,g) print "X:", X.encode("hex") print "Y:", Y.encode("hex") s1 = curvedh(x,Y) s2 = curvedh(y,X) print "s:", s1.encode("hex") print "s:", s2.encode("hex") assert s1 == s2 print "DH Success!"
def expon(self, base, exp): return curvedh(exp, base)