|
@@ -69,6 +69,11 @@ def signatureWithESK(m,h,pk):
|
|
|
def newSK():
|
|
|
return os.urandom(32)
|
|
|
|
|
|
+def random_scalar(entropy_f):
|
|
|
+
|
|
|
+ oversized = int(binascii.hexlify(entropy_f(32+32)), 16)
|
|
|
+ return oversized % ell
|
|
|
+
|
|
|
|
|
|
|
|
|
MSG = "This is extremely silly. But it is also incredibly serious business!"
|
|
@@ -126,6 +131,31 @@ class SelfTest(unittest.TestCase):
|
|
|
|
|
|
self._testSignatures(besk, bpk)
|
|
|
|
|
|
+ def testIdentity(self):
|
|
|
+
|
|
|
+
|
|
|
+ By = 4 * inv(5)
|
|
|
+ Bx = xrecover(By)
|
|
|
+ B = [Bx % q,By % q]
|
|
|
+
|
|
|
+
|
|
|
+ identity = scalarmult(B, ell)
|
|
|
+
|
|
|
+
|
|
|
+ sk = newSK()
|
|
|
+ pk = decodepoint(publickey(sk))
|
|
|
+ identity2 = scalarmult(pk, ell)
|
|
|
+
|
|
|
+
|
|
|
+ assert(identity == identity2)
|
|
|
+
|
|
|
+ assert(identity == [0L,1L])
|
|
|
+
|
|
|
+
|
|
|
+ scalar = random_scalar(os.urandom)
|
|
|
+ result = scalarmult(identity, scalar)
|
|
|
+ assert(result == identity == identity2)
|
|
|
+
|
|
|
|
|
|
|
|
|
|