Try it Live
Run Keccak256 examples in the interactive playground
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
| Implementation | Bundle Size | Init Required | Platform Support |
|---|---|---|---|
| WASM (Default) | Smaller than pure JS | Yes (async) | All modern browsers/runtimes |
| Pure TypeScript | ~25KB (@noble) | No | Universal |
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
- 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
- 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: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
Related
- Keccak256 API Reference - Main documentation
- Cryptography Overview - All crypto functions
- WASM Guide - WASM deployment details
- Performance Benchmarks - Detailed benchmark results

