Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Functions | Variables
coordinator.crypto Namespace Reference

Functions

str export_digest (bytes digest)
 
bytes import_digest (str digest_s)
 
ecdsa.SigningKey generate_signing_key ()
 
bytes export_signing_key (ecdsa.SigningKey sk)
 
ecdsa.SigningKey import_signing_key (bytes sk_b)
 
ecdsa.VerifyingKey get_verification_key (ecdsa.SigningKey sk)
 
str export_verification_key (ecdsa.VerifyingKey vk)
 
ecdsa.VerifyingKey import_verification_key (str vk_s)
 
str export_signature (bytes sig)
 
bytes import_signature (str sig_s)
 
bytes compute_file_digest (str file_name)
 
bytes sign (ecdsa.SigningKey sk, bytes digest)
 
bool verify (bytes sig, ecdsa.VerifyingKey vk, bytes digest)
 
Signature create_key_evidence (ecdsa.SigningKey key)
 
bool check_key_evidence (ecdsa.VerificationKey verification_key, Signature key_evidence)
 

Variables

 HASH = SHA512
 
int HASH_BYTE_LENGTH = 64
 
 CURVE = ecdsa.NIST521p
 
 VerificationKey = ecdsa.VerifyingKey
 
 SigningKey = ecdsa.SigningKey
 
 Signature = bytes
 
int HASH_FILE_BLOCK_SIZE = 4096
 

Function Documentation

◆ check_key_evidence()

bool coordinator.crypto.check_key_evidence ( ecdsa.VerificationKey  verification_key,
Signature  key_evidence 
)

Definition at line 107 of file crypto.py.

108  verification_key: ecdsa.VerificationKey, # pylint: disable=no-member
109  key_evidence: Signature) -> bool:
110  return verify(key_evidence, verification_key, KEY_VALIDATION_CHECK_DIGEST)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_file_digest()

bytes coordinator.crypto.compute_file_digest ( str  file_name)

Definition at line 82 of file crypto.py.

82 def compute_file_digest(file_name: str) -> bytes:
83  h = HASH.new()
84  with open(file_name, "rb") as file_f:
85  while True:
86  block = file_f.read(HASH_FILE_BLOCK_SIZE)
87  if not block:
88  return h.digest()
89  h.update(block)
90 
91 

◆ create_key_evidence()

Signature coordinator.crypto.create_key_evidence ( ecdsa.SigningKey  key)

Definition at line 103 of file crypto.py.

103 def create_key_evidence(key: ecdsa.SigningKey) -> Signature:
104  return sign(key, KEY_VALIDATION_CHECK_DIGEST)
105 
106 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ export_digest()

str coordinator.crypto.export_digest ( bytes  digest)
Digest to string

Definition at line 32 of file crypto.py.

32 def export_digest(digest: bytes) -> str:
33  """
34  Digest to string
35  """
36  assert len(digest) == HASH_BYTE_LENGTH
37  return digest.hex()
38 
39 
Here is the caller graph for this function:

◆ export_signature()

str coordinator.crypto.export_signature ( bytes  sig)

Definition at line 74 of file crypto.py.

74 def export_signature(sig: bytes) -> str:
75  return sig.hex()
76 
77 
Here is the caller graph for this function:

◆ export_signing_key()

bytes coordinator.crypto.export_signing_key ( ecdsa.SigningKey  sk)

Definition at line 54 of file crypto.py.

54 def export_signing_key(sk: ecdsa.SigningKey) -> bytes:
55  return sk.to_der()
56 
57 

◆ export_verification_key()

str coordinator.crypto.export_verification_key ( ecdsa.VerifyingKey  vk)

Definition at line 66 of file crypto.py.

66 def export_verification_key(vk: ecdsa.VerifyingKey) -> str:
67  return vk.to_der().hex()
68 
69 
Here is the caller graph for this function:

◆ generate_signing_key()

ecdsa.SigningKey coordinator.crypto.generate_signing_key ( )

Definition at line 50 of file crypto.py.

50 def generate_signing_key() -> ecdsa.SigningKey:
51  return ecdsa.SigningKey.generate(curve=CURVE)
52 
53 

◆ get_verification_key()

ecdsa.VerifyingKey coordinator.crypto.get_verification_key ( ecdsa.SigningKey  sk)

Definition at line 62 of file crypto.py.

62 def get_verification_key(sk: ecdsa.SigningKey) -> ecdsa.VerifyingKey:
63  return sk.get_verifying_key()
64 
65 

◆ import_digest()

bytes coordinator.crypto.import_digest ( str  digest_s)
Digest from string

Definition at line 40 of file crypto.py.

40 def import_digest(digest_s: str) -> bytes:
41  """
42  Digest from string
43  """
44  if len(digest_s) != 2 * HASH_BYTE_LENGTH:
45  raise Exception(f"unexpected digest string length: {len(digest_s)}")
46  assert len(digest_s) == 2 * HASH_BYTE_LENGTH
47  return bytes.fromhex(digest_s)
48 
49 
Here is the caller graph for this function:

