Skip to content

Commit 4ffd9ec

Browse files
authored
OpenSSL <3.0 ripemd160 bugfix (#30)
1 parent ea07705 commit 4ffd9ec

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ mnemonic==0.20
88
protobuf==4.22.1
99
safe-pysha3==1.0.3;python_version>='3.9'
1010
pysha3==1.0.2;python_version<'3.9'
11+
pycryptodome==3.20.0

src/mospy/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from mnemonic import Mnemonic
77
from sha3 import keccak_256
88
import binascii
9+
from Crypto.Hash.RIPEMD160 import new as ripemd160_new
910

1011

1112
def seed_to_private_key(seed, derivation_path, passphrase: str = ""):
@@ -26,7 +27,9 @@ def privkey_to_pubkey(privkey: bytes, raw: bool = False) -> bytes:
2627

2728
def pubkey_to_address(pubkey: bytes, *, hrp: str) -> str:
2829
s = hashlib.new("sha256", pubkey).digest()
29-
r = hashlib.new("ripemd160", s).digest()
30+
ripemd160 = ripemd160_new()
31+
ripemd160.update(s)
32+
r = ripemd160.digest()
3033
five_bit_r = bech32.convertbits(r, 8, 5)
3134
assert five_bit_r is not None, "Unsuccessful bech32.convertbits call"
3235
return bech32.bech32_encode(hrp, five_bit_r)

0 commit comments

Comments
 (0)