Example #1
0
def get_mix_parameters_components(
    zeth_client: MixerClient,
    prover_client: ProverClient,
    zksnark: IZKSnarkProvider,
    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, 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_proto = prover_client.get_proof(prover_inputs)
    ext_proof = zksnark.extended_proof_from_proto(ext_proof_proto)
    return (prover_inputs.js_outputs[0], prover_inputs.js_outputs[1],
            ext_proof, signing_keypair)
Example #2
0
def aggregated_transaction_from_proto(
    zksnark: IZKSnarkProvider,
    aggregated_transaction_proto: aggregator_pb2.AggregatedTransaction
) -> AggregatedTransaction:
    """
    Convert a generic protobuf AggregatedTransactionRequest to an in-memory
    AggregatedTransaction
    """
    app_name = aggregated_transaction_proto.application_name
    extproof = zksnark.extended_proof_from_proto(
        aggregated_transaction_proto.extended_proof)
    nested_parameters = list(aggregated_transaction_proto.nested_parameters)
    return AggregatedTransaction(app_name, extproof, nested_parameters)
Example #3
0
 def _do_test_ext_proof_proto_encode_decode(
         self, proof: ExtendedProof, snark: IZKSnarkProvider) -> None:
     proof_proto = snark.extended_proof_to_proto(proof)
     proof_decoded = snark.extended_proof_from_proto(proof_proto)
     self.assertEqual(proof.to_json_dict(), proof_decoded.to_json_dict())