Ethereum Virtual Machine (EVM) RIPEMD160 PRECOMPILED CONTRACT

Introduction

Implementation of the RIPEMD160 precompiled contract.

Module Contents

Functions

ripemd160

Writes the ripemd160 hash to output.

Module Details

ripemd160

ripemd160(evm: ethereum.tangerine_whistle.vm.Evm)None

Writes the ripemd160 hash to output.

Parameters

evm – The current EVM frame.

def ripemd160(evm: Evm) -> None:
    data = evm.message.data

    # GAS
    word_count = ceil32(Uint(len(data))) // 32
    charge_gas(evm, GAS_RIPEMD160 + GAS_RIPEMD160_WORD * word_count)

    # OPERATION
    hash_bytes = hashlib.new("ripemd160", data).digest()
    padded_hash = left_pad_zero_bytes(hash_bytes, 32)
    evm.output = padded_hash