The privacy-preserving onchain credit scoring and micro-lending protocol built with Zama's Fully Homomorphic Encryption.
- Demo
- Problem & Opportunity
- Product-Market Fit
- Architecture
- Smart Contracts
- Frontend
- Design System
- Deployment
- Team & Credits
Contract (Sepolia): 0x6A0846cAFC2344Fc6fECbc45eB0257fc3a448d62
What you can do:
- Connect your wallet on Sepolia
- Submit encrypted financial metrics (tx count, volume, wallet age)
- Watch the smart contract compute your credit score entirely on encrypted data
- Decrypt your score and tier locally — only you ever see the number
- Reveal your tier to access tiered micro-loans from the community pool
- Borrow with a 2.5% origination fee and 5% interest
- Deposit liquidity to earn pro-rata yield from borrower fees and interest
- Withdraw your principal + accrued yield at any time
Existing DeFi lending protocols (Aave, Compound, Morpho) are transparent by design. Every wallet's collateral, debt, and liquidation price is publicly visible. This creates three critical problems:
- Financial surveillance — whales, competitors, and analytics firms can monitor and front-run large positions
- Social stigma — borrowers don't want their community to see they're leveraged or in debt
- Exclusion of underbanked — 1.4 billion people lack traditional credit history. Onchain credit scoring could help, but nobody wants their entire transaction history published to the world
| Approach | Can compute on encrypted data? | Composability | Onchain verification |
|---|---|---|---|
| Zero-Knowledge Proofs | ❌ (proves statements, doesn't compute) | ✅ | ✅ |
| Multi-Party Compute | ✅ | ❌ (offchain coordination) | ❌ |
| Fully Homomorphic Encryption | ✅ | ✅ | ✅ |
FHE is the only technology that allows a smart contract to run arbitrary arithmetic on encrypted inputs, store encrypted state, and let only authorized parties decrypt the result. Zama's FHEVM makes this practical on Ethereum.
- Zama FHEVM is live on Sepolia and mainnet
- ERC-7984 (Confidential Token Standard) is gaining traction
- Institutional DeFi demands privacy for compliance and competitive reasons
- The "Confidential Finance" narrative is the next frontier (per Zama's own Season 2 positioning)
| Segment | Pain Point | How Cipher Helps |
|---|---|---|
| Crypto-native borrowers | Don't want collateral/debt positions visible | Confidential score + private borrowing |
| Emerging market users | No traditional credit file, but have onchain history | Wallet-based credit scoring without doxxing |
| DAOs & treasuries | Need to lend to contributors privately | Tier-based access with encrypted terms |
| Fintechs / Neobanks | Compliance requires data privacy; want DeFi yields | White-label confidential credit layer |
| Privacy advocates | Refuse to use transparent DeFi | End-to-end encrypted financial operations |
| Project | Privacy Tech | Credit Scoring? | Onchain? | Unique vs Cipher |
|---|---|---|---|---|
| Aave | None | ❌ | ✅ | Transparent, no credit scoring |
| Teller | ZK (offchain oracle) | ✅ | ❌ | Oracle-dependent, not fully onchain |
| Spectral | Public ML | ✅ | ✅ | Scores are public |
| Cipher | FHE | ✅ | ✅ | Fully confidential, end-to-end |
┌─────────────────────────────────────────────────────────────┐
│ User Browser │
│ ┌─────────────┐ ┌──────────────┐ ┌─────────────────────┐ │
│ │ Next.js │ │ Zama SDK │ │ RainbowKit Wallet │ │
│ │ React UI │ │ (encrypt/ │ │ (MetaMask, etc.) │ │
│ │ │ │ decrypt) │ │ │ │
│ └──────┬──────┘ └──────┬───────┘ └─────────────────────┘ │
└─────────┼────────────────┼──────────────────────────────────┘
│ │
│ encrypted txs │
▼ ▼
┌─────────────────────────────────────────────────────────────┐
│ Ethereum / Sepolia (EVM) │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ CipherProtocol.sol (FHEVM) │ │
│ │ ┌─────────────┐ ┌──────────────┐ ┌──────────────┐ │ │
│ │ │ applyForScore│ │ borrow │ │ repayLoan │ │ │
│ │ │ (FHE compute)│ │ (tier-based) │ │ (track repay)│ │ │
│ │ └─────────────┘ └──────────────┘ └──────────────┘ │ │
│ │ │ │
│ │ Encrypted state: encryptedScores[user] → euint32 │ │
│ │ encryptedTiers[user] → euint32 │ │
│ │ loans[user] → Loan │ │
│ └───────────────────────────────────────────────────────┘ │
│ ▲ │
│ │ FHE ops (add, mul, div, ge, select)│
│ ▼ │
│ ┌───────────────────────────────────────────────────────┐ │
│ │ Zama FHEVM Executor │ │
│ │ (KMS + Threshold Decryption) │ │
│ └───────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
The scoring formula demonstrates 7 distinct FHE operation types:
// 1. Multiplication (encrypted * plaintext)
euint32 weightedTxCount = FHE.mul(txCount, FHE.asEuint32(5));
// 2. Division (encrypted / plaintext)
euint64 volumeDiv = FHE.div(totalVolume, uint64(1e15));
// 3. Addition (encrypted + encrypted)
euint32 positiveScore = FHE.add(weightedTxCount, volumeScore);
// 4. Subtraction (encrypted - encrypted)
euint32 rawScore = FHE.sub(positiveScore, weightedDefaults);
// 5. Greater-than (encrypted > encrypted)
ebool negativeLarger = FHE.gt(weightedDefaults, positiveScore);
// 6. Less-than (encrypted < plaintext)
ebool isTierC = FHE.and(isC, FHE.lt(score, FHE.asEuint32(650)));
// 7. Select (encrypted ternary)
score = FHE.select(aboveMax, FHE.asEuint32(850), score);Location: packages/foundry/src/CipherProtocol.sol
Deployed Address (Sepolia): 0x6A0846cAFC2344Fc6fECbc45eB0257fc3a448d62
Core Functions:
| Function | Description | Gas (approx) |
|---|---|---|
applyForScore |
Accepts 3 encrypted inputs, reads defaults onchain, computes weighted score via FHE | ~1.9M |
getEncryptedScore |
Returns user's encrypted score handle (view) | ~0 |
getEncryptedTier |
Returns user's encrypted tier handle (view) | ~0 |
revealTier |
User reveals decrypted tier for onchain borrowing | ~30K |
borrow |
Borrow ETH up to tier limit. 2.5% origination fee retained by pool. | ~120K |
repayLoan |
Repay active loan. Principal + 5% interest due to close. | ~40K |
depositLiquidity |
Deposit ETH to lending pool. Earn pro-rata yield. | ~25K |
withdrawLiquidity |
Withdraw ETH + accrued yield proportional to deposit share | ~30K |
liquidate |
Anyone can liquidate an overdue loan (>30 days). Records default onchain. | ~25K |
DeFi Economics:
- Origination Fee: 2.5% flat fee on every borrow (retained by pool immediately)
- Interest Rate: 5% due on repayment (stays in pool)
- Yield Distribution: Pro-rata based on deposit share
- Liquidation: Bad debt is written off from
totalBorrows, absorbed by depositors proportionally
Security Notes:
revealTieris self-reported for the hackathon demo. In production, this would be replaced by:- A ZK-proof that the claimed tier matches the encrypted score, OR
- A Zama Gateway decryption callback that verifies the tier onchain
- The contract uses
FHE.allowThis()andFHE.allow()to enforce ACL on every encrypted handle - No reentrancy risk: borrowing uses
.call{value:...}with checks-effects-interactions pattern
Location: packages/foundry/test/CipherProtocol.t.sol
pnpm contracts:testTests cover:
- Encrypted score computation and decryption
- Encrypted tier computation and decryption
- Full borrow/repay flow with fees and interest
- Liquidation and default recording
- Depositor yield from fees and interest
- Partial withdrawals
Stack:
- Next.js 15 (App Router)
- React 19
- Tailwind CSS v4
- wagmi + viem + RainbowKit
@zama-fhe/react-sdkv3
Design Language: The UI follows an Apple-inspired design system with:
- Single accent color (
#0066ccAction Blue) - SF Pro / Inter typography with tight negative letter-spacing
- Alternating light (
#ffffff,#f5f5f7) and dark (#272729) tiles - Pill-shaped CTAs with
transform: scale(0.95)press states - Zero decorative gradients, zero card shadows
- Photography-first whitespace philosophy
Key Components:
ApplyPanel— Auto-fills wallet history from Alchemy, read-only fields, submit encrypted applicationScorePanel— Encrypted score display + decrypt CTA with step indicatorLoanPanel— Borrow calculator with fee preview, repay with interest breakdownPoolPanel— Liquidity deposit/withdraw, utilization bar, pool stats
The Cipher frontend follows an Apple-inspired design language documented in DESIGN.md (see project root). Key principles:
- Single accent color:
#0066ccAction Blue carries every interactive element - Typography: Inter (open-source SF Pro equivalent) with negative letter-spacing at display sizes
- Surface rhythm: Alternating light (
#ffffff,#f5f5f7) and dark (#272729) tiles create visual pulse without borders or shadows - Button grammar: Pill-shaped CTAs (
border-radius: 9999px) for primary actions; compact rectangles (border-radius: 8px) for utilities - Shadow philosophy: Exactly one drop-shadow exists in the system —
rgba(0,0,0,0.22) 3px 5px 30px— reserved for product imagery, never UI chrome - Press state:
transform: scale(0.95)on every button - Whitespace: Sections use 80px vertical padding; tiles stack edge-to-edge with color change as the divider
- Contract:
0x6A0846cAFC2344Fc6fECbc45eB0257fc3a448d62 - Etherscan: https://sepolia.etherscan.io/address/0x6A0846cAFC2344Fc6fECbc45eB0257fc3a448d62
- Network: Sepolia Testnet (Chain ID: 11155111)
- Verified: ✅
Create packages/nextjs/.env.local:
NEXT_PUBLIC_ALCHEMY_API_KEY=...
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=...Create root .env.local (for contract deployment):
DEPLOYER_PRIVATE_KEY=0x...
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/...
ETHERSCAN_API_KEY=...pnpm install
pnpm next:build
# Deploy .next/ folder to VercelBuilt for: Zama Developer Program — Builder Track (Mainnet Season 2)
Tech Stack:
- Zama FHEVM — Fully Homomorphic Encryption for EVM
- OpenZeppelin Confidential Contracts — ERC-7984 standards
- Foundry — Ethereum development toolkit
- Next.js — React framework
- RainbowKit — Wallet connection
License: BSD-3-Clause-Clear (per Zama template)
- Zama team for the FHEVM protocol and developer tooling
- OpenZeppelin for confidential contract standards
- The FHEVM React Template maintainers
Cipher — Privacy is the default.