fix to pass tests.py
* deterministic_keys() now accepts both str and bytes for passphrase. * The test for RandomTrackingDict is modified to use bytes for random keys.
This commit is contained in:
parent
bc254a935e
commit
3f808fbcd7
|
@ -85,7 +85,12 @@ def random_keys():
|
|||
|
||||
def deterministic_keys(passphrase, nonce):
|
||||
"""Generate keys from *passphrase* and *nonce* (encoded as varint)"""
|
||||
priv = hashlib.sha512(passphrase.encode() + nonce).digest()[:32]
|
||||
if isinstance(passphrase, str):
|
||||
ph = passphrase.encode()
|
||||
else:
|
||||
ph = passphrase
|
||||
priv = hashlib.sha512(ph + nonce).digest()[:32]
|
||||
|
||||
pub = pointMult(priv)
|
||||
return priv, pub
|
||||
|
||||
|
|
|
@ -15,10 +15,10 @@ class TestRandomTrackingDict(unittest.TestCase):
|
|||
@staticmethod
|
||||
def randString():
|
||||
"""helper function for tests, generates a random string"""
|
||||
retval = ''
|
||||
for _ in range(32):
|
||||
retval += chr(random.randint(0, 255))
|
||||
return retval
|
||||
retval = bytearray(32)
|
||||
for i in range(32):
|
||||
retval[i] = random.randint(0, 255)
|
||||
return bytes(retval)
|
||||
|
||||
def test_check_randomtrackingdict(self):
|
||||
"""Check the logic of RandomTrackingDict class"""
|
||||
|
|
Reference in New Issue
Block a user