feat: add Groth16 zk-proof verifier for anonymous meter readings (#64) - #79
Merged
elizabetheonoja-art merged 1 commit intoJun 26, 2026
Conversation
…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
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Zero-Knowledge Proof Verifier for Anonymous Meter Reading Submissions (#64)
Closes #64
What's included
src/types/zk.tssrc/services/keyCache.tsRangerequests, SHA-256 integrity check, and LRU eviction.src/workers/zkProver.worker.ts{ proof, publicSignals }.src/services/zkProver.tsprepareInputs()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.tszk_verification_keydata entry, caches it 24h, runsgroth16.verify.src/hooks/useZKSubmission.tsprove → submit → verifypipeline with weightedprogress(0–100),status,proofHash, pluscancel/reset.src/components/panels/ZKSubmissionPanel.tsxpublic/wasm/zk/circuit_final.zkeyis CDN-hosted; configured viaNEXT_PUBLIC_ZK_ZKEY_URL/NEXT_PUBLIC_ZK_ZKEY_SHA256).tests/unit/zkProver.test.ts,tests/unit/keyCache.test.ts