예제 #1
0
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
예제 #2
0
def create_joinsplit_input(merkle_path: List[str], address: int,
                           note: ZethNote, a_sk: OwnershipSecretKey,
                           nullifier: bytes) -> JoinsplitInput:
    return JoinsplitInput(merkle_path=merkle_path,
                          address=address,
                          note=note,
                          spending_ask=ownership_key_as_hex(a_sk),
                          nullifier=nullifier.hex())
예제 #3
0
 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}"
예제 #4
0
파일: joinsplit.py 프로젝트: umlspec/zeth
def get_dummy_input_and_address(
        a_pk: OwnershipPublicKey) -> Tuple[int, ZethNote]:
    """
    Create a zeth note and address, for use as circuit inputs where there is no
    real input.
    """
    dummy_note = ZethNote(apk=ownership_key_as_hex(a_pk),
                          value=ZERO_UNITS_HEX,
                          rho=get_dummy_rho(),
                          trap_r=trap_r_randomness())
    dummy_note_address = 7
    return (dummy_note_address, dummy_note)
예제 #5
0
def get_dummy_input_and_address(
        a_pk: OwnershipPublicKey) -> Tuple[int, ZethNote]:
    """
    Create a zeth note and address, for use as circuit inputs where there is no
    real input.
    """
    dummy_note = 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)
예제 #6
0
 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),
     }