Luke Murphy 1 month ago
parent
commit
60a0ff1920
No account linked to committer's email address
2 changed files with 14 additions and 2 deletions
  1. 1
    1
      hypercore_crypto/crypto.py
  2. 13
    1
      test/test_crypto.py

+ 1
- 1
hypercore_crypto/crypto.py View File

@@ -131,7 +131,7 @@ def discovery_key(public_key: bytes) -> bytes:
131 131
 
132 132
     :param public_key: The public key for hashing
133 133
     """
134
-    return crypto_generichash(HYPERCORE, key=public_key)
134
+    return crypto_generichash(HYPERCORE, k=public_key)
135 135
 
136 136
 
137 137
 def _to_unsigned_64_int(num: int) -> bytes:

+ 13
- 1
test/test_crypto.py View File

@@ -4,7 +4,15 @@ import pytest
4 4
 from merkle_tree_stream import MerkleTreeNode
5 5
 from pysodium import crypto_sign_PUBLICKEYBYTES, crypto_sign_SECRETKEYBYTES
6 6
 
7
-from hypercore_crypto import data, key_pair, parent, random_bytes, sign, verify
7
+from hypercore_crypto import (
8
+    data,
9
+    discovery_key,
10
+    key_pair,
11
+    parent,
12
+    random_bytes,
13
+    sign,
14
+    verify,
15
+)
8 16
 
9 17
 
10 18
 def test_key_pair_seed_length():
@@ -59,3 +67,7 @@ def test_parent_digest():
59 67
         _parent.hex()
60 68
         == '43563406adba8b34b133fdca32d0a458c5be769615e01df30e6535ccd3c075f0'
61 69
     )
70
+
71
+
72
+def test_discovery_key_generated():
73
+    assert discovery_key(random_bytes(32)) is not None

Loading…
Cancel
Save