Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Functions
zeth.core.proto_utils Namespace Reference

Functions

Dict[str, str] zeth_note_to_json_dict (ZethNote zeth_note_grpc_obj)
 
ZethNote zeth_note_from_json_dict (Dict[str, str] parsed_zeth_note)
 
bytes zeth_note_to_bytes (ZethNote zeth_note_grpc_obj)
 
ZethNote zeth_note_from_bytes (bytes note_bytes)
 

Function Documentation

◆ zeth_note_from_bytes()

ZethNote zeth.core.proto_utils.zeth_note_from_bytes ( bytes  note_bytes)

Definition at line 57 of file proto_utils.py.

57 def zeth_note_from_bytes(note_bytes: bytes) -> ZethNote:
58  if len(note_bytes) != (constants.NOTE_LENGTH_BYTES):
59  raise ValueError(
60  f"note_bytes len {len(note_bytes)}, "
61  f"(expected {constants.NOTE_LENGTH_BYTES})")
62  apk = note_bytes[
63  _APK_OFFSET_BYTES:_APK_OFFSET_BYTES + constants.APK_LENGTH_BYTES]
64  value = note_bytes[
65  _VALUE_OFFSET_BYTES:
66  _VALUE_OFFSET_BYTES + constants.PUBLIC_VALUE_LENGTH_BYTES]
67  rho = note_bytes[
68  _RHO_OFFSET_BYTES:_RHO_OFFSET_BYTES + constants.RHO_LENGTH_BYTES]
69  trap_r = note_bytes[_TRAPR_OFFSET_BYTES:]
70  return ZethNote(
71  apk=apk.hex(), value=value.hex(), rho=rho.hex(), trap_r=trap_r.hex())

◆ zeth_note_from_json_dict()

ZethNote zeth.core.proto_utils.zeth_note_from_json_dict ( Dict[str, str]  parsed_zeth_note)

Definition at line 37 of file proto_utils.py.

37 def zeth_note_from_json_dict(parsed_zeth_note: Dict[str, str]) -> ZethNote:
38  note = ZethNote(
39  apk=parsed_zeth_note["a_pk"],
40  value=parsed_zeth_note["value"],
41  rho=parsed_zeth_note["rho"],
42  trap_r=parsed_zeth_note["trap_r"]
43  )
44  return note
45 
46 
Here is the caller graph for this function:

◆ zeth_note_to_bytes()

bytes zeth.core.proto_utils.zeth_note_to_bytes ( ZethNote  zeth_note_grpc_obj)

Definition at line 47 of file proto_utils.py.

47 def zeth_note_to_bytes(zeth_note_grpc_obj: ZethNote) -> bytes:
48  apk_bytes = bytes.fromhex(zeth_note_grpc_obj.apk)
49  value_bytes = bytes.fromhex(zeth_note_grpc_obj.value)
50  rho_bytes = bytes.fromhex(zeth_note_grpc_obj.rho)
51  trap_r_bytes = bytes.fromhex(zeth_note_grpc_obj.trap_r)
52  note_bytes = apk_bytes + value_bytes + rho_bytes + trap_r_bytes
53  assert len(note_bytes) == (constants.NOTE_LENGTH_BYTES)
54  return note_bytes
55 
56 

◆ zeth_note_to_json_dict()

Dict[str, str] zeth.core.proto_utils.zeth_note_to_json_dict ( ZethNote  zeth_note_grpc_obj)

Definition at line 28 of file proto_utils.py.

28 def zeth_note_to_json_dict(zeth_note_grpc_obj: ZethNote) -> Dict[str, str]:
29  return {
30  "a_pk": zeth_note_grpc_obj.apk,
31  "value": zeth_note_grpc_obj.value,
32  "rho": zeth_note_grpc_obj.rho,
33  "trap_r": zeth_note_grpc_obj.trap_r,
34  }
35 
36 
Here is the caller graph for this function:
zeth.core.proto_utils.zeth_note_to_bytes
bytes zeth_note_to_bytes(ZethNote zeth_note_grpc_obj)
Definition: proto_utils.py:47
zeth.core.proto_utils.zeth_note_from_bytes
ZethNote zeth_note_from_bytes(bytes note_bytes)
Definition: proto_utils.py:57
zeth.core.proto_utils.zeth_note_from_json_dict
ZethNote zeth_note_from_json_dict(Dict[str, str] parsed_zeth_note)
Definition: proto_utils.py:37
zeth.core.proto_utils.zeth_note_to_json_dict
Dict[str, str] zeth_note_to_json_dict(ZethNote zeth_note_grpc_obj)
Definition: proto_utils.py:28