Exemple #1
0
 def test_batch_2_m_1_n_4(self):
     M = 1
     N = 4
     data = [[Scalar(random.randint(0,2**N-1)),random_scalar()] for i in range(M)]
     proof1 = pybullet.prove(data,N)
     data = [[Scalar(random.randint(0,2**N-1)),random_scalar()] for i in range(M)]
     proof2 = pybullet.prove(data,N)
     pybullet.verify([proof1,proof2],N)
Exemple #2
0
 def test_invalid_value(self):
     M = 1
     N = 4
     data = [[
         Scalar(random.randint(2**N, 2**(N + 1) - 1)),
         random_scalar()
     ]]
     with self.assertRaises(ArithmeticError):
         pybullet.verify([pybullet.prove(data, N)], N)
Exemple #3
0
 def test_invalid_batch_2_m_1_2_n_4(self):
     M = 1
     N = 4
     data = [[Scalar(random.randint(0,2**N-1)),random_scalar()] for i in range(M)]
     proof1 = pybullet.prove(data,N)
     M = 2
     data = [[Scalar(random.randint(2**N,2**(N+1)-1)),random_scalar()] for i in range(M)]
     proof2 = pybullet.prove(data,N)
     with self.assertRaises(ArithmeticError):
         pybullet.verify([proof1,proof2],N)
Exemple #4
0
    def verify(self):
        # Verify spend proof
        #aux1_,aux2_ = spend.verify(self.spend_proof,[coin.P for coin in self.coins_in],[coin.C for coin in self.coins_in],[coin.C for coin in self.coins_out]+[com(self.f,Scalar(0))])
        spend.verify(self.spend_proof, [coin.P for coin in self.coins_in],
                     [coin.C for coin in self.coins_in],
                     [coin.C
                      for coin in self.coins_out] + [com(self.f, Scalar(0))])

        #if not (aux1_ == aux1 and aux2_ == aux2):
        #    raise ArithmeticError('Failed to recover hidden data!')

        # Verify range proof
        pybullet.verify([self.range_proof], BITS)
Exemple #5
0
 def test_prove_verify_m_2_n_4(self):
     M = 2
     N = 4
     data = [[Scalar(random.randint(0,2**N-1)),random_scalar()] for i in range(M)]
     pybullet.verify([pybullet.prove(data,N)],N)