Skip to main content
Voltaire is a Zig library at its core. The TypeScript and native bindings you install from npm are pre-built artifacts optimized for bundle size (ReleaseSmall). Building from source unlocks capabilities not available in the distributed packages.

Why Build From Source

Performance Optimization

npm distributions use ReleaseSmall which prioritizes bundle size over raw speed. Building from source with ReleaseFast yields measurable performance gains:
For native FFI, the difference is even more significant since native code benefits from aggressive LLVM optimizations:

Granular Tree-Shaking

The full Voltaire WASM bundle includes all primitives and crypto. If you only need specific functionality, build individual WASM modules:
This produces 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:
Pre-built distributions only ship macOS (arm64/x64), Linux (arm64/x64), and Windows (x64). Building from source lets you target:
  • 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:
Benefits:
  • 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

The npm ecosystem has demonstrated systemic vulnerability to supply chain attacks that specifically target cryptocurrency applications.

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 hooked window.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:
  1. Compromise trusted maintainer accounts
  2. Inject malicious code into popular packages
  3. Target cryptocurrency wallets specifically
  4. Exist for hours before detection

Defense Through Source Builds

Building from source with vendored dependencies eliminates npm as an attack vector:
What this eliminates:
  • 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)
We encourage anyone handling significant value to build from source. The cryptocurrency industry faces unique risk from supply chain attacks, and source builds are the only complete mitigation.

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

Learn More

Getting Started

Standard installation via npm/bun

Branded Types

Type-safe primitives with zero overhead