◆ import_signature()

bytes coordinator.crypto.import_signature ( str  sig_s)

Definition at line 78 of file crypto.py.

78 def import_signature(sig_s: str) -> bytes:
79  return bytes.fromhex(sig_s)
80 
81 
Here is the caller graph for this function:

◆ import_signing_key()

ecdsa.SigningKey coordinator.crypto.import_signing_key ( bytes  sk_b)

Definition at line 58 of file crypto.py.

58 def import_signing_key(sk_b: bytes) -> ecdsa.SigningKey:
59  return ecdsa.SigningKey.from_der(sk_b)
60 
61 
Here is the caller graph for this function:

◆ import_verification_key()

ecdsa.VerifyingKey coordinator.crypto.import_verification_key ( str  vk_s)

Definition at line 70 of file crypto.py.

70 def import_verification_key(vk_s: str) -> ecdsa.VerifyingKey:
71  return ecdsa.VerifyingKey.from_der(bytes.fromhex(vk_s))
72 
73 
Here is the caller graph for this function:

◆ sign()

bytes coordinator.crypto.sign ( ecdsa.SigningKey  sk,
bytes  digest 
)

Definition at line 92 of file crypto.py.

92 def sign(sk: ecdsa.SigningKey, digest: bytes) -> bytes:
93  return sk.sign_digest(digest)
94 
95 
Here is the caller graph for this function:

◆ verify()

bool coordinator.crypto.verify ( bytes  sig,
ecdsa.VerifyingKey  vk,
bytes  digest 
)

Definition at line 96 of file crypto.py.

96 def verify(sig: bytes, vk: ecdsa.VerifyingKey, digest: bytes) -> bool:
97  try:
98  return vk.verify_digest(sig, digest)
99  except Exception:
100  return False
101 
102 
Here is the caller graph for this function:

Variable Documentation

◆ CURVE

coordinator.crypto.CURVE = ecdsa.NIST521p

Definition at line 14 of file crypto.py.

◆ HASH

coordinator.crypto.HASH = SHA512

Definition at line 12 of file crypto.py.

◆ HASH_BYTE_LENGTH

int coordinator.crypto.HASH_BYTE_LENGTH = 64

Definition at line 13 of file crypto.py.

◆ HASH_FILE_BLOCK_SIZE

int coordinator.crypto.HASH_FILE_BLOCK_SIZE = 4096

Definition at line 19 of file crypto.py.

◆ Signature

coordinator.crypto.Signature = bytes

Definition at line 17 of file crypto.py.

◆ SigningKey

coordinator.crypto.SigningKey = ecdsa.SigningKey

Definition at line 16 of file crypto.py.

◆ VerificationKey

coordinator.crypto.VerificationKey = ecdsa.VerifyingKey

Definition at line 15 of file crypto.py.

coordinator.crypto.import_signing_key
ecdsa.SigningKey import_signing_key(bytes sk_b)
Definition: crypto.py:58
coordinator.crypto.export_signature
str export_signature(bytes sig)
Definition: crypto.py:74
coordinator.crypto.export_verification_key
str export_verification_key(ecdsa.VerifyingKey vk)
Definition: crypto.py:66
coordinator.crypto.compute_file_digest
bytes compute_file_digest(str file_name)
Definition: crypto.py:82
coordinator.crypto.sign
bytes sign(ecdsa.SigningKey sk, bytes digest)
Definition: crypto.py:92
coordinator.crypto.import_digest
bytes import_digest(str digest_s)
Definition: crypto.py:40
coordinator.crypto.import_verification_key
ecdsa.VerifyingKey import_verification_key(str vk_s)
Definition: crypto.py:70
coordinator.crypto.check_key_evidence
bool check_key_evidence(ecdsa.VerificationKey verification_key, Signature key_evidence)
Definition: crypto.py:107
coordinator.crypto.get_verification_key
ecdsa.VerifyingKey get_verification_key(ecdsa.SigningKey sk)
Definition: crypto.py:62
coordinator.crypto.generate_signing_key
ecdsa.SigningKey generate_signing_key()
Definition: crypto.py:50
coordinator.crypto.export_digest
str export_digest(bytes digest)
Definition: crypto.py:32
coordinator.crypto.import_signature
bytes import_signature(str sig_s)
Definition: crypto.py:78
coordinator.crypto.verify
bool verify(bytes sig, ecdsa.VerifyingKey vk, bytes digest)
Definition: crypto.py:96
coordinator.crypto.export_signing_key
bytes export_signing_key(ecdsa.SigningKey sk)
Definition: crypto.py:54
coordinator.crypto.create_key_evidence
Signature create_key_evidence(ecdsa.SigningKey key)
Definition: crypto.py:103