eosapi icon indicating copy to clipboard operation
eosapi copied to clipboard

RIPEMD160 Hash Error

Open PuppyCerberus opened this issue 1 year ago • 0 comments

def ripmed160(data):
    h = hashlib.new('ripemd160')
    h.update(data)
    return h.digest()

above code will cause a RIPEMD160 HASH error when signing a transaction.

I had to change to in packer.py

from Crypto.Hash import RIPEMD160

def ripemd160(data):
    if isinstance(data, str):
        data = data.encode('utf-8')

    h = RIPEMD160.new()
    h.update(data)
    return h.digest()

also in transaction.py

    def unpack_signature(self, signature: bytes):
        t = Uint8.unpack(signature)
        if t == 0:
            data = signature[Uint8.size: Uint8.size + 65]
            data = data + ripemd160(data + b"K1")[:4]
            return "SIG_K1_" + b58encode(data).decode("ascii")
        elif t == 1:
            raise EosApiException("not implementd")
        else:
            raise EosApiException("invalid binary signature")

PuppyCerberus avatar Oct 06 '24 10:10 PuppyCerberus