def test_verify1_2x2(self): b = [] b.append([Scalar(1),Scalar(0)]) b.append([Scalar(0),Scalar(1)]) r = random_scalar() proof1 = pyruff.prove1(b,r) B = pyruff.matrix_commit(b,r) pyruff.verify1(B,proof1)
def test_verify1_2x2_bad(self): # This matrix has duplicate 1 entries b = [] b.append([Scalar(1),Scalar(0)]) b.append([Scalar(1),Scalar(1)]) r = random_scalar() proof1 = pyruff.prove1(b,r) B = pyruff.matrix_commit(b,r) with self.assertRaises(ArithmeticError): pyruff.verify1(B,proof1) # This matrix has too few 1 entries b = [] b.append([Scalar(0),Scalar(0)]) b.append([Scalar(1),Scalar(1)]) r = random_scalar() proof1 = pyruff.prove1(b,r) B = pyruff.matrix_commit(b,r) with self.assertRaises(ArithmeticError): pyruff.verify1(B,proof1)
def test_1_2(self): m = [[random_scalar(),random_scalar()]] r = random_scalar() result = hash_to_point('pyruff 0 0')*m[0][0] + hash_to_point('pyruff 0 1')*m[0][1] + G*r self.assertEqual(pyruff.matrix_commit(m,r),result)