Skip to content

Cryptographic Proof-of-Reserve Verification Module for Cross-Chain Asset Backing #52

Description

@elizabetheonoja-art

Problem Statement / Feature Objective

Operators must verify that on-chain asset reserves (e.g., tokenized utility credits) are fully backed by off-chain physical resources. A cryptographic Proof-of-Reserve (PoR) module must run client-side, fetching Merkle-summary commitments from Soroban contract storage, querying the operator's own audited resource inventory via REST, and computing a non-interactive zero-knowledge range proof that the off-chain total exceeds the on-chain liability. The resulting proof is submitted as a Soroban transaction for on-chain attestation, providing a cryptographically verifiable audit trail without revealing individual meter readings.

Technical Invariants & Bounds

  • Merkle tree depth: 20 levels for up to 1,048,576 meter endpoints. Each leaf is SHA-256( meterId || consumption || salt ).
  • Proof type: Bulletproofs-style range proof using the dalek-cryptography/bulletproofs library compiled to WASM. Range: [0, 2^64) with 64-bit commitment.
  • Off-chain inventory aggregation: REST endpoint GET /api/resources/audit?from={ts}&to={ts} returns cumulative consumption per resource class with a signed server timestamp.
  • On-chain commitment: Soroban contract stores the Merkle root (bytes32), total liability (i128), and last audit ledger number.
  • Computation budget: WASM proof generation must complete within 5 seconds on a mid-range field tablet (Snapdragon 7c). WASM binary size must not exceed 2 MB gzipped.

Codebase Navigation Guide

  • src/services/proofOfReserve.ts - Orchestrator: fetches on-chain commitment, off-chain inventory, invokes WASM prover.
  • src/workers/proofWorker.worker.ts - Dedicated Web Worker loading the WASM module; receives JSON input, runs proof generation, returns proof bytes.
  • src/utils/merkleTree.ts - Merkle tree construction: building leaf nodes, computing root, generating Merkle proof paths.
  • src/utils/wasmLoader.ts - Helper to fetch, instantiate, and cache WASM module from public/wasm/ directory.
  • src/hooks/useProofOfReserve.ts - React hook providing proof generation status, progress (0-100%), and result state.
  • src/components/panels/ReserveAttestationPanel.tsx - UI panel showing latest attestation, proof hash, and verification status.

Implementation Blueprint

  1. Compile bulletproofs WASM binary using wasm-pack with target bundler. Place output in public/wasm/bulletproofs.wasm with a versioned integrity hash.
  2. Write src/utils/merkleTree.ts: buildTree(leaves) returns root; generateProof(leafIndex) returns sibling path. Use incremental SHA-256 via SubtleCrypto API to keep the main thread responsive.
  3. In src/services/proofOfReserve.ts: (a) call Soroban contract to fetch on-chain Merkle root and totalLiability; (b) call REST audit endpoint to get off-chain aggregated consumption; (c) if off-chain total < on-chain liability, abort with insolvency warning; (d) otherwise, format inputs and post to the worker.
  4. In proofWorker.worker.ts: instantiate WASM module, accept { merkleRoot, totalLiability, auditTotal, randomness }, invoke the prover, return { proof, commitment, challenge }.
  5. Back on the main thread, assemble a Soroban transaction that calls attestReserve(proof, commitment) and submit via src/services/soroban.ts.
  6. The hook useProofOfReserve wraps this flow with progress events (25% fetch, 50% proving, 75% submitting, 100% confirmed).
  7. Display the attestation result in ReserveAttestationPanel: attestation hash, block number, time since last proof, and a red banner if insolvency detected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions