ethereum.cancun.vm.precompiled_contracts.ripemd160
Ethereum Virtual Machine (EVM) RIPEMD160 PRECOMPILED CONTRACT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Implementation of the RIPEMD160
precompiled contract.
ripemd160
Writes the ripemd160 hash to output.
Parameters
evm : The current EVM frame.
def ripemd160(evm: Evm) -> None:
25 | """ |
---|---|
26 | Writes the ripemd160 hash to output. |
27 |
|
28 | Parameters |
29 | ---------- |
30 | evm : |
31 | The current EVM frame. |
32 | """ |
33 | data = evm.message.data |
34 | |
35 | # GAS |
36 | word_count = ceil32(Uint(len(data))) // 32 |
37 | charge_gas(evm, GAS_RIPEMD160 + GAS_RIPEMD160_WORD * word_count) |
38 | |
39 | # OPERATION |
40 | hash_bytes = hashlib.new("ripemd160", data).digest() |
41 | padded_hash = left_pad_zero_bytes(hash_bytes, 32) |
42 | evm.output = padded_hash |