Refactor using of crypto functions #1796
|
@ -33,9 +33,10 @@ sample_point = (
|
||||||
94730058721143827257669456336351159718085716196507891067256111928318063085006
|
94730058721143827257669456336351159718085716196507891067256111928318063085006
|
||||||
)
|
)
|
||||||
|
|
||||||
sample_seed = 'TIGER, tiger, burning bright. In the forests of the night'
|
sample_seed = b'TIGER, tiger, burning bright. In the forests of the night'
|
||||||
# Deterministic addresses with stream 1 and versions 3, 4
|
# RIPE hash on step 22 with signing key nonce 42
|
||||||
sample_deterministic_ripe = b'00cfb69416ae76f68a81c459de4e13460c7d17eb'
|
sample_deterministic_ripe = b'00cfb69416ae76f68a81c459de4e13460c7d17eb'
|
||||||
|
# Deterministic addresses with stream 1 and versions 3, 4
|
||||||
sample_deterministic_addr3 = 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
sample_deterministic_addr3 = 'BM-2DBPTgeSawWYZceFD69AbDT5q4iUWtj1ZN'
|
||||||
sample_deterministic_addr4 = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
sample_deterministic_addr4 = 'BM-2cWzSnwjJ7yRP3nLEWUV5LisTZyREWSzUK'
|
||||||
sample_daddr3_512 = 18875720106589866286514488037355423395410802084648916523381
|
sample_daddr3_512 = 18875720106589866286514488037355423395410802084648916523381
|
||||||
|
|
|
@ -16,10 +16,10 @@ except ImportError:
|
||||||
RIPEMD = None
|
RIPEMD = None
|
||||||
|
|
||||||
from .samples import (
|
from .samples import (
|
||||||
sample_double_sha512,
|
sample_deterministic_ripe, sample_double_sha512,
|
||||||
sample_msg, sample_pubsigningkey, sample_pubencryptionkey,
|
sample_msg, sample_pubsigningkey, sample_pubencryptionkey,
|
||||||
sample_privsigningkey, sample_privencryptionkey, sample_ripe,
|
sample_privsigningkey, sample_privencryptionkey, sample_ripe,
|
||||||
sample_sig, sample_sig_sha1
|
sample_seed, sample_sig, sample_sig_sha1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,6 +82,22 @@ class TestHighlevelcrypto(unittest.TestCase):
|
||||||
self.assertNotEqual(len(set(data)), 1)
|
self.assertNotEqual(len(set(data)), 1)
|
||||||
self.assertNotEqual(data, highlevelcrypto.randomBytes(n))
|
self.assertNotEqual(data, highlevelcrypto.randomBytes(n))
|
||||||
|
|
||||||
|
def test_random_keys(self):
|
||||||
|
"""Dummy checks for random keys"""
|
||||||
|
priv, pub = highlevelcrypto.random_keys()
|
||||||
|
self.assertEqual(len(priv), 32)
|
||||||
|
|||||||
|
self.assertEqual(highlevelcrypto.pointMult(priv), pub)
|
||||||
|
|
||||||
|
def test_deterministic_keys(self):
|
||||||
|
"""Generate deterministic keys, make ripe and compare it to sample"""
|
||||||
|
# encodeVarint(42) = b'*'
|
||||||
|
sigkey = highlevelcrypto.deterministic_keys(sample_seed, b'*')[1]
|
||||||
|
enkey = highlevelcrypto.deterministic_keys(sample_seed, b'+')[1]
|
||||||
|
self.assertEqual(
|
||||||
|
sample_deterministic_ripe,
|
||||||
|
hexlify(TestHashlib._hashdigest(
|
||||||
|
hashlib.sha512(sigkey + enkey).digest())))
|
||||||
|
|
||||||
def test_verify(self):
|
def test_verify(self):
|
||||||
"""Verify sample signatures and newly generated ones"""
|
"""Verify sample signatures and newly generated ones"""
|
||||||
pubkey_hex = hexlify(sample_pubsigningkey)
|
pubkey_hex = hexlify(sample_pubsigningkey)
|
||||||
|
|
Reference in New Issue
Block a user
ideally
b'hello'
should also be a variable in samplesIt's from here: https://pybitmessage-test.readthedocs.io/en/doc/protocol.html#hashes