Browse Source

activate RIPEMD-160 code, add tests

The MMGen Project 2 years ago
parent
commit
4dd799104b
5 changed files with 13 additions and 2 deletions
  1. 1 1
      mmgen/data/release_date
  2. 1 1
      mmgen/data/version
  3. 3 0
      mmgen/opts.py
  4. 1 0
      test/test-release.sh
  5. 7 0
      test/unit_tests_d/ut_dep.py

+ 1 - 1
mmgen/data/release_date

@@ -1 +1 @@
-April 2022
+May 2022

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.1.dev27
+13.1.dev28

+ 3 - 0
mmgen/opts.py

@@ -326,6 +326,9 @@ def init(
 	from .term import init_term
 	from .term import init_term
 	init_term()
 	init_term()
 
 
+	from .util import wrap_ripemd160
+	wrap_ripemd160() # ripemd160 used by cfg_file()
+
 	if not (opt.skip_cfg_file or opt.bob or opt.alice or g.prog_name == 'mmgen-regtest'):
 	if not (opt.skip_cfg_file or opt.bob or opt.alice or g.prog_name == 'mmgen-regtest'):
 		from .cfg import cfg_file
 		from .cfg import cfg_file
 		# check for changes in system template file - term must be initialized
 		# check for changes in system template file - term must be initialized

+ 1 - 0
test/test-release.sh

@@ -292,6 +292,7 @@ t_hash="
 	256    $python test/hashfunc.py sha256 $rounds_max
 	256    $python test/hashfunc.py sha256 $rounds_max
 	512    $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
 	512    $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
 	keccak $python test/hashfunc.py keccak $rounds_max
 	keccak $python test/hashfunc.py keccak $rounds_max
+	ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE
 "
 "
 f_hash='Hash function tests completed'
 f_hash='Hash function tests completed'
 
 

+ 7 - 0
test/unit_tests_d/ut_dep.py

@@ -68,6 +68,13 @@ class unit_tests:
 		pubkey = pko.get_verifying_key().to_string().hex()
 		pubkey = pko.get_verifying_key().to_string().hex()
 		return True
 		return True
 
 
+	def ripemd160(self,name,ut):
+		import hashlib
+		if hashlib.new.__name__ == 'hashlib_new_wrapper':
+			ymsg('Warning: RIPEMD160 missing in hashlib, falling back on pure-Python implementation')
+		hashlib.new('ripemd160')
+		return True
+
 	def gmpy(self,name,ut):
 	def gmpy(self,name,ut):
 		from gmpy2 import context,set_context,sqrt,cbrt
 		from gmpy2 import context,set_context,sqrt,cbrt
 		# context() parameters are platform-dependent!
 		# context() parameters are platform-dependent!