Skip to content

Latest commit

ย 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

VeilCred (ZK-Appraise)

Privacy-Preserving Home Equity Appraisal & Lending Protocol on Midnight Network

Midnight Network ZKML Proving Engine AI Engine Frontend MIT License


๐Ÿ  Overview

VeilCred enables homeowners to unlock decentralized finance (DeFi) liquidity against their real estate equity without exposing sensitive property data, street addresses, appraisal figures, or personal identities to public blockchains.

By combining local client-side AI valuations (ONNX), Zero-Knowledge Machine Learning proofs (Halo2 / EZKL), and Midnight Network confidential smart contracts (Compact), VeilCred allows borrowers to prove collateral eligibility (Appraised Value โ‰ฅ Loan Threshold) and qualify for up to 75% LTV credit tiersโ€”completely in zero-knowledge.

   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   โ”‚  1. Property Intake  โ”‚ โ”€โ”€โ”€โ”€> โ”‚  2. Local AI & ZKML  โ”‚ โ”€โ”€โ”€โ”€> โ”‚ 3. Midnight Compact  โ”‚
   โ”‚  Zero-telemetry specsโ”‚       โ”‚  In-browser Halo2 ZK โ”‚       โ”‚ Private state & loan โ”‚
   โ”‚  kept on your device โ”‚       โ”‚  KZG proof on BN254  โ”‚       โ”‚ outcome unlocked     โ”‚
   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โšก The Problem vs. The VeilCred Solution

Dimension Traditional Home Equity Loans VeilCred (ZK-Appraise)
Property Privacy Street address, parcel deeds & photos made public ๐Ÿ”’ 100% Private โ€” raw specs never leave your browser
Financial Privacy Full appraisal dollars and loan amounts exposed on-chain ๐Ÿ”’ Zero-Knowledge โ€” only eligibility tiers recorded
Identity Linkage Wallet address directly bound to physical property title ๐Ÿ”’ Unlinkable Identity โ€” derived UserPublicKey + PIN
Attestation Centralized, slow manual paper trail โšก Cryptographic โ€” Jubjub Schnorr attestations & Merkle proofs
Double-Spend Risk Subject to manual title searches โšก Mathematical โ€” Poseidon nullifiers prevent re-pledging

๐Ÿš€ How It Works

sequenceDiagram
    autonumber
    actor User as Homeowner (Client)
    participant Model as Local ONNX Model
    participant Prover as EZKL Prover (Wasm)
    participant Oracle as Licensed Appraiser
    participant Midnight as Midnight Compact Ledger

    Note over User,Model: 1. Zero-Telemetry Valuation
    User->>Model: Ingest Specs (Sqft, Age, Rooms, Location Score)
    Model-->>User: Compute Estimated Valuation (y_val) locally

    Note over User,Prover: 2. Client-Side ZK Proving
    User->>Prover: Generate Halo2 / KZG SNARK Proof (ฯ€)
    Prover-->>User: Output Proof (ฯ€) proving: Appraised Value โ‰ฅ Threshold

    Note over User,Oracle: 3. Cryptographic Attestation
    User->>Oracle: Submit Appraisal Hash + Derived Identity (userPk)
    Oracle-->>User: Issue Jubjub Schnorr Signature (ฯƒ)

    Note over User,Midnight: 4. Private Settlement & Verification
    User->>Midnight: Submit requestAppraisalVerification(Threshold, PIN, Witness, ฯ€)
    Midnight->>Midnight: 1. In-circuit Schnorr & Merkle root verification
    Midnight->>Midnight: 2. Enforce Poseidon nullifier (anti-double-pledge)
    Midnight->>Midnight: 3. Grant collateral tier in private ledger state
    Midnight-->>User: Collateral confirmed & loan entitlement issued
Loading

๐Ÿ’Ž Loan Eligibility & Collateral Tiers

VeilCred dynamically classifies collateral into automated credit tiers based on verified property value:

