v0.1.0-beta

Introduction

Veil is a cross-chain, privacy-preserving credit scoring protocol that lets any DeFi application make informed credit decisions without ever learning who the borrower is or seeing their raw on-chain history.

Live on Midnight
Veil Protocol is live on Midnight. The production contract address is 9ed09d1cfb3c1b6219d7631a29504854654e0c90461894967519ba999a92276f

What Is Veil?

Veil Protocol is a three-layer infrastructure stack that bridges on-chain behavioral data from any blockchain, aggregates it into a privacy-preserving credit score, and delivers verifiable credit decisions to DeFi lending protocols — all without exposing the individual user's wallet address, transaction history, or raw score.

Think of Veil as the credit bureau of DeFi, but one that operates entirely within a zero-knowledge framework. Borrowers obtain a credit band (Bronze, Silver, Gold, Platinum) rather than a raw number, and protocols receive a ZK-verified decision that includes a maximum LTV ratio and a risk premium adjustment — with no personally identifiable information attached.

Each user's identity within Veil is represented as a Decentralized Identifier (DID) — a globally unique, self-sovereign identifier in the form did:veil:0x…. This DID is the single portable handle a protocol needs to request a credit check. It is safe to share publicly because it does not reveal the user's wallet address on any chain or their raw credit score.

The Problem

Traditional DeFi lending is either fully over-collateralized (inefficient capital) or relies on off-chain identity systems that destroy the core promise of self-sovereign finance. The existing approaches fail in two ways:

  • Over-collateralization (e.g. 150% LTV): Users must lock up more capital than they borrow. This is safe for protocols but deeply inefficient for users with solid repayment histories.
  • Off-chain identity systems: KYC-gated credit scoring brings back precisely the trust relationships and surveillance risks that blockchain was designed to remove.

Veil solves this by letting on-chain behavior speak for itself, aggregated and proven with zero-knowledge cryptography, with identity anchored to an immutable on-chain DID rather than a KYC document.

How It Works

The protocol operates in four phases: data collection, score computation, ZK proof generation, and decision delivery.

Architecture Overview

Veil is composed of three logical layers that each have a distinct responsibility:

  1. Data Layer (Any Chain):Registered DeFi protocols (issuers) submit behavioral signals — repayments, liquidations, protocol usage, debt state snapshots — to the Veil backend API. Events are keyed to a user's Veil public key (userPk), a deterministic anonymous key derived from the user's Midnight wallet. Only approved issuers can submit events.
  2. Privacy Layer (Midnight):A Compact smart contract on Midnight stores the computed credit score privately and maintains a DID registry for each user. A ZK circuit proves band membership (e.g. "this user's score is in the Gold range") without revealing the raw score. The proof is submitted on-chain and the contract issues a verifiable credit decision.
  3. Identity Layer (CKB / Nervos):The user mints a Spore Digital Object (DOB) on CKB that serves as their immutable identity anchor. The DOB binds the user's veilIdHash to their CKB lock hash, linking the Midnight score to a portable, chain-agnostic public identity. Once minted, the user receives a did:veil:… identifier that any protocol can resolve to verify identity and request a credit decision.

Midnight Layer

Midnight is a data-protection blockchain that enables privacy-preserving smart contracts written in Compact — a ZK-native language that compiles to circuits the Midnight prover can evaluate. Veil's core contract is written in Compact and stores credit scores in a private ledger state that only the score owner and the Veil oracle can update.

The Midnight contract also runs a DID Registry— an on-chain record that links a user's veilIdHash, CKB identity pass (Spore DOB), and CKB owner lock hash. This registry is what makes the did:veil:… identifier resolvable and verifiable by any party without trusting Veil.

When a credit decision is requested, the backend runs the Midnight ZK prover to generate a proof that the score falls within a particular band. This proof is verified by the on-chain contract and stored as a commitment, never revealing the raw numeric score.

CKB Identity Layer

CKB (Common Knowledge Base, the Nervos Network Layer 1) is optimized for on-chain asset and identity primitives. The Spore protocol on CKB provides "Digital Objects" (DOBs) — immutable, non-fungible cells that can store arbitrary structured data and are permanently associated with an owner lock.

Veil uses a Spore DOB as the user's public identity container. The DOB stores the user's veilIdHash, the Midnight contract address, and the network version. Because CKB cells are immutable once created and verified by every CKB full node, this provides an unforgeable, chain-agnostic identity anchor for the user's Veil DID.

Veil Decentralized Identity (DID)

Every Veil user has a globally unique identifier called a Veil DID, formatted as:

did:veil:0x<64-hex-chars>

This follows the W3C DID Core specification and is derived from the hash of the user's Veil public key. Here is what makes this design powerful:

  • Shareable without risk:The DID does not expose the user's Midnight private key, wallet addresses on other chains, or raw credit score. A user can share their DID freely with any app that wants to check their credit status.
  • Resolvable by anyone: Any protocol can call GET /api/v1/dids/resolve?did=did:veil:0x…to retrieve a standard DID Document. The document contains the user's verification method (CKB public key), the credit-decision service endpoint, and the CKB identity pass location — enough to perform a credit check without any additional out-of-band information.
  • Registered on Midnight: When a user mints their CKB identity pass, the backend automatically registers the DID on the Midnight DID Registry contract. This makes the DID cryptographically anchored to a ZK-protected on-chain record, not just a database entry.
  • Used for credit authorization: When a user authorizes a credit decision, their CKB wallet signs a message that includes the DID and a verification method reference — proving they control the identity without revealing any private state.
For normal users
You do not need to understand DIDs to use Veil. The dashboard generates your Veil DID automatically when you mint your identity pass, and displays it as "Your Veil ID." You can copy it and share it with any app that supports Veil credit checks.

Key Benefits

No Identity Disclosure
Protocols learn only a credit band and LTV limit, never a wallet address or raw score.
Chain-Agnostic
Behavioral data can come from Ethereum, Solana, BNB Chain, or any EVM-compatible network.
Composable
Any lending protocol can integrate the Veil decision API — no custom contract needed on your end.
Immutable Identity
CKB DOBs are permanently on-chain and cannot be revoked or altered by any third party.
ZK-Verified
Credit decisions carry cryptographic proofs verifiable by any party without trusting the issuer.
Self-Sovereign DID
Users hold a portable W3C DID that resolves to their verified identity — no central registry needed.

Next Steps

From here, you can dive deeper into specific areas of the protocol:

  • Scoring Model — understand how the five credit bands are computed and what behavioral signals matter.
  • Integration Guide — start submitting behavioral data and consuming credit decisions in your protocol.
  • Dashboard Guide — walk through the end-user flow from wallet connection to minting an identity pass and sharing your Veil DID.
  • Architecture Deep Dive — understand the ZK proof pipeline and the three protocol roles in detail.