예제 #1
0
    def test_multiplication_of_commtiments_by_triplet(self):
        #q = self.ppatspp.q
        m1 = randint(1,self.maxmessage)
        r1 = randint(1,self.n-1)
        a1,r1 = self.ppatspk.commit(m1,r1)
        m2 = randint(1,self.maxmessage)
        r2 = randint(1,self.n-1)
        a2,r2 = self.ppatspk.commit(m2,r2)
        r3 = randint(1,self.n-1)
        a3,r3 = self.ppatspk.commit(m1*m2,r3)
        proof = nizk.multiplicationProof(self.ppatspk,a1,a2,a3,m1,m2,r1,r2,r3)
        m1p = randint(1,self.maxmessage)
        r1p = randint(1,self.n-1)
        d1,r1p = self.ppatspk.commit(m1p,r1p)
        m2p = randint(1,self.maxmessage)
        r2p = randint(1,self.n-1)
        d2,r2p = self.ppatspk.commit(m2p,r2p)
        g = self.ppatspp.g
        o1 = (r1p-r1)*g
        o2 = (r2p-r2)*g
        openings = (m1p-m1,o1),(m2p-m2,o2)

        d3 = nizk.multiplicationWithTripletAndCheck(self.ppatspk,d1,d2,a1,a2,a3,proof,openings)
        o3 = (r3+m2p*r1-m2*r1+m1p*r2-m1*r2)*g

        self.assertTrue(self.ppatspk.verifyOpening(d3,m1p*m2p,o3))
예제 #2
0
    def test_multiplication_of_commtiments_by_triplet(self):
        #q = self.ppatspp.q
        m1 = randint(1,self.maxmessage)
        r1 = randint(1,self.n-1)
        a1,r1 = self.ppatspk.commit(m1,r1)
        m2 = randint(1,self.maxmessage)
        r2 = randint(1,self.n-1)
        a2,r2 = self.ppatspk.commit(m2,r2)
        r3 = randint(1,self.n-1)
        a3,r3 = self.ppatspk.commit(m1*m2,r3)
        proof = nizk.multiplicationProof(self.ppatspk,a1,a2,a3,m1,m2,r1,r2,r3)
        m1p = randint(1,self.maxmessage)
        r1p = randint(1,self.n-1)
        d1,r1p = self.ppatspk.commit(m1p,r1p)
        m2p = randint(1,self.maxmessage)
        r2p = randint(1,self.n-1)
        d2,r2p = self.ppatspk.commit(m2p,r2p)
        g = self.ppatspp.g
        o1 = (r1p-r1)*g
        o2 = (r2p-r2)*g
        openings = (m1p-m1,o1),(m2p-m2,o2)

        d3 = nizk.multiplicationWithTripletAndCheck(self.ppatspk,d1,d2,a1,a2,a3,proof,openings)
        o3 = (r3+m2p*r1-m2*r1+m1p*r2-m1*r2)*g

        self.assertTrue(self.ppatspk.verifyOpening(d3,m1p*m2p,o3))
예제 #3
0
 def test_multiplication_of_commitment_proof_and_check(self):
     m1 = randint(1,self.maxmessage)
     r1 = randint(1,self.n-1)
     d1,r1 = self.ppatspk.commit(m1,r1)
     m2 = randint(1,self.maxmessage)
     r2 = randint(1,self.n-1)
     d2,r2 = self.ppatspk.commit(m2,r2)
     r3 = randint(1,100)
     d3,r3 = self.ppatspk.commit(m1*m2,r3)
     proof = nizk.multiplicationProof(self.ppatspk,d1,d2,d3,m1,m2,r1,r2,r3)
     self.assertTrue(nizk.multiplicationProofCheck(self.ppatspk,d1,d2,d3,proof))
예제 #4
0
 def test_multiplication_of_commitment_proof_and_check(self):
     m1 = randint(1,self.maxmessage)
     r1 = randint(1,self.n-1)
     d1,r1 = self.ppatspk.commit(m1,r1)
     m2 = randint(1,self.maxmessage)
     r2 = randint(1,self.n-1)
     d2,r2 = self.ppatspk.commit(m2,r2)
     r3 = randint(1,100)
     d3,r3 = self.ppatspk.commit(m1*m2,r3)
     proof = nizk.multiplicationProof(self.ppatspk,d1,d2,d3,m1,m2,r1,r2,r3)
     self.assertTrue(nizk.multiplicationProofCheck(self.ppatspk,d1,d2,d3,proof))