Skip to content

Commit 66cb016

Browse files
committed
Finished the test for deterministic keys:
this implementation requires a passphrase of type bytes
1 parent f005333 commit 66cb016

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/tests/samples.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
94730058721143827257669456336351159718085716196507891067256111928318063085006
3434
)
3535

36-
sample_seed = 'TIGER, tiger, burning bright. In the forests of the night'
37-
# RIPE hash on step
36+
sample_seed = b'TIGER, tiger, burning bright. In the forests of the night'
37+
# RIPE hash on step 22 with signing key nonce 42
3838
sample_deterministic_ripe = b'00cfb69416ae76f68a81c459de4e13460c7d17eb'
3939
# Deterministic addresses with stream 1 and versions 3, 4
4040
sample_deterministic_addr3 = 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'

src/tests/test_crypto.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,15 @@ def test_random_keys(self):
8787
self.assertEqual(len(priv), 32)
8888
self.assertEqual(highlevelcrypto.pointMult(priv), pub)
8989

90-
# def test_deterministic_keys(self):
91-
# """Generate deterministic keys, make ripe and compare it to sample"""
92-
# sigkey = highlevelcrypto.deterministic_keys(sample_seed, b'\x00')[1]
93-
# enkey = highlevelcrypto.deterministic_keys(sample_seed, b'\x01')[1]
94-
# self.assertEqual(
95-
# TestHashlib._hashdigest(sigkey + enkey), sample_deterministic_ripe)
90+
def test_deterministic_keys(self):
91+
"""Generate deterministic keys, make ripe and compare it to sample"""
92+
# encodeVarint(42) = b'*'
93+
sigkey = highlevelcrypto.deterministic_keys(sample_seed, b'*')[1]
94+
enkey = highlevelcrypto.deterministic_keys(sample_seed, b'+')[1]
95+
self.assertEqual(
96+
sample_deterministic_ripe,
97+
hexlify(TestHashlib._hashdigest(
98+
hashlib.sha512(sigkey + enkey).digest())))
9699

97100
def test_verify(self):
98101
"""Verify sample signatures and newly generated ones"""

0 commit comments

Comments
 (0)