bit icon indicating copy to clipboard operation
bit copied to clipboard

Ubuntu 22.04 - ValueError: unsupported hash type ripemd160

Open reisenmachtfreude opened this issue 3 years ago • 9 comments

Using Ubuntun 22.04 and Python 3.10.6 the code throws an error

my_key = PrivateKeyTestnet()
print(my_key.address)

 File "/home/user/.local/lib/python3.10/site-packages/bit/wallet.py", line 572, in address
    self._address = public_key_to_address(self._public_key, version=self.version)
  File "/home/user/.local/lib/python3.10/site-packages/bit/format.py", line 121, in public_key_to_address
    return b58encode_check(version + ripemd160_sha256(public_key))
  File "/home/user/.local/lib/python3.10/site-packages/bit/crypto.py", line 19, in ripemd160_sha256
    return new('ripemd160', sha256(bytestr)).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

Using same code in virtual env python3.9 does work.

reisenmachtfreude avatar Oct 31 '22 02:10 reisenmachtfreude

Is a problem with openssl, basically ripemd160 was dissable, if you want you can activate again:

The issue can be resolved by adding this lines to /etc/ssl/openssl.cnf:

[openssl_init] providers = provider_sect

List of providers to load

[provider_sect] default = default_sect +legacy = legacy_sect

[default_sect] activate = 1

+[legacy_sect] +activate = 1

Check this link https://stackoverflow.com/questions/72409563/unsupported-hash-type-ripemd160-with-hashlib-in-python

cibermosso avatar Nov 05 '22 19:11 cibermosso

I wonder why this issue isn't getting more attention. It would seem like this is a breaking issue that affects a very sizable portion of users. Is it absolutely necessary to use ripemd160 or can a substitute be used that is enabled by default in OpenSSL?

NateNate60 avatar Dec 08 '22 17:12 NateNate60

See image on https://en.bitcoinwiki.org/wiki/Bitcoin_address#Purpose_and_opportunities

ofek avatar Dec 08 '22 18:12 ofek

I add a PR to solve this: https://github.com/ofek/bit/pull/184

paulocoutinhox avatar Feb 15 '24 21:02 paulocoutinhox