diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2020-05-31 20:31:17 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2020-07-16 18:10:48 +0200 |
commit | 0e2b400fea890e769b75da5b55fa1902fd9f9851 (patch) | |
tree | ee06bec6183254a1bb0452d4abe15105b219bae0 /test/functional/test_framework | |
parent | b85543cb7361d6ba27c0eeca756eec9fd5395b36 (diff) |
test: Add basic Python/C++ Muhash implementation parity unit test
Diffstat (limited to 'test/functional/test_framework')
-rw-r--r-- | test/functional/test_framework/muhash.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/functional/test_framework/muhash.py b/test/functional/test_framework/muhash.py index 7dfce1b756..70a3cc53a0 100644 --- a/test/functional/test_framework/muhash.py +++ b/test/functional/test_framework/muhash.py @@ -4,6 +4,7 @@ """Native Python MuHash3072 implementation.""" import hashlib +import unittest from .util import modinv @@ -88,3 +89,13 @@ class MuHash3072: val = (self.numerator * modinv(self.denominator, self.MODULUS)) % self.MODULUS bytes384 = val.to_bytes(384, 'little') return hashlib.sha256(bytes384).digest() + +class TestFrameworkMuhash(unittest.TestCase): + def test_muhash(self): + muhash = MuHash3072() + muhash.insert([0]*32) + muhash.insert([1] + [0]*31) + muhash.remove([2] + [0]*31) + finalized = muhash.digest() + # This mirrors the result in the C++ MuHash3072 unit test + self.assertEqual(finalized[::-1].hex(), "a44e16d5e34d259b349af21c06e65d653915d2e208e4e03f389af750dc0bfdc3") |