Skip to main content

Overview

The Hash primitive has been moved to crypto/keccak256 as Keccak256Hash. This change reflects that Hash was specifically for Keccak256 hashing and belongs semantically under cryptographic operations rather than general primitives.

Why the Change

Better Organization
  • Hash was Keccak256-specific, not a general hash primitive
  • Cryptographic operations belong in the crypto module
  • Clearer semantic organization of the codebase
Semantic Clarity
  • Keccak256Hash explicitly names what it is
  • Separates hash algorithm (Keccak256) from hash type (Keccak256Hash)
  • Aligns with other crypto primitives (Secp256k1Signature, BlsSignature, etc.)

Migration Guide

Import Changes

Hashing Methods

Type Changes

Constructor Changes

Complete Example

Type Hierarchy

Keccak256Hash extends Bytes32, inheriting all Bytes32 methods while adding Keccak256-specific semantics:
This means all Bytes32 operations work on Keccak256Hash:
  • Construction: Bytes32.from(), Bytes32.fromHex()
  • Conversion: Bytes32.toHex(), Bytes32.toBytes()
  • Validation: Bytes32.equals(), Bytes32.isZero()
  • Utilities: Bytes32.slice(), Bytes32.concat()

Where to Find

Keccak256Hash Type

/crypto/keccak256/hash - Type definition, branded type system, constructor methods

Hashing Methods

/crypto/keccak256/index - Main hashing functions: hash(), hashHex(), hashString()

Implementations

/crypto/keccak256/implementations - Native (keccak-asm), WASM (ReleaseSmall/ReleaseFast), JavaScript fallback