feat: cryptographic proof-of-reserve verification module (#52) - #85
Merged
elizabetheonoja-art merged 1 commit intoJun 25, 2026
Merged
Conversation
…tocol#52) Lets operators prove that on-chain liabilities are fully backed by off-chain audited reserves via a Bulletproofs-style range proof, without revealing individual meter readings. - types/reserve.ts: commitment/audit/proof-input/range-proof/attestation types and bounds (Merkle depth 20, [0,2^64) range, 2MB WASM, 5s budget) - utils/porMerkle.ts: SHA-256 Merkle tree (leaf = SHA-256(meterId||u64 consumption||salt)) with buildTree/computeRoot/generateProof/verifyProof and odd-layer padding; dedicated module so the existing WASM merkleTree.ts is untouched - utils/wasmLoader.ts: adds a generic fetch+SHA-256-integrity+cache loader (loadWasmModule) alongside the existing loadMerkleWasm - services/proofOfReserve.ts: fetch commitment + audit, aggregate, solvency gate (throws InsolvencyError), build 64-bit-bounded inputs, drive the prover, hash + optionally submit the attestation, with fetch→prove→submit→confirm progress - workers/proofWorker.worker.ts: loads/verifies the Bulletproofs WASM off-thread with a clearly-marked deterministic dev placeholder until the binary ships - hooks/useProofOfReserve.ts: status/progress/result + insolvency state - components/panels/ReserveAttestationPanel.tsx: attestation hash, ledger, time since last proof, red insolvency banner - tests for the Merkle tree (root/proof/tamper/padding) and the orchestrator (aggregation, solvency abort, range bound, full-flow progress)
elizabetheonoja-art
approved these changes
Jun 25, 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.
Cryptographic Proof-of-Reserve Verification Module (#52)
Closes #52
What's included
src/types/reserve.ts[0,2^64)range, 2 MB WASM, 5 s budget).src/utils/porMerkle.tsSHA-256(meterId ‖ u64LE(consumption) ‖ salt)—buildTree/computeRoot/generateProof/verifyProofwith odd-layer padding, via SubtleCrypto. Dedicated module so the existing WASM-backedmerkleTree.ts(used bymerkleWorker) is untouched.src/utils/wasmLoader.tsloadWasmModule(url, {integrity, imports})with fetch + SHA-256 integrity verification + caching, alongside the existingloadMerkleWasm.src/services/proofOfReserve.tsInsolvencyError), builds 64-bit-bounded inputs, drives the prover, hashes + optionally submits the attestation; emits fetch→prove→submit→confirm progress. All I/O injectable.src/workers/proofWorker.worker.tssrc/hooks/useProofOfReserve.tsstatus/progress(25→50→75→100)/result+ insolvency state.src/components/panels/ReserveAttestationPanel.tsxpublic/wasm/bulletproofs.README.mdtests/unit/*