Skip to content

hash160 may not always work #30

@Eunovo

Description

@Eunovo

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions