Swap out hashlib.ripemd160 for own implementation

Github-Pull: #23716
Rebased-From: 5b559dc7ec
This commit is contained in:
Pieter Wuille 2021-12-08 14:17:08 -05:00 committed by fanquake
parent 6bfa0bef48
commit bf79f08d97
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1

View file

@ -8,7 +8,6 @@ This file is modified from python-bitcoinlib.
"""
from collections import namedtuple
import hashlib
import struct
import unittest
from typing import List, Dict
@ -25,6 +24,8 @@ from .messages import (
uint256_from_str,
)
from .ripemd160 import ripemd160
MAX_SCRIPT_ELEMENT_SIZE = 520
LOCKTIME_THRESHOLD = 500000000
ANNEX_TAG = 0x50
@ -34,7 +35,7 @@ OPCODE_NAMES = {} # type: Dict[CScriptOp, str]
LEAF_VERSION_TAPSCRIPT = 0xc0
def hash160(s):
return hashlib.new('ripemd160', sha256(s)).digest()
return ripemd160(sha256(s))
def bn2vch(v):
"""Convert number to bitcoin-specific little endian format."""