Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu 22.04 - ValueError: unsupported hash type ripemd160 #168

Open
reisenmachtfreude opened this issue Oct 31, 2022 · 4 comments
Open

Comments

@reisenmachtfreude
Copy link

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.

@cibermosso
Copy link

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

@NateNate60
Copy link
Contributor

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?

@ofek
Copy link
Owner

ofek commented Dec 8, 2022

@paulocoutinhox
Copy link

I add a PR to solve this:
#184

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants