mcdallas / cryptotools

MIT License
206 stars 80 forks source link

public keys to_address, P2PKH, P2WPKH, are not working #43

Closed hitalloazevedo closed 5 months ago

hitalloazevedo commented 5 months ago

Traceback (most recent call last): File "/usr/lib/python3.10/hashlib.py", line 160, in __hash_new return _hashlib.new(name, data, **kwargs) ValueError: [digital envelope routines] unsupported

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/hitallozx/python-finder/teste.py", line 11, in addrp2pkh = publicKey.to_address('P2PKH') File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/ECDSA/secp256k1.py", line 164, in to_address return pubkey_to_address(self, addrtype) File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/BTC/address.py", line 75, in pubkey_to_address return converter(pub) File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/BTC/address.py", line 59, in ADDRESS.P2PKH: lambda pub: legacy_address(pub, version_byte=network('keyhash')), File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/BTC/address.py", line 20, in legacy_address hashed = hash160(bts) File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/transformations.py", line 14, in hash160 = lambda x: ripemd160(sha256(x)) File "/home/hitallozx/.local/lib/python3.10/site-packages/cryptotools/transformations.py", line 13, in ripemd160 = lambda x: hashlib.new('ripemd160', x).digest() File "/usr/lib/python3.10/hashlib.py", line 166, in __hash_new return get_builtin_constructor(name)(data) File "/usr/lib/python3.10/hashlib.py", line 123, in get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type ripemd160

mcdallas commented 5 months ago

Looks like python uses ripemd160 implementation from openssl which may be disabled for newer versions. Does the solution here help? https://stackoverflow.com/questions/72409563/unsupported-hash-type-ripemd160-with-hashlib-in-python

hitalloazevedo commented 5 months ago

Thx man!!