forked from cypherstack/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_chaum.py
23 lines (18 loc) · 825 Bytes
/
test_chaum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import chaum
from dumb25519 import random_point, random_scalar, ScalarVector, PointVector
import unittest
class TestChaum(unittest.TestCase):
def test_complete(self):
params = chaum.ChaumParameters(random_point(),random_point(),random_point(),random_point())
n = 3
x = ScalarVector([random_scalar() for _ in range(n)])
y = ScalarVector([random_scalar() for _ in range(n)])
z = ScalarVector([random_scalar() for _ in range(n)])
witness = chaum.ChaumWitness(x,y,z)
S = PointVector([x[i]*params.F + y[i]*params.G + z[i]*params.H for i in range(n)])
T = PointVector([x[i].invert()*(params.U - y[i]*params.G) for i in range(n)])
statement = chaum.ChaumStatement(params,'Proof context',S,T)
proof = chaum.prove(statement,witness)
chaum.verify(statement,proof)
if __name__ == '__main__':
unittest.main()