RIPEMD-160 precompile — address 0x03.
Output format (Yellow Paper §E.2)
Even though the digest is only 20 bytes, the precompile always returns 32 bytes: the 20-byte hash is right-aligned within the 32-byte word, with 12 zero bytes prepended on the left.
[ 0x00 × 12 | RIPEMD160(input) × 20 ]
└────────────────────────── 32 bytes ──┘Gas schedule
| Component | Cost |
|---|---|
| Base | 600 |
| Per word | 120 (one word = 32 bytes, rounded up) |
Summary
Functions
Executes the RIPEMD-160 precompile.
Functions
@spec execute(binary(), non_neg_integer()) :: {:ok, binary(), non_neg_integer()} | {:error, :out_of_gas}
Executes the RIPEMD-160 precompile.
Hashes input with RIPEMD-160 and returns a 32-byte binary: 12 zero bytes
followed by the 20-byte digest. Gas charged is
600 + 120 * ceil(byte_size(input) / 32).
Examples
iex> {:ok, out, _gas} = EEVM.Precompiles.RIPEMD160.execute(<<>>, 10_000)
iex> byte_size(out)
32
iex> binary_part(out, 0, 12)
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>
iex> EEVM.Precompiles.RIPEMD160.execute(<<1::256>>, 5)
{:error, :out_of_gas}