예제 #1
0
파일: utils.py 프로젝트: clearmatics/zeth
def zeth_note_short(note_desc: ZethNoteDescription) -> str:
    """
    Generate a short human-readable description of a commitment.
    """
    value = from_zeth_units(int(note_desc.note.value, 16)).ether()
    cm = short_commitment(note_desc.commitment)
    return f"{cm}: value={value} ETH, addr={note_desc.address}"
예제 #2
0
    def receive_note(self, comm_addr: int,
                     out_ev: MixOutputEvents) -> Optional[ZethNoteDescription]:
        # Check this output event to see if it belongs to this wallet.
        our_note = receive_note(out_ev, self.k_sk_receiver)
        if our_note is None:
            return None

        (commit, note) = our_note
        if not _check_note(commit, note):
            return None

        note_desc = ZethNoteDescription(note, comm_addr, commit)
        self._write_note(note_desc)

        # Add the nullifier to the map in the state file
        nullifier = compute_nullifier(note_desc.note, self.a_sk)
        self.state.nullifier_map[nullifier.hex()] = \
            short_commitment(commit)
        return note_desc
예제 #3
0
 def _note_basename(self, note_desc: ZethNoteDescription) -> str:
     value_eth = from_zeth_units(int(note_desc.note.value, 16)).ether()
     cm_str = short_commitment(note_desc.commitment)
     return "note_%s_%04d_%s_%s" % (self.username, note_desc.address,
                                    cm_str, value_eth)