EEVM.Crypto.Keccak (eevm v0.1.0)

Copy Markdown View Source

Keccak-256, the hash Ethereum calls keccak256, in pure Elixir.

This is Keccak[r = 1088, c = 512] with the original submission's pad10*1 padding: the first padding byte is 0x01. SHA3-256 (FIPS 202) is the same sponge with 0x06, so the two give different digests.

The permutation is Keccak-f[1600] from FIPS 202 §3: 24 rounds of θ, ρ, π, χ and ι over a 5×5 array of 64-bit lanes.

Example

iex> EEVM.Crypto.Keccak.hash_256("") |> Base.encode16(case: :lower)
"c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"

Summary

Functions

Returns the 32-byte Keccak-256 digest of message.

Functions

hash_256(message)

@spec hash_256(binary()) :: <<_::256>>

Returns the 32-byte Keccak-256 digest of message.

Example

iex> EEVM.Crypto.Keccak.hash_256("abc") |> Base.encode16(case: :lower)
"4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45"