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

hash160 may not always work #30

Open
Eunovo opened this issue May 10, 2023 · 2 comments · May be fixed by #31
Open

hash160 may not always work #30

Eunovo opened this issue May 10, 2023 · 2 comments · May be fixed by #31

Comments

@Eunovo
Copy link
Contributor

Eunovo commented May 10, 2023

The hash160 implementation at

def hash160(data):
"""{data} must be bytes, returns ripemd160(sha256(data))"""
assert isinstance(data, bytes)
return hashlib.new("ripemd160", sha256(data)).digest()
uses hashlib to create a ripemd160 digest. The ripemd160 digest is not among hashlib's guaranteed algorigthms so this function may fail on some platforms with a ValueError: unsupported hash type ripemd message. I experienced this while trying to run liana's tests.

Would it be a bad idea to check for the presence of 'ripemd160' in hashlib.algorithms_available and output an appropriate error message before trying to create the ripemd160 digest?

@darosior
Copy link
Owner

I think we should use Bitcoin Core's Python implementation from bitcoin/bitcoin#23716.

@darosior
Copy link
Owner

darosior commented May 12, 2023

Also relevant, what we did for Python-bip32: darosior/python-bip32#33 (link to the file: https://github.com/darosior/python-bip32/blob/master/bip32/ripemd160.py).

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

Successfully merging a pull request may close this issue.

2 participants