def _create_zeth_notes( phi: bytes, hsig: bytes, output0: Tuple[OwnershipPublicKey, int], output1: Tuple[OwnershipPublicKey, int]) -> Tuple[ZethNote, ZethNote]: """ Create two ordered ZethNotes. Used to generate new output notes to be passed to the prover server. """ (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) 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 _create_api_zeth_note(out_index: int, recipient: OwnershipPublicKey, value: int) -> api.ZethNote: rho = _compute_rho_i(phi, hsig, out_index) trap_r = _trap_r_randomness() return api.ZethNote(apk=ownership_key_as_hex(recipient), value=int64_to_hex(value), rho=rho.hex(), trap_r=trap_r)
def create_api_joinsplit_input(merkle_path: List[str], address: int, note: api.ZethNote, a_sk: OwnershipSecretKey, nullifier: bytes) -> api.JoinsplitInput: return api.JoinsplitInput(merkle_path=merkle_path, address=address, note=note, spending_ask=ownership_key_as_hex(a_sk), nullifier=nullifier.hex())
def __str__(self) -> str: """ Write the address as "<ownership-key-hex>:<encryption_key_hex>". (Technically the ":" is not required, since the first key is written with fixed length, but a separator provides some limited sanity checking). """ a_pk_hex = ownership_key_as_hex(self.a_pk) k_pk_hex = encryption_public_key_as_hex(self.k_pk) return f"{a_pk_hex}:{k_pk_hex}"
def get_dummy_input_and_address( a_pk: OwnershipPublicKey) -> Tuple[int, api.ZethNote]: """ Create a zeth note and address, for use as circuit inputs where there is no real input. """ dummy_note = api.ZethNote(apk=ownership_key_as_hex(a_pk), value=ZERO_UNITS_HEX, rho=_get_dummy_rho(), trap_r=_trap_r_randomness()) # Note that the Merkle path is not fully checked against the root by the # circuit since the note value is 0. Hence the address used here is # arbitrary. dummy_note_address = 0 return (dummy_note_address, dummy_note)
def _to_json_dict(self) -> Dict[str, Any]: return { "a_sk": ownership_key_as_hex(self.a_sk), "k_sk": encryption_secret_key_as_hex(self.k_sk), }