def get_mix_parameters_components( zeth_client: MixerClient, prover_client: ProverClient, mk_tree: MerkleTree, sender_ownership_keypair: OwnershipKeyPair, inputs: List[Tuple[int, ZethNote]], outputs: List[Tuple[ZethAddressPub, EtherValue]], v_in: EtherValue, v_out: EtherValue, compute_h_sig_cb: Optional[ComputeHSigCB] = None ) -> Tuple[ZethNote, ZethNote, ExtendedProof, List[int], JoinsplitSigKeyPair]: """ Manually create the components required for MixParameters. The tests below manipulate these to create custom MixParameters as part of attacks. """ mix_call_desc = MixCallDescription( mk_tree, sender_ownership_keypair, inputs, outputs, v_in, v_out, compute_h_sig_cb) prover_inputs, signing_keypair = zeth_client.create_prover_inputs( mix_call_desc) ext_proof, public_data = prover_client.get_proof(prover_inputs) return ( prover_inputs.js_outputs[0], prover_inputs.js_outputs[1], ext_proof, public_data, signing_keypair)
def create_mix_parameters_and_signing_key( self, prover_client: ProverClient, mk_tree: MerkleTree, sender_ownership_keypair: OwnershipKeyPair, sender_eth_address: str, inputs: List[Tuple[int, ZethNote]], outputs: List[Tuple[ZethAddressPub, EtherValue]], v_in: EtherValue, v_out: EtherValue, compute_h_sig_cb: Optional[ComputeHSigCB] = None ) -> Tuple[MixParameters, JoinsplitSigKeyPair]: """ Convenience function around creation of MixCallDescription, ProofInputs, Proof and MixParameters. """ # Generate prover inputs and signing key mix_call_desc = MixCallDescription(mk_tree, sender_ownership_keypair, inputs, outputs, v_in, v_out, compute_h_sig_cb) prover_inputs, signing_keypair = MixerClient.create_prover_inputs( mix_call_desc) zksnark = get_zksnark_provider(self.prover_config.zksnark_name) # Query the prover_server for the related proof ext_proof_proto = prover_client.get_proof(prover_inputs) ext_proof = zksnark.extended_proof_from_proto(ext_proof_proto) # Create the final MixParameters object mix_params = self.create_mix_parameters_from_proof( mix_call_desc, prover_inputs, signing_keypair, ext_proof, sender_eth_address) return mix_params, signing_keypair
def create_mix_parameters_and_signing_key( self, prover_client: ProverClient, mk_tree: MerkleTree, sender_ownership_keypair: OwnershipKeyPair, sender_eth_address: str, inputs: List[Tuple[int, api.ZethNote]], outputs: List[Tuple[ZethAddressPub, EtherValue]], v_in: EtherValue, v_out: EtherValue, compute_h_sig_cb: Optional[ComputeHSigCB] = None, for_dispatch_call: bool = False ) -> Tuple[MixParameters, JoinsplitSigKeyPair]: """ Convenience function around creation of MixCallDescription, ProofInputs, Proof and MixParameters. If for_dispatch_call is set, the parameters are to be passed to the Mixer's `dispatch` call in a later operation (in which proof data is not available), hence proof is ommitted from the signature. """ # Generate prover inputs and signing key mix_call_desc = MixCallDescription(mk_tree, sender_ownership_keypair, inputs, outputs, v_in, v_out, compute_h_sig_cb) assert len(mix_call_desc.inputs) == constants.JS_INPUTS assert len(mix_call_desc.outputs) == constants.JS_OUTPUTS prover_inputs, signing_keypair = MixerClient.create_prover_inputs( mix_call_desc) # pylint: disable=no-member assert len(prover_inputs.js_inputs) == constants.JS_INPUTS assert len(prover_inputs.js_outputs) == constants.JS_OUTPUTS # pylint: enable=no-member # Query the prover-server for the related proof ext_proof, public_data = prover_client.get_proof(prover_inputs) # Create the final MixParameters object mix_params = self.create_mix_parameters_from_proof( mix_call_desc, prover_inputs, signing_keypair, ext_proof, public_data, sender_eth_address, for_dispatch_call) return mix_params, signing_keypair