Tier Level Valuation Floor Max Eligible Loan LTV Ceiling Approval Mode
๐Ÿฅ‡ Tier 1 (Platinum) โ‰ฅ $1,000,000 $750,000 75% Instant Approval
๐Ÿฅˆ Tier 2 (Gold) โ‰ฅ $750,000 $525,000 70% Instant Approval
๐Ÿฅ‰ Tier 3 (Silver) โ‰ฅ $500,000 $325,000 65% Standard Protocol Review
๐ŸŽ–๏ธ Tier 4 (Bronze) โ‰ฅ $300,000 $180,000 60% Standard Protocol Review

๐ŸŽจ Web Application Features

The VeilCred DApp is designed for maximum speed, privacy, and visual excellence:

  • ๐Ÿ›ก๏ธ Zero-Telemetry Property Intake: Enter living area, structural age, bedroom/bathroom counts, and socioeconomic indices without transmitting data to any backend server.
  • ๐Ÿงฎ Real-Time Loan Calculator: Interactive sliders compute real-time LTV ratios, maximum borrowing capacity, and monthly payment estimates.
  • โšก Multi-Engine Prover Architecture:
    • In-Browser Web Worker (Wasm): Generates Halo2/KZG SNARK proofs client-side without UI freezing.
    • Local Native Daemon: High-speed desktop proof acceleration adapter.
    • Dev Simulator: Instant cryptographic simulation mode for rapid offline testing.
  • ๐Ÿ’ผ Midnight Lace Wallet Integration: Seamless one-click wallet connectivity for confidential contract execution.
  • ๐Ÿ”ฎ Dark Glassmorphism Interface: Smooth gradient mesh background, responsive mobile layouts, and animated state progression badges.

๐Ÿ”’ Privacy & Public Ledger Boundaries

Data Element Type Storage / Processing Public Visibility
Property Specs & Address Private Input Client Browser Only โŒ Zero-Knowledge (Never leaves device)
Exact Valuation Figure Private Witness Client & Appraiser Secret โŒ Hidden in SNARK Proof
Applicant Secret Key & PIN Secret Witness Client Wallet Session โŒ Never Broadcast
Appraiser Jubjub Signature Schnorr Signature Private Witness Input โŒ Verified In-Circuit
Appraisal Commitment Hash Commitment Merkle Tree (MerkleTree<16, Bytes<32>>) โœ… Hash Only (Unlinkable)
Appraisal Nullifier Spend Nullifier Nullifier Set (Set<Bytes<32>>) โœ… One-Time Spend Marker
Derived User Public Key Domain Identifier Ledger Map Index โœ… Unlinkable to Primary Wallet
Loan Status & Tier Outcome Struct Public Ledger State โœ… Authorized Tier & Status

๐Ÿ—๏ธ Core Technology Stack

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                            FRONTEND & CLIENT                                โ”‚
โ”‚   React 18  โ€ข  TypeScript  โ€ข  Vite  โ€ข  TailwindCSS  โ€ข  WebAssembly Workers  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                            ZKML PROVING ENGINE                              โ”‚
โ”‚    EZKL  โ€ข  Halo2 (KZG Commitments)  โ€ข  BN254 Curve  โ€ข  INT8 Quantization   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                           AI VALUATION ENGINE                               โ”‚
โ”‚      PyTorch 2.x  โ€ข  ONNX Runtime  โ€ข  California Housing Feature Model      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                       โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         MIDNIGHT NETWORK LEDGER                             โ”‚
โ”‚     Compact 0.26  โ€ข  Jubjub Curves  โ€ข  Poseidon Sponges  โ€ข  Midnight.js     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start Guide

Prerequisites

  • Node.js: v18.0.0 or higher
  • Python: 3.10 or 3.11

1. Clone & Install Dependencies

git clone https://github.com/vishaltn74-dev/zk-appraise.git
cd zk-appraise

