Replace all hashlib ripemd160 functions.

This commit is contained in:
tecnovert
2023-12-16 09:29:48 +02:00
parent 08f0156b75
commit 0a9db22828
11 changed files with 31 additions and 23 deletions

View File

@@ -22,7 +22,7 @@ from coincurve.keys import (
PrivateKey)
from basicswap.util import i2b, h2b
from basicswap.util.crypto import ripemd160
from basicswap.util.crypto import ripemd160, hash160
from basicswap.util.rfc2440 import rfc2440_hash_password
from basicswap.interface.btc import BTCInterface
from basicswap.interface.xmr import XMRInterface
@@ -40,6 +40,7 @@ from basicswap.messages_pb2 import (
BidMessage,
BidMessage_v1Deprecated,
)
from basicswap.contrib.test_framework.script import hash160 as hash160_btc
class Test(unittest.TestCase):
@@ -317,6 +318,12 @@ class Test(unittest.TestCase):
input_data = b'hash this'
assert (ripemd160(input_data).hex() == 'd5443a154f167e2c1332f6de72cfb4c6ab9c8c17')
def test_hash160(self):
# hash160 is RIPEMD(SHA256(data))
input_data = b'hash this'
assert (hash160(input_data).hex() == '072985b3583a4a71f548494a5e1d5f6b00d0fe13')
assert (hash160_btc(input_data).hex() == '072985b3583a4a71f548494a5e1d5f6b00d0fe13')
def test_protobuf(self):
# Ensure old protobuf templates can be read