def test_vec_mul_E_is_correct_2(self): s, k, prover_id = 3, 0, 1 c = [None] * s zk = ZKProof(s, prover_id, k, RuntimeStub(), c) zk.e = [0, 1, 1] x = [2, -3, 0] x_mul_E = zk._vec_mul_E(x) self.assertEquals([v for v in [0, 2, -1, -3, 0]], x_mul_E)
def test_vec_pow_is_correct_2(self): s, k, prover_id = 3, 0, 1 c = [None] * s y = [mpz(i) for i in [1, 7, 2]] zk = ZKProof(s, prover_id, k, RuntimeStub(), c) zk.e = [0, 1, 1] y_pow_E = zk._vec_pow_E(y, 117) self.assertEquals([mpz(v) for v in [1, 1, 7, 14, 2]], y_pow_E)
def test_vec_pow_is_correct(self): s, prover_id, k = 5, 1, 0 c = [None] * s y = [mpz(i) for i in range(1, 6)] zk = ZKProof(s, prover_id, k, RuntimeStub(), c) zk.e = [1, 0, 1, 1, 0] y_pow_E = zk._vec_pow_E(y, 117) self.assertEquals([mpz(v) for v in [1, 2, 3, 8, 30, 12, 20, 5, 1]], y_pow_E)
def test_vec_mul_E_is_correct(self): s, prover_id, k, Zn = 5, 1, 0, GF(17) c = [None] * s y = [Zn(i) for i in range(1, 6)] zk = ZKProof(s, prover_id, k, RuntimeStub(), c) zk.e = [1, 0, 1, 1, 0] x = [1, 2, 0, 1, 0] x_mul_E = zk._vec_mul_E(x) self.assertEquals([v for v in [1, 2, 1, 4, 2, 1, 1, 0, 0]], x_mul_E)
def test_zk_matrix_entries_are_correct(self): s, k, prover_id = 5, 1, 1 c = [None] * s zk = ZKProof(s, prover_id, k, RuntimeStub(), c) zk.e = [1, 0, 0, 1, 1] for i in range(zk.s): for j in range(zk.m): if j >= i and j < i + zk.s: self.assertEquals(zk.e[j - i], zk._E(j, i)) else: self.assertEquals(0, zk._E(j, i))
def test_generate_Z_and_W_is_correct(self, runtime): s, prover_id, k = 3, 1, 0 c = [None] * s zk = ZKProof(s, prover_id, k, runtime, c) zk.u = [1, -2, 0, 6, -3] zk.v = [3, 5, 2, 1, 7] zk.x = [2, -3, 0] zk.r = [1, 7, 2] zk.e = [0, 1, 1] zk._generate_Z_and_W() self.assertEquals([1, 0, -1, 3, -3], zk.Z) self.assertEquals([3, 5, 14, 14, 14], zk.W)