ethereum.forks.constantinople.vm.precompiled_contracts.sha256ethereum.forks.istanbul.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:
| 25 | """ |
|---|---|
| 26 | Writes the sha256 hash to output. |
| 27 | |
| 28 | Parameters |
| 29 | ---------- |
| 30 | evm : |
| 31 | The current EVM frame. |
| 32 | |
| 33 | """ |
| 34 | data = evm.message.data |
| 35 | |
| 36 | # GAS |
| 37 | word_count = ceil32(Uint(len(data))) // Uint(32) |
| 38 | charge_gas(evm, GAS_SHA256 + GAS_SHA256_WORD * word_count) |
| 39 | |
| 40 | # OPERATION |
| 41 | evm.output = hashlib.sha256(data).digest() |