ethereum.forks.byzantium.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:
            
| 26 |     """ | 
|---|---|
| 27 |     Writes the ripemd160 hash to output. | 
| 28 |  | 
| 29 |     Parameters | 
| 30 |     ---------- | 
| 31 |     evm : | 
| 32 |         The current EVM frame. | 
| 33 |  | 
| 34 |     """ | 
| 35 |     data = evm.message.data | 
| 36 | |
| 37 |     # GAS | 
| 38 |     word_count = ceil32(Uint(len(data))) // Uint(32) | 
| 39 |     charge_gas(evm, GAS_RIPEMD160 + GAS_RIPEMD160_WORD * word_count) | 
| 40 | |
| 41 |     # OPERATION | 
| 42 |     hash_bytes = hashlib.new("ripemd160", data).digest() | 
| 43 |     padded_hash = left_pad_zero_bytes(hash_bytes, 32) | 
| 44 |     evm.output = padded_hash |