HomePhabricator

[electrum] rely on pycryptodomex being installed in hash_160

Description

[electrum] rely on pycryptodomex being installed in hash_160

Summary:
The code was wrong and didn't work on systems with OpenSSL compiled without ripemd160 (which is now the case for the OpenSSL 3.0 default build), because the try except clauses were not properly nested.

It should have been:

try:
   ...
except ValueError:
    try:
        ...
    except ImportError:
        ...

The last fallback option, which is a slow pure-python implementation (slowdown very noticeable in wallets with many addresses), is no longer really needed as we just made pycryptodomex an official dependency.

Note that we also have a (better maintained) ripemd pure-python implementation in the node's test framework, so this also deduplicates code in the monorepo.

Depends on D14132

Test Plan:

pip uninstall pycryptodomex
pip install -r contrib/requirements/requirements.txt
python run_tests.py

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14133

Details

Provenance
PiRKAuthored on Jun 27 2023, 12:33
PiRKPushed on Jun 27 2023, 13:41
Reviewer
Restricted Project
Differential Revision
D14133: [electrum] rely on pycryptodomex being installed in hash_160
Parents
rABC9533c4d21067: [electrum] use pycryptodomex everywhere, drop pycryptodome
Branches
Unknown
Tags
Unknown