|
17 | 17 | RIPEMD160 = None |
18 | 18 |
|
19 | 19 | from .samples import ( |
20 | | - sample_double_sha512, sample_hash_data, |
| 20 | + sample_deterministic_ripe, sample_double_sha512, sample_hash_data, |
21 | 21 | sample_msg, sample_pubsigningkey, sample_pubencryptionkey, |
22 | 22 | sample_privsigningkey, sample_privencryptionkey, sample_ripe, |
23 | | - sample_sig, sample_sig_sha1 |
| 23 | + sample_seed, sample_sig, sample_sig_sha1 |
24 | 24 | ) |
25 | 25 |
|
26 | 26 |
|
@@ -81,6 +81,22 @@ def test_randomBytes(self): |
81 | 81 | self.assertNotEqual(len(set(data)), 1) |
82 | 82 | self.assertNotEqual(data, highlevelcrypto.randomBytes(n)) |
83 | 83 |
|
| 84 | + def test_random_keys(self): |
| 85 | + """Dummy checks for random keys""" |
| 86 | + priv, pub = highlevelcrypto.random_keys() |
| 87 | + self.assertEqual(len(priv), 32) |
| 88 | + self.assertEqual(highlevelcrypto.pointMult(priv), pub) |
| 89 | + |
| 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()))) |
| 99 | + |
84 | 100 | def test_signatures(self): |
85 | 101 | """Verify sample signatures and newly generated ones""" |
86 | 102 | pubkey_hex = hexlify(sample_pubsigningkey) |
|
0 commit comments