Example #1
0
def _proof_and_inputs_to_bytes(snark: IZKSnarkProvider, pp: PairingParameters,
                               extproof: ExtendedProof) -> Tuple[bytes, bytes]:
    """
    Given a proof object, compute the byte encodings of the properties
    excluding "inputs", and the byte encoding of the "inputs". These are used
    when hashing the mixer call parameters for signing, so must match what
    happens in the mixer contract.
    """
    # TODO: avoid duplicating this encoding to evm parameters
    proof = extproof.proof
    return \
        message_to_bytes(snark.proof_to_contract_parameters(proof, pp)), \
        message_to_bytes(hex_list_to_uint256_list(extproof.inputs))
Example #2
0
def deposit_parameters_to_contract_arguments(
        zksnark: IZKSnarkProvider, pp: PairingParameters,
        deposit_parameters: DepositParameters) -> List[Any]:
    """
    Convert DepositParameters to a list of eth ABI objects which can be passed to
    the contract's deposit method.
    """
    proof_contract_params = zksnark.proof_to_contract_parameters(
        deposit_parameters.proof, pp)
    return [
        proof_contract_params, deposit_parameters.proof,
        deposit_parameters.zklay_address, deposit_parameters.amount,
        deposit_parameters.ciphertexts
    ]
Example #3
0
def mix_parameters_to_contract_arguments(
        zksnark: IZKSnarkProvider, pp: PairingParameters,
        mix_parameters: MixParameters) -> List[Any]:
    """
    Convert MixParameters to a list of eth ABI objects which can be passed to
    the contract's mix method.
    """
    proof_contract_params = zksnark.proof_to_contract_parameters(
        mix_parameters.extended_proof.proof, pp)
    return [
        proof_contract_params,
        signing.verification_key_as_mix_parameter(mix_parameters.signature_vk),
        signing.signature_as_mix_parameter(mix_parameters.signature),
        mix_parameters.public_data,
        mix_parameters.ciphertexts,
    ]