# Install root dependencies
npm install

2. Launch the Frontend DApp

cd frontend
npm install
npm run dev

Open http://localhost:5173 (or http://localhost:3000) in your browser to experience the VeilCred interface.

3. Run the Smart Contract Test Suite

# From repository root
npm test

4. (Optional) Train & Export AI Valuation Model

# Setup Python environment
python -m venv .venv
# Activate: .venv\Scripts\Activate.ps1 (Windows) or source .venv/bin/activate (Linux/Mac)
pip install -r ai-engine/requirements.txt
pip install -e .

# Train model and export ONNX graph
python ai-engine/train_valuation_model.py

๐Ÿ“‚ Repository Structure

zk-appraise/
โ”œโ”€โ”€ frontend/                         # React 18 / Vite DApp & Web Worker Prover
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/               # Hero, PropertyIntakeForm, LoanCalculator, SiteNav
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                    # useMidnightContract state machine hook
โ”‚   โ”‚   โ”œโ”€โ”€ services/                 # contractBridge, proofService, prover adapters
โ”‚   โ”‚   โ””โ”€โ”€ workers/                  # prover.worker.ts (Wasm proof synthesis)
โ”‚   โ””โ”€โ”€ public/wasm/                  # Bundled EZKL WebAssembly runtime
โ”‚
โ”œโ”€โ”€ contracts/                        # Midnight Compact privacy smart contracts
โ”‚   โ”œโ”€โ”€ appraiser_verifier.compact    # Full appraisal attestation & loan state machine
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ AppraisalVerifier.compact # Modular proof verification circuit
โ”‚   โ”‚   โ”œโ”€โ”€ LoanCollateralPool.compact# Private borrower records & disbursement
โ”‚   โ”‚   โ””โ”€โ”€ NullifierRegistry.compact # Replay & double-pledge prevention
โ”‚   โ””โ”€โ”€ tests/
โ”‚       โ””โ”€โ”€ collateral_pool.test.ts   # Vitest contract simulation suite
โ”‚
โ”œโ”€โ”€ zk-circuits/                      # ZKML circuit definitions & compiled artifacts
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ model_gen.py              # PyTorch model topology & ONNX exporter
โ”‚   โ”‚   โ”œโ”€โ”€ circuit_builder.py        # EZKL settings calibration & Halo2 keygen
โ”‚   โ”‚   โ”œโ”€โ”€ export_abi.py             # Verification ABI & verification key exporter
โ”‚   โ”‚   โ””โ”€โ”€ verify_standalone.py      # Standalone auditor CLI verifier
โ”‚   โ”œโ”€โ”€ model.onnx                    # Serialized ONNX computational graph
โ”‚   โ””โ”€โ”€ CIRCUIT_MANIFEST.md           # Production circuit manifest & frozen VK hash
โ”‚
โ”œโ”€โ”€ ai-engine/                        # Python ML training & dataset loader
โ”‚   โ”œโ”€โ”€ train_valuation_model.py      # Deterministic model training & ONNX export
โ”‚   โ”œโ”€โ”€ dataset_loader.py             # Feature extractor & validation pipeline
โ”‚   โ””โ”€โ”€ model_config.py               # Canonical model configuration
โ”‚
โ””โ”€โ”€ docs-pitch/                       # Architecture blueprints & execution plans
    โ”œโ”€โ”€ PLAN.md                       # Comprehensive engineering project plan
    โ””โ”€โ”€ AGENTS.md                     # Multi-agent role specifications

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.

Built with ๐Ÿ’œ for the Midnight Network Ecosystem.

About

ZK-Appraise: A ZKML app enabling home equity borrowers to prove DeFi loan collateral eligibility via local AI real estate valuations. It generates cryptographic proofs without exposing raw property specs or addresses to public ledgers. Tech Stack: Python/ONNX, EZKL, Midnight Compact, React.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages