EEVM.Precompiles.Blake2F (eevm v0.1.0)

Copy Markdown View Source

Blake2f precompile — address 0x09 (EIP-152).

Implements the Blake2b compression function F.

Gas schedule

Gas cost is exactly the rounds field from input bytes 0..3 (uint32, big-endian).

Input format

Input must be exactly 213 bytes:

  • bytes 0..3 — rounds (uint32, big-endian)
  • bytes 4..67 — h (8 × 64-bit words, little-endian)
  • bytes 68..195 — m (16 × 64-bit words, little-endian)
  • bytes 196..211 — t (2 × 64-bit words, little-endian)
  • byte 212 — f final block flag (0 or 1 only)

Output is 64 bytes: the 8 updated state words in little-endian.

Summary

Functions

Executes the Blake2f precompile.

Functions

execute(arg1, gas_limit)

@spec execute(binary(), non_neg_integer()) ::
  {:ok, binary(), non_neg_integer()} | {:error, :invalid_input | :out_of_gas}

Executes the Blake2f precompile.

Returns {:ok, output, gas_used} on success where output is 64 bytes and gas_used == rounds.

Returns:

  • {:error, :invalid_input} if input length is not 213 bytes or final flag is not 0 or 1
  • {:error, :out_of_gas} if gas_limit < rounds