def create_zeth_notes( phi: str, hsig: bytes, output0: Tuple[OwnershipPublicKey, int], output1: Tuple[OwnershipPublicKey, int]) -> Tuple[ZethNote, ZethNote]: """ Create two ordered ZethNotes. This function is used to generate new output notes. """ (recipient0, value0) = output0 (recipient1, value1) = output1 rho0 = _compute_rho_i(phi, hsig, 0) trap_r0 = trap_r_randomness() note0 = ZethNote(apk=ownership_key_as_hex(recipient0), value=int64_to_hex(value0), rho=rho0.hex(), trap_r=trap_r0) rho1 = _compute_rho_i(phi, hsig, 1) print("rho1: ", rho1.hex()) trap_r1 = trap_r_randomness() note1 = ZethNote(apk=ownership_key_as_hex(recipient1), value=int64_to_hex(value1), rho=rho1.hex(), trap_r=trap_r1) return note0, note1
def compute_joinsplit2x2_inputs( mk_roots: List[bytes], input0: Tuple[int, ZethNote], mk_path0: List[str], input1: Tuple[int, ZethNote], mk_path1: List[str], sender_ask: OwnershipSecretKey, output0: Tuple[OwnershipPublicKey, int], output1: Tuple[OwnershipPublicKey, int], public_in_value_zeth_units: int, public_out_value_zeth_units: int, sign_vk: JoinsplitSigVerificationKey, compute_h_sig_cb: Optional[ComputeHSigCB] = None) -> ProofInputs: """ Create a ProofInput object for joinsplit parameters """ (input_address0, input_note0) = input0 (input_address1, input_note1) = input1 input_nullifier0 = compute_nullifier(input_note0, sender_ask) input_nullifier1 = compute_nullifier(input_note1, sender_ask) js_inputs: List[JoinsplitInput] = [ create_joinsplit_input(mk_path0, input_address0, input_note0, sender_ask, input_nullifier0), create_joinsplit_input(mk_path1, input_address1, input_note1, sender_ask, input_nullifier1) ] # Use the specified or default h_sig computation compute_h_sig_cb = compute_h_sig_cb or compute_h_sig h_sig = compute_h_sig_cb(input_nullifier0, input_nullifier1, sign_vk) phi = _phi_randomness() output_note0, output_note1 = create_zeth_notes(phi, h_sig, output0, output1) js_outputs = [output_note0, output_note1] merkle_roots = [] for mk_root in mk_roots: merkle_roots.append(mk_root.hex()) return ProofInputs(mk_roots=merkle_roots, js_inputs=js_inputs, js_outputs=js_outputs, pub_in_value=int64_to_hex(public_in_value_zeth_units), pub_out_value=int64_to_hex(public_out_value_zeth_units), h_sig=h_sig.hex(), phi=phi)