Background
Whitechain includes privacy-preserving governance voting. The smart contracts require Groth16 zk-SNARK proofs to validate votes.
Problem
Generating zk-proofs on the client side (browser) is computationally heavy and requires complex WASM integrations, compiling constraint systems, and managing proving keys.
Expected Outcome
A highly optimized SDK module that abstracts SnarkJS logic, dynamically loads proving keys via Web Workers to prevent UI freezing, and outputs on-chain ready calldata.
Suggested Implementation
- Create
src/zk/Prover.ts.
- Integrate
snarkjs (as an optional peer dependency to prevent bloat for non-ZK users).
- Implement a Web Worker script to offload the
snarkjs.groth16.fullProve computation off the main thread.
- Implement a formatting utility that converts the SnarkJS JSON output into the exact
uint256[8] array structure required by the Solidity verifier.
Acceptance Criteria
Likely Affected Files
src/zk/Prover.ts
src/zk/worker.js
Requirements
- The WASM files are too large to bundle. The module must securely fetch them at runtime and verify their integrity (hashes) before execution.
Background
Whitechain includes privacy-preserving governance voting. The smart contracts require Groth16 zk-SNARK proofs to validate votes.
Problem
Generating zk-proofs on the client side (browser) is computationally heavy and requires complex WASM integrations, compiling constraint systems, and managing proving keys.
Expected Outcome
A highly optimized SDK module that abstracts SnarkJS logic, dynamically loads proving keys via Web Workers to prevent UI freezing, and outputs on-chain ready calldata.
Suggested Implementation
src/zk/Prover.ts.snarkjs(as an optional peer dependency to prevent bloat for non-ZK users).snarkjs.groth16.fullProvecomputation off the main thread.uint256[8]array structure required by the Solidity verifier.Acceptance Criteria
zkeyandwasmfiles from a CDN if they are not cached locally.Likely Affected Files
src/zk/Prover.tssrc/zk/worker.jsRequirements