コード例 #1
0
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!"
コード例 #2
0
ファイル: testcurvedh.py プロジェクト: ndavison21/ScalaSphinx
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!"
コード例 #3
0
 def expon(self, base, exp):
     return curvedh(exp, base)
コード例 #4
0
ファイル: SphinxParams.py プロジェクト: mdyszynski/Thebes
 def expon(self, base, exp):
     return curvedh(exp, base)