ethereum.spurious_dragon.vm.precompiled_contracts.sha256ethereum.byzantium.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
    data = evm.message.data
34
35
    # GAS
36
    word_count = ceil32(Uint(len(data))) // Uint(32)
37
    charge_gas(evm, GAS_SHA256 + GAS_SHA256_WORD * word_count)
38
39
    # OPERATION
40
    evm.output = hashlib.sha256(data).digest()