Skip to content

feat: WASM build target + single-threaded prover#79

Merged
MatteoMer merged 1 commit into
mainfrom
feat/wasm-target
Apr 14, 2026
Merged

feat: WASM build target + single-threaded prover#79
MatteoMer merged 1 commit into
mainfrom
feat/wasm-target

Conversation

@MatteoMer

Copy link
Copy Markdown
Owner

Summary

  • Add wasm32-freestanding compilation support, enabling Zolt to run in browsers and on phones for client-side proving
  • Conditional ThreadPool type: native work-stealing pool vs WASM sequential stub with identical API
  • Platform-gated OS dependencies (std.time, std.posix.getenv, std.Thread, std.fs, std.debug.print) across the entire prover pipeline
  • New WASM-friendly C API: zolt_load_elf_bytes (byte-slice ELF loading), zolt_proof_result_ptr, optional thread pool
  • Dory SRS loadFromBytes for passing pre-serialized SRS from JS host memory
  • Fix u64usize truncations and u6Log2Int(usize) shift amounts across 15+ files for 32-bit wasm32

Test plan

  • zig build -Dtarget=wasm32-freestanding -Doptimize=ReleaseFast compiles with zero errors
  • zig build (native) compiles with zero errors
  • zig build test (native) passes all tests
  • zig build fmt passes

🤖 Generated with Claude Code

Enable Zolt to compile for wasm32-freestanding, the foundation for
client-side proving in browsers and on phones.

Key changes:
- ThreadPool: conditional type — native work-stealing pool vs WASM
  sequential stub with identical API surface
- MSM: gate bare std.Thread spawns, fall back to sequential Pippenger
- Dory SRS: gate filesystem caching, add loadFromBytes for WASM,
  setupCached falls back to in-memory generation on WASM
- Prover pipeline: platform-gated Timer/getenv/debug.print wrappers
  in debug.zig, used across all spartan stages and jolt_prover
- Build system: gate executables/tests/benchmarks/Metal behind !is_wasm
- C API: add zolt_load_elf_bytes (byte-slice ELF loading),
  zolt_proof_result_ptr, WASM allocator, optional thread pool
- Fix u64→usize truncations across 15+ files for 32-bit wasm32
- Fix u6→Log2Int(usize) shift amounts for 32-bit shift registers

Verified: zig build -Dtarget=wasm32-freestanding -Doptimize=ReleaseFast
produces libzolt_capi.a with zero errors. Native build and tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MatteoMer MatteoMer merged commit 880a893 into main Apr 14, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant