Skip to content

Implement ZK-Proof Generation Wrapper using SnarkJS #69

Description

@Lakes41

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

  • Generating a proof does not block the browser's UI rendering.
  • Automatically downloads zkey and wasm files from a CDN if they are not cached locally.
  • Outputs formatted calldata that successfully executes against the on-chain verifier.

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.

Metadata

Metadata

Assignees

Labels

GrantFox OSSRelated to GrantFox Open Source Software initiativesMaybe RewardedPotential for a reward based on contributionOfficial Campaign | FWC26Period after the official FIFA World Cup 2026 campaignexpertRequires expert level knowledge or skillsfeatureNew feature or requestperformancePerformance improvements

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions