forked from cypherstack/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bpplus.py
29 lines (23 loc) · 858 Bytes
/
test_bpplus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import bpplus
from dumb25519 import random_point, random_scalar, Scalar, ScalarVector, PointVector
from random import randrange
import unittest
class TestBPPlus(unittest.TestCase):
def test_complete(self):
params = bpplus.RangeParameters(random_point(),random_point(),4)
n_commits = 2
n_proofs = 4
statements = []
proofs = []
for _ in range(n_proofs):
v = ScalarVector([Scalar(randrange(0,2**params.N)) for _ in range(n_commits)])
r = ScalarVector([random_scalar() for _ in range(n_commits)])
witness = bpplus.RangeWitness(v,r)
C = PointVector([v[i]*params.H + r[i]*params.G for i in range(n_commits)])
statement = bpplus.RangeStatement(params,C)
statements.append(statement)
proof = bpplus.prove(statement,witness)
proofs.append(proof)
bpplus.verify(statements,proofs)
if __name__ == '__main__':
unittest.main()