Skip to main content
Keccak256 (exported as Keccak256 and Keccak256Hash) computes the 32-byte Ethereum Keccak-256 digest over arbitrary byte sequences, UTF-8 strings, or hex strings. Every hashing method returns a branded 32-byte Uint8Array (Keccak256Hash).

Sponge Construction and Ethereum Derivations

Keccak-256 uses a 1600-bit permutation (STATE_SIZE = 25 64-bit lanes = 200 bytes) with rate r = 1088 bits (RATE = 136 bytes), capacity c = 512 bits, and domain padding byte 0x01.
Ethereum uses original Keccak-256 (0x01 padding), not NIST FIPS 202 SHA3-256 (0x06 padding). The two algorithms produce different digests for every input.

Entrypoints and Runtime Backends

Voltaire exposes three Keccak-256 entrypoints with distinct execution models: @tevm/voltaire/Keccak256/wasm currently aliases the pure TypeScript module in package.json. Use Keccak256Wasm from @tevm/voltaire/wasm when you want explicit WASM execution.

API Reference

All functions below are available both as methods on Keccak256 / Keccak256Hash and as tree-shakeable named exports from @tevm/voltaire/Keccak256.

Constants

Ethereum Helpers

Errors and Edge Cases

  • from(input) treats any string matching /^[0-9a-fA-F]*$/ (including "" or "deadbeef") as hex rather than UTF-8. Call hashString explicitly when hashing arbitrary text to avoid hex misdetection.
  • contractAddress throws InvalidLengthError if sender.length !== 20.
  • create2Address takes initCodeHash (32 bytes), not raw initCode. It throws InvalidLengthError if sender is not 20 bytes or salt / initCodeHash is not 32 bytes.
  • Keccak256.hashSync on @tevm/voltaire/Keccak256/native throws Keccak256NativeNotLoadedError if called before any async call loads the native shared library.

Test Vectors