๐Ÿ” Inspiration

Every loan application is a privacy violation in disguise.

When you apply for a mortgage, car loan, or DeFi credit line โ€” you hand over everything: income statements, bank records, debt schedules, personal identifiers. This data gets stored indefinitely, sold to brokers, and breached in cyberattacks. Over 1.4 billion financial records were exposed in 2023 alone.

The lender needs to know one thing: "Can this person repay?"
They don't need your salary. They don't need your bank account.
They don't need your address.

That question kept me up. And that's how PrivateLens was born.


๐Ÿ—๏ธ What I Built

PrivateLens is the world's first ZK + AI credit scoring protocol on Midnight Network. It lets users mathematically prove their creditworthiness without revealing a single piece of raw financial data.

Here's the flow:

  1. User enters financial data โ€” income, debts, credit age, assets
  2. Groq AI (LLaMA 3.1) computes a credit score locally (300โ€“850)
  3. Compact ZK circuit seals the score โ€” generates a zero-knowledge proof
  4. Midnight devnet verifies and records the proof on-chain
  5. Lender sees: Score โœ… ยท Eligibility โœ… ยท Raw data: โœ— Never

The privacy boundary is enforced by cryptographic law, not a privacy policy.

ZK Credential System (inspired by ZKGate โ€” my previous winning project)

Based on the score, the system auto-issues soulbound on-chain credentials:

Credential Requirement
CREDIT_VERIFIED Score โ‰ฅ 650
PRIME_BORROWER Score โ‰ฅ 720
INCOME_QUALIFIED DTI โ‰ค 36%
LOW_RISK_PROFILE AI risk: LOW
DEBT_CLEAR DTI โ‰ค 30%

These credentials unlock ZK-gated DeFi lending pools โ€” protocols verify the badge, never the underlying data.

The Math Behind It

The ZK proof asserts:

$$\exists \text{ score } S \text{ such that } S \geq 650 \text{ and } H(\text{inputs}) = \text{commitment}$$

Without revealing \( S \) or any input that produced it.


โš™๏ธ How I Built It

Frontend: React 18 + Vite + Tailwind CSS โ€” built a full "cryptographic terminal" design system from scratch. No UI component libraries. Every animation, every glowing hex node, every typewriter effect is custom CSS and React state.

AI Layer: Groq SDK with llama-3.1-8b-instant โ€” sub-second credit score inference using standard financial methodology (DTI ratio, payment history, credit age, asset backing). The prompt is carefully engineered to return a structured JSON score with no hallucination.

ZK Layer: Compact smart contract on Midnight Network โ€” the storeMessage transaction commits the encrypted score. The proof server runs locally via Docker.

Credential Engine: Node.js + Express backend with a Merkle tree commitment scheme and nullifier system to prevent replay attacks. Every issued credential gets a unique commitment hash added to the Merkle root.

Wallet: Lace DApp connector (window.midnight.mnLace) โ€” built a custom hook with polling retry logic to handle async extension injection. Added full demo mode for judges without Lace installed.


๐Ÿง— Challenges I Faced

1. Midnight's Lace wallet detection
The extension injects window.midnight.mnLace asynchronously โ€” if the user connects before the extension has loaded, detection fails silently. Built a polling retry system that checks every 250ms for up to 6 seconds, distinguishes 3 error states (LACE_NOT_FOUND, LACE_CONNECTOR_MISSING, CONNECTION_REJECTED), and surfaces clear instructions for each.

2. ZK proof UX
Zero-knowledge proof generation feels like a black box to users. Solved this with a cinematic terminal log โ€” 9 timestamped lines appear one by one with typewriter animation, showing exactly what's happening cryptographically. Makes the invisible visible.

3. Making privacy tangible
"Your data is private" is a claim everyone makes. Making judges feel the privacy required the redacted shimmer bars in the Lender View โ€” actual financial fields visually sealed with animated shimmer, not just hidden. The DeFi pool gating makes the credential system real, not theoretical.

4. The Privacy Trilemma
Traditional finance forces you to choose: Privacy OR Compliance OR Decentralization. Designing the UI to communicate "PrivateLens gives you all three" required the animated SVG triangle visualization โ€” each vertex lights up sequentially, then all three lock green simultaneously.


๐Ÿ“š What I Learned

  • Compact language for writing ZK circuits on Midnight โ€” completely different mental model from Solidity. Privacy is a first-class primitive, not an afterthought.
  • ZK credential architecture โ€” Merkle commitments + nullifiers prevent double-spending of proofs. The same pattern that makes ZKGate work for identity works for credit.
  • Groq inference speed โ€” LLaMA 3.1 at Groq's speed changes what's possible. Credit scoring that used to take days now takes 800ms.
  • Privacy UX โ€” Making cryptographic guarantees feel real to non-technical users is the hardest design problem in Web3.

๐Ÿš€ What's Next

  • Mainnet deployment on Midnight when it launches
  • Protocol SDK โ€” any DeFi protocol integrates ZK credit in 3 lines
  • Multi-issuer credentials โ€” banks, credit bureaus issue ZK-signed data
  • Cross-chain credit portability โ€” your ZK score works everywhere
  • Mobile app โ€” ZK credit proof in your pocket

Built for Midnight Network Hackathon 2026 by J Madhan @ GPS AI Labs
6x Hackathon Winner ยท Privacy-First AI Infrastructure

Built With

  • aes-256
  • compact-(zk-circuit-language)
  • express.js
  • groq-sdk
  • javascript
  • jetbrains-mono
  • lace-wallet
  • llama-3.1
  • merkle-tree
  • midnight-network
  • node.js
  • react-18
  • space
  • tailwind-css
  • vite
  • zk-snark
Share this project:

Updates