The test for double SHA512

This commit is contained in:
Dmitri Bogomolov 2021-07-29 22:18:16 +03:00 committed by Lee Miller
parent 3ed84a5863
commit 7348568c78
Signed by untrusted user: lee.miller
GPG Key ID: 4F97A5EA88F4AB63
2 changed files with 13 additions and 0 deletions

View File

@ -2,6 +2,12 @@
from binascii import unhexlify from binascii import unhexlify
# hello, page 1 of the Specification
sample_hash_data = b'hello'
sample_double_sha512 = unhexlify(
'0592a10584ffabf96539f3d780d776828c67da1ab5b169e9e8aed838aaecc9ed36d49ff14'
'23c55f019e050c66c6324f53588be88894fef4dcffdb74b98e2b200')
# 500 identical peers: # 500 identical peers:
# 1626611891, 1, 1, 127.0.0.1, 8444 # 1626611891, 1, 1, 127.0.0.1, 8444

View File

@ -17,6 +17,7 @@ except ImportError:
RIPEMD160 = None RIPEMD160 = None
from .samples import ( from .samples import (
sample_double_sha512, sample_hash_data,
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_sig, sample_sig_sha1
@ -66,6 +67,12 @@ class TestCrypto(RIPEMD160TestCase, unittest.TestCase):
class TestHighlevelcrypto(unittest.TestCase): class TestHighlevelcrypto(unittest.TestCase):
"""Test highlevelcrypto public functions""" """Test highlevelcrypto public functions"""
def test_double_sha512(self):
"""Reproduce the example on page 1 of the Specification"""
self.assertEqual(
highlevelcrypto.double_sha512(sample_hash_data),
sample_double_sha512)
def test_randomBytes(self): def test_randomBytes(self):
"""Dummy checks for random bytes""" """Dummy checks for random bytes"""
for n in (8, 32, 64): for n in (8, 32, 64):