Exemplo n.º 1
0
 def test_geq_proof_on_commitment(self):
     m1 = randint(1,self.maxmessage)
     m2 = randint(1,m1)
     com1, r1 = self.ppatspk.commit(m1)
     com2, r2 = self.ppatspk.commit(m2)
     gproof = nizk.geqProof(self.ppatspk,com1,m1,r1,com2,m2,r2,self.maxexp)
     res = nizk.geqProofCheck(self.ppatspk,com1,com2,gproof,self.maxexp)
     self.assertTrue(res)
Exemplo n.º 2
0
 def test_geq_proof_on_commitment(self):
     m1 = randint(1,self.maxmessage)
     m2 = randint(1,m1)
     com1, r1 = self.ppatspk.commit(m1)
     com2, r2 = self.ppatspk.commit(m2)
     gproof = nizk.geqProof(self.ppatspk,com1,m1,r1,com2,m2,r2,self.maxexp)
     res = nizk.geqProofCheck(self.ppatspk,com1,com2,gproof,self.maxexp)
     self.assertTrue(res)
Exemplo n.º 3
0
    def sort(self, printing=False):
        L = []
        for g in self.circuit.gates:
            if 'recommitedInput' in g.label:
                m = g.valuedict['message']
                L.append((m, g))
        L.sort()
        L.reverse()
        tempoutputs = []

        for m, gate in L:
            #ngate = gate.copy()
            #a,b = ngate.label
            #ngate.label = ('output',b)
            #ngate.inputs = [gate]
            tempoutputs.append(gate)

        #outputs = tempoutputs
        outputs = []
        #order = self.publicKey.PPATSpp.order
        maxexp = self.publicKey.maxexp

        for i in range(len(tempoutputs) - 1):
            currentgate = tempoutputs[i]
            nextgate = tempoutputs[i + 1]
            currentm = currentgate.valuedict['message']
            nextm = nextgate.valuedict['message']
            currentcom = currentgate.valuedict['commitment']
            nextcom = nextgate.valuedict['commitment']
            currentopening = currentgate.valuedict['openingclear']
            nextopening = nextgate.valuedict['openingclear']

            #newm = (nextm-currentm)%order
            newcom = nextcom - currentcom
            newopening = nextopening - currentopening
            geqPr = nizk.geqProof(self.publicKey, currentcom, currentm,
                                  currentopening, nextcom, nextm, nextopening,
                                  maxexp)

            newvaluedict = {'commitment': newcom, 'openingclear': newopening}
            newproofdict = {'geqproof': geqPr}
            newgate = Gate([nextgate, currentgate], ('output', str(i)),
                           'sub',
                           valuedict=newvaluedict,
                           proofdict=newproofdict)
            outputs.append(newgate)
            if printing: print "gate sub ", str(i), " added"

        self.circuit.outputs = outputs
        self.circuit.gates = self.circuit.gates + outputs
Exemplo n.º 4
0
    def sort(self, printing=False):
        L = []
        for g in self.circuit.gates:
            if "recommitedInput" in g.label:
                m = g.valuedict["message"]
                L.append((m, g))
        L.sort()
        L.reverse()
        tempoutputs = []

        for m, gate in L:
            # ngate = gate.copy()
            # a,b = ngate.label
            # ngate.label = ('output',b)
            # ngate.inputs = [gate]
            tempoutputs.append(gate)

        # outputs = tempoutputs
        outputs = []
        # order = self.publicKey.PPATSpp.order
        maxexp = self.publicKey.maxexp

        for i in range(len(tempoutputs) - 1):
            currentgate = tempoutputs[i]
            nextgate = tempoutputs[i + 1]
            currentm = currentgate.valuedict["message"]
            nextm = nextgate.valuedict["message"]
            currentcom = currentgate.valuedict["commitment"]
            nextcom = nextgate.valuedict["commitment"]
            currentopening = currentgate.valuedict["openingclear"]
            nextopening = nextgate.valuedict["openingclear"]

            # newm = (nextm-currentm)%order
            newcom = nextcom - currentcom
            newopening = nextopening - currentopening
            geqPr = nizk.geqProof(
                self.publicKey, currentcom, currentm, currentopening, nextcom, nextm, nextopening, maxexp
            )

            newvaluedict = {"commitment": newcom, "openingclear": newopening}
            newproofdict = {"geqproof": geqPr}
            newgate = Gate(
                [nextgate, currentgate], ("output", str(i)), "sub", valuedict=newvaluedict, proofdict=newproofdict
            )
            outputs.append(newgate)
            if printing:
                print "gate sub ", str(i), " added"

        self.circuit.outputs = outputs
        self.circuit.gates = self.circuit.gates + outputs