diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-07 17:16:47 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2021-01-07 17:57:17 +0100 |
commit | b6a71b80d28c79796b557cdb6bae05abb34d1225 (patch) | |
tree | cc11cd6db34b546fe629d400675d935edb2374c9 /test/functional | |
parent | 3a6acd1772100d71de45355381d0d6ccf1320748 (diff) | |
parent | 9815332d5158d69a94abeaf465a2c07bd8e43359 (diff) |
Merge #19055: Add MuHash3072 implementation
9815332d5158d69a94abeaf465a2c07bd8e43359 test: Change MuHash Python implementation to match cpp version again (Fabian Jahr)
01297fb3ca57e4b8cbc5a89fc7c6367de33b0bc6 fuzz: Add MuHash consistency fuzz test (Fabian Jahr)
b111410914041b72961536c3e4037eba103a8085 test: Add MuHash3072 fuzz test (Fabian Jahr)
c1225273857f9fa2e2276396e3f8b3ea48306df3 bench: Add Muhash benchmarks (Fabian Jahr)
7b1242229d1fcc9277238a3aefb3431061c82bfa test: Add MuHash3072 unit tests (Fabian Jahr)
adc708c98dbf03b1735edc91f813a36580781a95 crypto: Add MuHash3072 implementation (Fabian Jahr)
0b4d290bf5b0a4d156c523431bf89aaa9ffe92e5 crypto: Add Num3072 implementation (Fabian Jahr)
589f958662a2dcaacdb9a66f1088c74828a39577 build: Check for 128 bit integer support (Fabian Jahr)
Pull request description:
This is the first split of #18000 which implements the Muhash algorithm and uses it to calculate the UTXO set hash in `gettxoutsetinfo`.
ACKs for top commit:
laanwj:
Code review ACK 9815332d5158d69a94abeaf465a2c07bd8e43359
Tree-SHA512: 4bc090738f0e3d80b74bdd8122e24a8ce80121120fd37c7e4335a73e7ba4fcd7643f2a2d559e2eebf54b8e3a3bd5f12cfb27ba61ded135fda210a07a233eae45
Diffstat (limited to 'test/functional')
-rw-r--r-- | test/functional/test_framework/muhash.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/functional/test_framework/muhash.py b/test/functional/test_framework/muhash.py index 97d02359cb..183548f71f 100644 --- a/test/functional/test_framework/muhash.py +++ b/test/functional/test_framework/muhash.py @@ -78,11 +78,13 @@ class MuHash3072: def insert(self, data): """Insert a byte array data in the set.""" - self.numerator = (self.numerator * data_to_num3072(data)) % self.MODULUS + data_hash = hashlib.sha256(data).digest() + self.numerator = (self.numerator * data_to_num3072(data_hash)) % self.MODULUS def remove(self, data): """Remove a byte array from the set.""" - self.denominator = (self.denominator * data_to_num3072(data)) % self.MODULUS + data_hash = hashlib.sha256(data).digest() + self.denominator = (self.denominator * data_to_num3072(data_hash)) % self.MODULUS def digest(self): """Extract the final hash. Does not modify this object.""" @@ -93,12 +95,12 @@ class MuHash3072: class TestFrameworkMuhash(unittest.TestCase): def test_muhash(self): muhash = MuHash3072() - muhash.insert([0]*32) - muhash.insert([1] + [0]*31) - muhash.remove([2] + [0]*31) + muhash.insert(b'\x00' * 32) + muhash.insert((b'\x01' + b'\x00' * 31)) + muhash.remove((b'\x02' + b'\x00' * 31)) finalized = muhash.digest() # This mirrors the result in the C++ MuHash3072 unit test - self.assertEqual(finalized[::-1].hex(), "a44e16d5e34d259b349af21c06e65d653915d2e208e4e03f389af750dc0bfdc3") + self.assertEqual(finalized[::-1].hex(), "10d312b100cbd32ada024a6646e40d3482fcff103668d2625f10002a607d5863") def test_chacha20(self): def chacha_check(key, result): |