From d5e8d5b96fabbf1a1aec0c3166c237e36ae3fa79 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 6 May 2022 12:52:41 +0000 Subject: [PATCH] various fixes and cleanups --- mmgen/addr.py | 1 + mmgen/base_proto/ethereum/daemon.py | 2 +- mmgen/contrib/ripemd160.py | 15 ++++++++++++++- setup.py | 11 +++++++---- test/test-release.sh | 8 ++++---- test/unit_tests_d/ut_msg.py | 10 ++++++---- test/unit_tests_d/ut_testdep.py | 1 - 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/mmgen/addr.py b/mmgen/addr.py index fab522d8..88b49034 100755 --- a/mmgen/addr.py +++ b/mmgen/addr.py @@ -201,6 +201,7 @@ def KeyGenerator(proto,pubkey_type,backend=None,silent=False): if not pubkey_type_cls.libsecp256k1.test_avail(silent=silent): backend_id = 'python-ecdsa' if not backend: + from .util import qmsg qmsg('Using (slow) native Python ECDSA library for public key generation') return getattr(pubkey_type_cls,backend_id.replace('-','_'))() diff --git a/mmgen/base_proto/ethereum/daemon.py b/mmgen/base_proto/ethereum/daemon.py index 079c02fb..949e7eed 100755 --- a/mmgen/base_proto/ethereum/daemon.py +++ b/mmgen/base_proto/ethereum/daemon.py @@ -50,7 +50,7 @@ class ethereum_daemon(CoinDaemon): getattr(self.chain_subdirs,self.network) ) class openethereum_daemon(ethereum_daemon): - daemon_data = _dd('OpenEthereum', 3003000, '3.3.0') + daemon_data = _dd('OpenEthereum', 3003005, '3.3.5') version_pat = r'OpenEthereum//v(\d+)\.(\d+)\.(\d+)' exec_fn = 'openethereum' cfg_file = 'parity.conf' diff --git a/mmgen/contrib/ripemd160.py b/mmgen/contrib/ripemd160.py index a2dea639..6a184b83 100755 --- a/mmgen/contrib/ripemd160.py +++ b/mmgen/contrib/ripemd160.py @@ -3,10 +3,23 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. # # Source: https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/ripemd160.py -# Ported to MMGen with the following changes: +# +# Adapted for the MMGen Project with the following changes: # - replace leading spaces with tabs # - reimplement as class with digest() and hexdigest() methods # - add custom test output display +# +# SECURITY DISCLAIMER: +# This code has been flagged as ‘test-only’ by its creator because it is not +# constant-time and therefore vulnerable to timing attacks. +# +# The RIPEMD-160 algorithm is used in the MMGen code base in two places: a) +# in hash160(); and b) as a checksum for a config file template. Here +# timing attacks are not meaningful, because in the first case the preimage +# is a secure cryptographic hash and in the second -- public data. +# +# The MMGen Project assumes no responsibility for the use of this code in +# other contexts. """Test-only pure Python RIPEMD160 implementation.""" diff --git a/setup.py b/setup.py index a868ffa9..6a75bdd8 100755 --- a/setup.py +++ b/setup.py @@ -12,9 +12,11 @@ def build_libsecp256k1(): if not os.path.exists(cache_path): os.makedirs(cache_path) if not os.path.exists(ext_path): + print('\nCloning libsecp256k1') run(['git','clone','https://github.com/bitcoin-core/secp256k1.git'],check=True,cwd=cache_path) if not os.path.exists(os.path.join(ext_path,'.libs/libsecp256k1.a')): import platform + print('\nBuilding libsecp256k1') cmds = { 'Windows': ( ['sh','./autogen.sh'], @@ -24,16 +26,17 @@ def build_libsecp256k1(): 'Linux': ( ['./autogen.sh'], ['./configure','CFLAGS=-g -O2 -fPIC'], - ['make','-j4'] + ['make'] + ([] if have_arm else ['-j4']), ), }[platform.system()] for cmd in cmds: print('Executing {}'.format(' '.join(cmd))) run(cmd,check=True,cwd=ext_path) -have_msys2 = run(['uname','-s'],stdout=PIPE,check=True).stdout.startswith(b'MSYS_NT') -if have_msys2: - print('MSYS2 system detected') +uname = {k:run(['uname',f'-{k}'],stdout=PIPE,check=True).stdout.strip().decode() for k in ('m','s')} + +have_arm = uname['m'] in ('aarch64','armv7l') # x86_64, aarch64, armv7l +have_msys2 = uname['s'].startswith('MSYS_NT') # Linux, MSYS_NT.* class my_build_ext(build_ext): def build_extension(self,ext): diff --git a/test/test-release.sh b/test/test-release.sh index 0964dbd4..316c2545 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -350,7 +350,7 @@ t_alts=" " [ "$MSYS2" ] && t_alts_skip='m z' # no moneropy (pysha3), zcash-mini (golang) -[ "$ARM32" -o "$ARM64" ] && t_alts_skip='z e' +[ "$ARM32" ] && t_alts_skip='z e' f_alts='Gen-only altcoin tests completed' @@ -510,7 +510,7 @@ t_tool=" a $tooltest_py --coin=zec cryptocoin z $tooltest_py --coin=zec --type=zcash_z cryptocoin " -[ "$MSYS2" -o "$ARM32" -o "$ARM64" ] && t_tool_skip='z' +[ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z' [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z' f_tool='tooltest tests completed' @@ -546,8 +546,8 @@ t_gen=" a $gentest_py --coin=ltc --type=segwit 1:2 $rounds a $gentest_py --coin=ltc --testnet=1 1:2 $rounds a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds - a # all backends vs pycoin: - a $gentest_py all:pycoin $rounds + - # all backends vs pycoin: + - $gentest_py all:pycoin $rounds " [ "$SKIP_ALT_DEP" ] && t_gen_skip='a' diff --git a/test/unit_tests_d/ut_msg.py b/test/unit_tests_d/ut_msg.py index 991631be..874dabe9 100755 --- a/test/unit_tests_d/ut_msg.py +++ b/test/unit_tests_d/ut_msg.py @@ -38,12 +38,13 @@ async def run_test(network_id,chksum,msghash_type='raw'): bmsg(f'\nTesting {coin.upper()} {network.upper()}:\n') - restart_test_daemons(network_id) + m = get_obj(coin,network,msghash_type) + + if m.proto.sign_mode == 'daemon': + restart_test_daemons(network_id) pumsg('\nTesting data creation:\n') - m = get_obj(coin,network,msghash_type) - tmpdir = os.path.join('test','trash2') os.makedirs(tmpdir,exist_ok=True) @@ -110,7 +111,8 @@ async def run_test(network_id,chksum,msghash_type='raw'): pumsg('\nTesting single address display (exported data):\n') msg(m.format(single_addr_coin)) - stop_test_daemons(network_id) + if m.proto.sign_mode == 'daemon': + stop_test_daemons(network_id) msg('\n') diff --git a/test/unit_tests_d/ut_testdep.py b/test/unit_tests_d/ut_testdep.py index a0ae645a..df68b0d5 100755 --- a/test/unit_tests_d/ut_testdep.py +++ b/test/unit_tests_d/ut_testdep.py @@ -12,7 +12,6 @@ class unit_tests: altcoin_deps = ('pycoin','moneropy','keyconv','zcash_mini','ethkey','ssh_socks_proxy') win_skip = ('losetup','moneropy','zcash_mini') - arm_skip = ('zcash_mini','ethkey') def core_repo(self,name,ut): crr = os.getenv('CORE_REPO_ROOT')