activate RIPEMD-160 code, add tests

This commit is contained in:
The MMGen Project 2022-05-03 21:01:06 +00:00
commit 4dd799104b
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 13 additions and 2 deletions

View file

@ -1 +1 @@
April 2022
May 2022

View file

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

View file

@ -326,6 +326,9 @@ def init(
from .term import 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'):
from .cfg import cfg_file
# check for changes in system template file - term must be initialized

View file

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

View file

@ -68,6 +68,13 @@ class unit_tests:
pubkey = pko.get_verifying_key().to_string().hex()
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):
from gmpy2 import context,set_context,sqrt,cbrt
# context() parameters are platform-dependent!