ethereum.cancun.vm.precompiled_contracts.blake2f
Ethereum Virtual Machine (EVM) Blake2 PRECOMPILED CONTRACT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Implementation of the Blake2
precompiled contract.
blake2f
Writes the Blake2 hash to output.
Parameters
evm : The current EVM frame.
def blake2f(evm: Evm) -> None:
22 | """ |
---|---|
23 | Writes the Blake2 hash to output. |
24 |
|
25 | Parameters |
26 | ---------- |
27 | evm : |
28 | The current EVM frame. |
29 | """ |
30 | data = evm.message.data |
31 | if len(data) != 213: |
32 | raise InvalidParameter |
33 | |
34 | blake2b = Blake2b() |
35 | rounds, h, m, t_0, t_1, f = blake2b.get_blake2_parameters(data) |
36 | |
37 | charge_gas(evm, GAS_BLAKE2_PER_ROUND * rounds) |
38 | if f not in [0, 1]: |
39 | raise InvalidParameter |
40 | |
41 | evm.output = blake2b.compress(rounds, h, m, t_0, t_1, f) |