Skip to content

feat: add Groth16 zk-proof verifier for anonymous meter readings (#64) - #79

Merged
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/zk-meter-reading-verifier
Jun 26, 2026
Merged

feat: add Groth16 zk-proof verifier for anonymous meter readings (#64)#79
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
real-venus:feat/zk-meter-reading-verifier

Conversation

@real-venus

Copy link
Copy Markdown
Contributor

Zero-Knowledge Proof Verifier for Anonymous Meter Reading Submissions (#64)

Closes #64

What's included

File Responsibility
src/types/zk.ts Shared types: private/public circuit signals, proof, verification key, submission state, worker messages, and range/freshness bounds.
src/services/keyCache.ts IndexedDB cache for the ~150 MB proving key — resumable downloads via HTTP Range requests, SHA-256 integrity check, and LRU eviction.
src/workers/zkProver.worker.ts Web Worker running the snarkjs Groth16 prover off the main thread; lazily loads snarkjs (local module → pinned ESM CDN). Returns { proof, publicSignals }.
src/services/zkProver.ts Orchestrator. prepareInputs() validates the reading and builds the witness (field elements → decimal strings, random 248-bit salt); generateProof() caches the key, drives the worker (zkey transferred, not copied), returns a proof hash.
src/services/zkVerifier.ts Fetches the verification key from the Soroban zk_verification_key data entry, caches it 24h, runs groth16.verify.
src/hooks/useZKSubmission.ts React hook exposing the prove → submit → verify pipeline with weighted progress (0–100), status, proofHash, plus cancel/reset.
src/components/panels/ZKSubmissionPanel.tsx Stepper UI (cache key → prove → submit → verify) with progress bar, input validation, cancel, and proof-hash display.
public/wasm/zk/ Artifact placeholders + README (real circuit_final.zkey is CDN-hosted; configured via NEXT_PUBLIC_ZK_ZKEY_URL / NEXT_PUBLIC_ZK_ZKEY_SHA256).
tests/unit/zkProver.test.ts, tests/unit/keyCache.test.ts Input validation/range bounds, salt generation, hex→field conversion, SHA-256 integrity vectors.

…lity-Protocol#64)

Implements a zero-knowledge proof module that lets field operators submit an
encrypted meter reading with a Groth16/BLS12-381 proof that the reading is in
range and from a registered meter, without revealing the value or meter ID.

- types/zk.ts: shared circuit input/proof/state types and bounds
- services/keyCache.ts: IndexedDB cache for the ~150MB proving key with
  resumable Range-request downloads, SHA-256 integrity and LRU eviction
- workers/zkProver.worker.ts: off-main-thread snarkjs Groth16 prover
- services/zkProver.ts: input validation/witness assembly and worker driver
- services/zkVerifier.ts: fetches the on-chain verification key, caches 24h,
  runs groth16Verify
- hooks/useZKSubmission.ts: prove -> submit -> verify pipeline with progress
- components/panels/ZKSubmissionPanel.tsx: stepper UI with progress bar
- public/wasm/zk: artifact placeholders + docs (real zkey is CDN-hosted)
- tests for input validation and integrity hashing
@elizabetheonoja-art
elizabetheonoja-art merged commit fc63e50 into Utility-Protocol:main Jun 26, 2026
4 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.

Zero-Knowledge Proof Verifier for Anonymous Meter Reading Submissions Using Groth16 over BLS12-381

2 participants