Skip to main content

Try it Live

Run Keccak256 examples in the interactive playground
Future Plans: This page is planned and under active development. Examples are placeholders and will be replaced with accurate, tested content.

Keccak256 Implementation Guide

Voltaire provides two Keccak256 implementations optimized for different deployment scenarios. All share the same data-first API, enabling transparent algorithm swapping.

Implementation Comparison

When to Use Each Implementation

WASM (Default)

Use when:
  • Default choice for most applications
  • Better performance than pure JavaScript
  • Smaller bundle size than pure JavaScript alternatives
Characteristics:
  • Pros: Better performance, smaller bundle
  • Cons: Async init required
  • Bundle: Smaller than @noble/hashes

Pure TypeScript

Use when:
  • Need to avoid WASM dependency
  • Debugging or development scenarios
  • Specific compatibility requirements
Characteristics:
  • Pros: Zero setup, runs everywhere, synchronous, no WASM
  • Cons: Larger bundle than WASM
  • Bundle: ~25KB (minified @noble/hashes)

Platform Compatibility

Browsers

  • ✅ WASM (Default)
  • ✅ Pure TypeScript

Node.js / Bun / Deno

  • ✅ WASM (Default)
  • ✅ Pure TypeScript

Edge Runtimes (Cloudflare, Vercel)

  • ✅ WASM (Default)
  • ✅ Pure TypeScript

Initialization Requirements

Synchronous (No Init)

Pure TypeScript implementation is ready immediately:

Asynchronous (Init Required)

WASM variant requires async initialization:
Important: WASM init is idempotent - calling init() multiple times is safe.

Bundle Size

WASM (Default)

Smaller than pure JavaScript alternatives:
  • Zig stdlib Keccak-256 implementation
  • Part of main WASM bundle
  • Smaller than @noble/hashes when considering full implementation

Pure TypeScript

Includes @noble/hashes dependencies:
  • Full @noble/hashes/sha3 module (~25KB)
  • Tree-shakeable (only Keccak-256 if unused)

Selection Decision Tree

Migration Examples

From Pure TypeScript to WASM

Conditional Selection