Zeth - Zerocash on Ethereum
0.8
Reference implementation of the Zeth protocol by Clearmatics
|
◆ 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,
109 key_evidence: Signature) -> bool:
110 return verify(key_evidence, verification_key, KEY_VALIDATION_CHECK_DIGEST)
◆ compute_file_digest()
bytes coordinator.crypto.compute_file_digest |
( |
str |
file_name | ) |
|
Definition at line 82 of file crypto.py.
84 with open(file_name,
"rb")
as file_f:
86 block = file_f.read(HASH_FILE_BLOCK_SIZE)
◆ create_key_evidence()
Signature coordinator.crypto.create_key_evidence |
( |
ecdsa.SigningKey |
key | ) |
|
Definition at line 103 of file crypto.py.
104 return sign(key, KEY_VALIDATION_CHECK_DIGEST)
◆ export_digest()
str coordinator.crypto.export_digest |
( |
bytes |
digest | ) |
|
Digest to string
Definition at line 32 of file crypto.py.
36 assert len(digest) == HASH_BYTE_LENGTH
◆ export_signature()
str coordinator.crypto.export_signature |
( |
bytes |
sig | ) |
|
◆ export_signing_key()
bytes coordinator.crypto.export_signing_key |
( |
ecdsa.SigningKey |
sk | ) |
|
◆ export_verification_key()
str coordinator.crypto.export_verification_key |
( |
ecdsa.VerifyingKey |
vk | ) |
|
Definition at line 66 of file crypto.py.
67 return vk.to_der().hex()
◆ generate_signing_key()
ecdsa.SigningKey coordinator.crypto.generate_signing_key |
( |
| ) |
|
Definition at line 50 of file crypto.py.
51 return ecdsa.SigningKey.generate(curve=CURVE)
◆ get_verification_key()
ecdsa.VerifyingKey coordinator.crypto.get_verification_key |
( |
ecdsa.SigningKey |
sk | ) |
|
Definition at line 62 of file crypto.py.
63 return sk.get_verifying_key()
◆ import_digest()
bytes coordinator.crypto.import_digest |
( |
str |
digest_s | ) |
|
Digest from string
Definition at line 40 of file crypto.py.
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)
◆ import_signature()
bytes coordinator.crypto.import_signature |
( |
str |
sig_s | ) |
|
Definition at line 78 of file crypto.py.
79 return bytes.fromhex(sig_s)
◆ import_signing_key()
ecdsa.SigningKey coordinator.crypto.import_signing_key |
( |
bytes |
sk_b | ) |
|
Definition at line 58 of file crypto.py.
59 return ecdsa.SigningKey.from_der(sk_b)
◆ import_verification_key()
ecdsa.VerifyingKey coordinator.crypto.import_verification_key |
( |
str |
vk_s | ) |
|
Definition at line 70 of file crypto.py.
71 return ecdsa.VerifyingKey.from_der(bytes.fromhex(vk_s))
◆ 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)
◆ 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:
98 return vk.verify_digest(sig, digest)
◆ CURVE
coordinator.crypto.CURVE = ecdsa.NIST521p |
◆ HASH
coordinator.crypto.HASH = SHA512 |
◆ HASH_BYTE_LENGTH
int coordinator.crypto.HASH_BYTE_LENGTH = 64 |
◆ HASH_FILE_BLOCK_SIZE
int coordinator.crypto.HASH_FILE_BLOCK_SIZE = 4096 |
◆ Signature
coordinator.crypto.Signature = bytes |
◆ SigningKey
coordinator.crypto.SigningKey = ecdsa.SigningKey |
◆ VerificationKey
coordinator.crypto.VerificationKey = ecdsa.VerifyingKey |
ecdsa.SigningKey import_signing_key(bytes sk_b)
str export_signature(bytes sig)
str export_verification_key(ecdsa.VerifyingKey vk)
bytes compute_file_digest(str file_name)
bytes sign(ecdsa.SigningKey sk, bytes digest)
bytes import_digest(str digest_s)
ecdsa.VerifyingKey import_verification_key(str vk_s)
bool check_key_evidence(ecdsa.VerificationKey verification_key, Signature key_evidence)
ecdsa.VerifyingKey get_verification_key(ecdsa.SigningKey sk)
ecdsa.SigningKey generate_signing_key()
str export_digest(bytes digest)
bytes import_signature(str sig_s)
bool verify(bytes sig, ecdsa.VerifyingKey vk, bytes digest)
bytes export_signing_key(ecdsa.SigningKey sk)
Signature create_key_evidence(ecdsa.SigningKey key)