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