예제 #1
0
 def test_witness(self):
     secret = randsn()
     items = list(range(1, 10))
     my_item = items[3]
     AkX = accumulate(items, secret)
     W_x = witness(AkX, my_item, secret)
     self.assertTrue(ismember(AkX, my_item, W_x, secret))
예제 #2
0
 def deposit(self, value):
     r = randsn()
     s, e = schnorr_create(r, G1)
     rG = ecmul(G1, r)
     output = Note(self.converter.to_token(value), r)
     receipt = self.contract.deposit(rG, s, e, Web3.toWei(value, "ether"))
     y = self.contract.get_note(output.x())
     assert output.C()[1].n == y
     self.add_notes(output)
     return receipt
예제 #3
0
def pedersen_c(v, r=None):
    if r is None:
        r = randsn()
    return ecadd(ecmultiply(G1, r), ecmultiply(H(), v)), r
예제 #4
0
 def test_borromean(self):
   msg = randsn()
   rings, pairs = borromean_ring_gen(n=4, m=4)
   e, s_mat = borromean_ring_sign(rings, pairs, msg=msg)
   self.assertTrue(borromean_ring_verify(rings, e, s_mat, msg=msg))
예제 #5
0
 def pedersen_c(self, v, r=None):
   from pysolcrypto.altbn128 import add, multiply, G1, randsn
   if r is None:
     r = randsn()
   return add(multiply(G1,r), multiply(self.H(), v)), r
예제 #6
0
 def test_borromean_with_bad_message(self):
   msg = randsn()
   rings, pairs = borromean_ring_gen(n=4, m=4)
   e, s_mat = borromean_ring_sign(rings, pairs, msg=msg)
   bad_msg = addmodp(msg,1)
   self.assertFalse(borromean_ring_verify(rings, e, s_mat, msg=bad_msg))