-
Notifications
You must be signed in to change notification settings - Fork 662
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
Openssl removed ripemd160 support. Code using hashlib's 'ripemd160' algorithm may fail. #255
Comments
Nice catch @cmdruid can you specify which chapter we will encounter this on? Also, should we create a separate file that includes the entire "ripemd160.py" and import that file into our scripts? |
Starting from chapter 4, it is used in the
Yes that is correct. The |
You can change your openssl config to enable ripemd160. https://stackoverflow.com/questions/72409563/unsupported-hash-type-ripemd160-with-hashlib-in-python |
I'm posting this issue in order to help anyone who comes across this problem.
If you try to use the code:
hashlib.new('ripemd160', thingtobehashed).digest()
and you receive this error:
ValueError: unsupported hash type ripemd160
It is because Hashlib uses openssl under the hood, and openssl has recently decided to depreciate support for the ripemd160 algorithm. See the relevant issues below:
openssl/openssl#16994
bitcoin/bitcoin#23710
There may be some way to re-enable support for ripemd160 under the hood, but I think an easier solution is to just copy/paste the pure python implementation of ripemd160 and use that instead. See the link below (code courtesy of the legend Pieter Wuille):
https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/ripemd160.py
If you would like, I can submit a PR that adds this file to the chapters and updates the existing hash160 function (with notes explaining the issue). But maybe there's a cleaner way to fix this, I don't know.
The text was updated successfully, but these errors were encountered: