File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 4
4
"""Native Python MuHash3072 implementation."""
5
5
6
6
import hashlib
7
+ import unittest
7
8
8
9
from .util import modinv
9
10
@@ -88,3 +89,13 @@ def digest(self):
88
89
val = (self .numerator * modinv (self .denominator , self .MODULUS )) % self .MODULUS
89
90
bytes384 = val .to_bytes (384 , 'little' )
90
91
return hashlib .sha256 (bytes384 ).digest ()
92
+
93
+ class TestFrameworkMuhash (unittest .TestCase ):
94
+ def test_muhash (self ):
95
+ muhash = MuHash3072 ()
96
+ muhash .insert ([0 ]* 32 )
97
+ muhash .insert ([1 ] + [0 ]* 31 )
98
+ muhash .remove ([2 ] + [0 ]* 31 )
99
+ finalized = muhash .digest ()
100
+ # This mirrors the result in the C++ MuHash3072 unit test
101
+ self .assertEqual (finalized [::- 1 ].hex (), "a44e16d5e34d259b349af21c06e65d653915d2e208e4e03f389af750dc0bfdc3" )
Original file line number Diff line number Diff line change 69
69
TEST_FRAMEWORK_MODULES = [
70
70
"address" ,
71
71
"blocktools" ,
72
+ "muhash" ,
72
73
"script" ,
73
74
"util" ,
74
75
]
You can’t perform that action at this time.
0 commit comments