BIP-352: use own ripemd160 for reference implementation #1616

pull theStack wants to merge 1 commits into bitcoin:master from theStack:bip352-replace_hashlib_ripemd_with_own_impl changing 2 files +132 −1
  1. theStack commented at 5:33 pm on June 10, 2024: contributor

    On some operating systems, Python doesn’t provide the expected ripemd160 implementation anymore, so the reference implementation fails to start. E.g. in Ubuntu 22.04:

     0$ ./reference.py send_and_receive_test_vectors.json
     1Simple send: two inputs
     2Traceback (most recent call last):
     3  File "/usr/lib/python3.10/hashlib.py", line 160, in __hash_new
     4    return _hashlib.new(name, data, **kwargs)
     5ValueError: [digital envelope routines] unsupported
     6
     7During handling of the above exception, another exception occurred:
     8
     9Traceback (most recent call last):
    10  File "/home/thestack/bips/bip-0352/./reference.py", line 228, in <module>
    11    pubkey = get_pubkey_from_input(vin)
    12  File "/home/thestack/bips/bip-0352/./reference.py", line 46, in get_pubkey_from_input
    13    pubkey_hash = hash160(pubkey_bytes)
    14  File "/home/thestack/bips/bip-0352/bitcoin_utils.py", line 130, in hash160
    15    return hashlib.new("ripemd160", hashlib.sha256(s).digest()).digest()
    16  File "/usr/lib/python3.10/hashlib.py", line 166, in __hash_new
    17    return __get_builtin_constructor(name)(data)
    18  File "/usr/lib/python3.10/hashlib.py", line 123, in __get_builtin_constructor
    19    raise ValueError('unsupported hash type ' + name)
    20ValueError: unsupported hash type ripemd160
    

    Fix this by providing a manual implementation, taken from the functional test framework of Bitcoin Core. See corresponding issue https://github.com/bitcoin/bitcoin/issues/23710 and PR https://github.com/bitcoin/bitcoin/pull/23716.

  2. BIP-352: use own ripemd160 for reference implementation
    On some operating systems, Python doesn't provide the expected ripemd160
    implementation anymore, so the reference implementation fails to start.
    E.g. in Ubuntu 22.04:
    
    ----------------------------------------------------------------------------------------------
    $ ./reference.py send_and_receive_test_vectors.json
    Simple send: two inputs
    Traceback (most recent call last):
      File "/usr/lib/python3.10/hashlib.py", line 160, in __hash_new
        return _hashlib.new(name, data, **kwargs)
    ValueError: [digital envelope routines] unsupported
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/thestack/bips/bip-0352/./reference.py", line 228, in <module>
        pubkey = get_pubkey_from_input(vin)
      File "/home/thestack/bips/bip-0352/./reference.py", line 46, in get_pubkey_from_input
        pubkey_hash = hash160(pubkey_bytes)
      File "/home/thestack/bips/bip-0352/bitcoin_utils.py", line 130, in hash160
        return hashlib.new("ripemd160", hashlib.sha256(s).digest()).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
    ----------------------------------------------------------------------------------------------
    
    Fix this by providing a manual implementation, taken from the functional test framework
    of Bitcoin Core. See corresponding issue https://github.com/bitcoin/bitcoin/issues/23710 and
    PR https://github.com/bitcoin/bitcoin/pull/23716
    ec7743d0a7
  3. murchandamus commented at 6:10 pm on June 10, 2024: contributor
  4. murchandamus added the label Proposed BIP modification on Jun 10, 2024
  5. murchandamus added the label Pending acceptance on Jun 10, 2024
  6. 5twelve approved
  7. josibake commented at 12:07 pm on June 29, 2024: member
  8. josibake referenced this in commit 9dade20071 on Jun 29, 2024
  9. jonatack commented at 2:08 pm on June 29, 2024: contributor

    ACK

    bip-0352/ripemd160.py matches bitcoin/test/functional/test/framework/crypto/ripemd160.py and ./reference.py send_and_receive_test_vectors.json runs as before.

  10. jonatack merged this on Jun 29, 2024
  11. jonatack closed this on Jun 29, 2024

  12. theStack deleted the branch on Jun 29, 2024
  13. jonatack removed the label Pending acceptance on Jul 1, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 16:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me