minor cleanups

This commit is contained in:
The MMGen Project 2021-09-24 20:07:04 +00:00
commit 86f263d2d4
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 14 additions and 10 deletions

View file

@ -275,7 +275,7 @@ class KeyGeneratorPython(KeyGenerator):
def privnum2pubhex(self,numpriv,compressed=False):
pko = ecdsa.SigningKey.from_secret_exponent(numpriv,self.secp256k1)
# pubkey = x (32 bytes) + y (32 bytes) (unsigned big-endian)
pubkey = (pko.get_verifying_key().to_string()).hex()
pubkey = pko.get_verifying_key().to_string().hex()
if compressed: # discard Y coord, replace with appropriate version byte
# even y: <0, odd y: >0 -- https://bitcointalk.org/index.php?topic=129652.0
return ('03','02')[pubkey[-1] in '02468ace'] + pubkey[:64]

View file

@ -138,7 +138,7 @@ class GlobalContext(Lockable):
)
for k in ('linux','win','msys'):
if sys.platform[:len(k)] == k:
if sys.platform.startswith(k):
platform = { 'linux':'linux', 'win':'win', 'msys':'win' }[k]
break
else:
@ -279,7 +279,7 @@ class GlobalContext(Lockable):
key_generator = 2 # libsecp256k1 is default
force_standalone_scrypt_module = False
# Scrypt params: 'id_num': [N, p, r] (N is an exponent of two)
# Scrypt params: 'id_num': [N, r, p] (N is an exponent of two)
# NB: hashlib.scrypt in Python (>=v3.6) supports max N value of 14. This means that
# for hash presets > 3 the standalone scrypt library must be used!
hash_presets = {

View file

@ -20,7 +20,7 @@
test/unit_tests.py: Unit tests for the MMGen suite
"""
import sys,os,time
import sys,os,time,importlib
from include.tests_header import repo_root
from mmgen.common import *
@ -116,7 +116,6 @@ def run_test(test,subtest=None):
rdie(1,'Unit test {test!r} failed')
try:
import importlib
for test in (cmd_args or all_tests):
if '.' in test:
test,subtest = test.split('.')

View file

@ -1,6 +1,9 @@
#!/usr/bin/env python3
"""
test.unit_tests_d.ut_rpc: dependency unit tests for the MMGen suite
test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite
Test whether dependencies are installed and functional.
No data verification is performed.
"""
from mmgen.common import *

View file

@ -35,7 +35,7 @@ class unit_test(object):
if opt.quiet:
omsg_r('.')
else:
msg_r(' password {:9} '.format(pw_disp))
msg_r('\n password {:9} '.format(pw_disp))
ret = scrypt_hash_passphrase(pw,salt,'1').hex()
assert ret == res, ret
@ -48,14 +48,15 @@ class unit_test(object):
if opt.quiet:
omsg_r('.')
else:
msg_r(' {!r:3}: {!r:12} '.format(hp,g.hash_presets[hp]))
msg_r('\n {!r:3}: {!r:12} '.format(hp,g.hash_presets[hp]))
st = time.time()
ret = scrypt_hash_passphrase(pw,salt,hp).hex()
t = time.time() - st
vmsg(' {:0.4f} secs'.format(t))
assert ret == res, ret
if opt.quiet: silence()
if opt.quiet:
silence()
g.force_standalone_scrypt_module = False
vmsg('Passwords:')
@ -69,7 +70,8 @@ class unit_test(object):
vmsg('Hash presets (standalone scrypt):')
test_presets((1,2,3))
if opt.quiet: end_silence()
if opt.quiet:
end_silence()
msg('OK')
return True