ReleaseSmall). Building from source unlocks capabilities not available in the distributed packages.
Why Build From Source
Performance Optimization
npm distributions useReleaseSmall which prioritizes bundle size over raw speed. Building from source with ReleaseFast yields measurable performance gains:
Granular Tree-Shaking
The full Voltaire WASM bundle includes all primitives and crypto. If you only need specific functionality, build individual WASM modules:wasm/crypto/*.wasm files you can load independently:
Custom Platform Targets
Zig’s cross-compilation is best-in-class. Build for any platform supporting C FFI:- Embedded systems (ARM Cortex, RISC-V, MIPS)
- Exotic operating systems (FreeBSD, NetBSD, Haiku)
- Custom architectures with C FFI support
- WebAssembly variants (wasm32-freestanding vs wasm32-wasi)
Vendored Dependencies
Building from source means you control every byte of code that executes:- Audit everything - No opaque binaries, every line is reviewable
- Contribute upstream - Make changes and submit PRs easily
- LLM context - Full codebase available for AI-assisted development
- Reproducible builds - Same source always produces same output
Supply Chain Security
Recent Attacks
September 2025: A phishing attack compromised 18 npm packages with 2+ billion weekly downloads (chalk, debug, ansi-styles). Malicious code injected wallet-draining malware that hookedwindow.ethereum and Solana APIs.
December 2024: The @solana/web3.js library was backdoored (CVE-2024-54134) through spear-phishing, stealing private keys from developers.
These attacks share a pattern:
- Compromise trusted maintainer accounts
- Inject malicious code into popular packages
- Target cryptocurrency wallets specifically
- Exist for hours before detection
Defense Through Source Builds
Building from source with vendored dependencies eliminates npm as an attack vector:- npm registry as single point of failure
- Account compromise attacks (no accounts to compromise)
- Malicious version injection (you control the commits)
- Typosquatting attacks (no package names to confuse)
Build Prerequisites
Quick Start
Build Commands Reference
Core Builds
TypeScript/WASM Builds
Cross-Platform Builds
Testing
WASM Build Modes
Zig supports two primary WASM targets:wasm32-wasi (Default)
Used when C libraries are involved (blst, c-kzg, Rust crypto):- Requires WASI runtime (browser polyfills available)
- Full libc support
- All crypto features enabled
wasm32-freestanding
For pure Zig code without C dependencies:- No WASI requirements
- Smaller output
- Limited to pure Zig implementations
Optimization Modes
ReleaseSmall is 20-40% smaller than ReleaseFast but can be 10-30% slower for compute-intensive operations like cryptographic primitives.
External Resources
- Zig 0.15.1 Release Notes - Language reference
- Zig Build System Guide - Intermediate build system usage
- WebAssembly with Zig - WASM tutorial
- Zig Cross-Compilation - Target triples and flags
- WASM Target Reference - wasm32-wasi vs freestanding
Learn More
Getting Started
Standard installation via npm/bun
Branded Types
Type-safe primitives with zero overhead

