mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-18 14:44:21 +01:00
Adds RIPMED160 hash function
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import pyzbase32
|
import pyzbase32
|
||||||
from hashlib import sha256
|
from hashlib import sha256, new
|
||||||
from binascii import unhexlify, hexlify
|
from binascii import unhexlify, hexlify
|
||||||
from coincurve.utils import int_to_bytes
|
from coincurve.utils import int_to_bytes
|
||||||
from coincurve import PrivateKey, PublicKey
|
from coincurve import PrivateKey, PublicKey
|
||||||
@@ -25,6 +25,24 @@ def sha256d(message):
|
|||||||
return sha256(sha256(message).digest()).digest()
|
return sha256(sha256(message).digest()).digest()
|
||||||
|
|
||||||
|
|
||||||
|
def hash_160(message):
|
||||||
|
""" Calculates the RIPEMD-160 hash of a given message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
message (:obj:`str`) the message to be hashed.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:obj:`str`: the ripemd160 hash of the given message.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Calculate the RIPEMD-160 hash of the given data.
|
||||||
|
md = new("ripemd160")
|
||||||
|
md.update(unhexlify(message))
|
||||||
|
h160 = md.hexdigest()
|
||||||
|
|
||||||
|
return h160
|
||||||
|
|
||||||
|
|
||||||
def sigrec_encode(rsig_rid):
|
def sigrec_encode(rsig_rid):
|
||||||
"""
|
"""
|
||||||
Encodes a pk-recoverable signature to be used in LN. ```rsig_rid`` can be obtained trough
|
Encodes a pk-recoverable signature to be used in LN. ```rsig_rid`` can be obtained trough
|
||||||
|
|||||||
Reference in New Issue
Block a user