def build_proof(self, env, message=""):
        """Generates a proof within an environment of assigned public and secret variables."""

        self._check_env(env)

        # Do sanity check on the proofs
        if __debug__:
            for base, expr in self.proofs:
                xGen = base.val(env)
                xExpr = expr.val(env)
                try:
                    assert xGen == xExpr
                except:
                    raise Exception("Proof about '%s' does not hold." % base.name)

        G = self.G
        order = G.order()

        ## Make a list of all the public state
        state = ['ZKP', G.nid(), message]

        for v in sorted(self.Const.keys()):
            state += [env[v]]
        for v in sorted(self.Pub.keys()):
            state += [env[v]]

        ## Set witnesses for all secrets
        witnesses = dict(env.items())
        for w in self.Sec.keys():
            assert w in witnesses
            witnesses[w] = order.random()

        ## Compute the first message and add it to the state
        for base, expr in self.proofs:
            Cw = expr.val(witnesses)
            state += [Cw]

        ## Compute the challenge using all the state
        hash_c = challenge(state)
        c = Bn.from_binary(hash_c) % order

        ## Compute all the resources
        responses = dict(env.items())
        for w in self.Sec.keys():
            responses[w] = (witnesses[w] - c * env[w]) % order
         
        for v in self.Const:
           del responses[v]

        return (c, responses)
dataset/ETHPy150Open gdanezis/petlib/examples/genzkp.py/ZKProof.build_proof/original