Skip to content
guru-murtthyPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

3 Commits

Folders and files

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

Repository files navigation

๐Ÿ‡ฎ๐Ÿ‡ณ BharatKYC

Zero-Knowledge Identity Platform for India

Prove who you are. Never reveal what you are.

License: MIT TypeScript React DPDP Compliant Polygon zkEVM


โšก What is BharatKYC?

Today, every time you do KYC โ€” at a bank, a broker, a hospital โ€” you hand over your full Aadhaar, PAN, and income data. The institution stores it. It gets hacked. It gets sold. You have zero control.

BharatKYC flips this. Using Zero-Knowledge Proofs, a citizen can prove "I am above 18 and earn over โ‚น10 lakh" โ€” without revealing their birth date or salary. The institution gets a cryptographic yes/no. Your data never leaves your device.

Built on India Stack โ€” Aadhaar, Account Aggregator, DigiLocker, eSign โ€” making it legally valid under DPDP Act 2023 and deployable on Polygon zkEVM.


๐Ÿ”ฅ The Problem

Old KYC BharatKYC
Share everything (Aadhaar, PAN, salary) Share only what's needed via ZK proof
Institution permanently stores your data Institution gets a cryptographic receipt only
No revocation mechanism On-chain consent revocation (ERC-5484 SBT burn)
No audit trail Regulator sees full immutable consent ledger
Legally grey on DPDP Fully DPDP Act 2023 compliant with eSign

๐Ÿ—๏ธ System Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                         CITIZEN'S DEVICE                            โ”‚
โ”‚                                                                     โ”‚
โ”‚   Aadhaar XML  โ”€โ”€โ–บ  India Stack Parser  โ”€โ”€โ–บ  ZK Circuit (WASM)     โ”‚
โ”‚                                                  โ”‚                  โ”‚
โ”‚   Biometric Liveness (FIDO2 WebAuthn)            โ–ผ                  โ”‚
โ”‚                                         Groth16 ZK Proof           โ”‚
โ”‚                                         (No raw data leaves)       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                          โ”‚
                                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                          BACKEND API (tRPC)                         โ”‚
โ”‚                                                                     โ”‚
โ”‚   Proof Verification  โ”€โ”€โ–บ  W3C Verifiable Credential Issuance      โ”‚
โ”‚                       โ”€โ”€โ–บ  DPDP eSign Consent Receipt              โ”‚
โ”‚                       โ”€โ”€โ–บ  Consent Audit Log (PostgreSQL)          โ”‚
โ”‚                       โ”€โ”€โ–บ  DID Registration (Polygon zkEVM)        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                โ”‚
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   VERIFIER   โ”‚  โ”‚       REGULATOR              โ”‚
โ”‚   PORTAL     โ”‚  โ”‚       DASHBOARD              โ”‚
โ”‚              โ”‚  โ”‚                              โ”‚
โ”‚ Set KYC      โ”‚  โ”‚  View all consent logs       โ”‚
โ”‚ requirements โ”‚  โ”‚  Audit proof submissions     โ”‚
โ”‚ Generate QR  โ”‚  โ”‚  Monitor revocations         โ”‚
โ”‚ Poll status  โ”‚  โ”‚  DPDP compliance reports     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Repository Structure

bharatkyc/
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ citizen-app/         # ๐Ÿชช Citizen ZK Wallet UI       (port 3000)
โ”‚   โ”œโ”€โ”€ landing/             # ๐ŸŒ Product Landing Page        (port 3002)
โ”‚   โ”œโ”€โ”€ verifier-portal/     # ๐Ÿฆ Institution Verifier UI     (port 3003)
โ”‚   โ””โ”€โ”€ regulator-dashboard/ # ๐Ÿ›๏ธ Regulatory Audit Console   (port 3004)
โ”‚
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ zk-core/             # ๐Ÿ” Circom circuits + SnarkJS engine
โ”‚   โ”œโ”€โ”€ india-stack/         # ๐Ÿ‡ฎ๐Ÿ‡ณ Aadhaar, AA, DigiLocker, eSign, ABHA
โ”‚   โ”œโ”€โ”€ chain/               # โ›“๏ธ Polygon DID + Verifiable Credentials
โ”‚   โ”œโ”€โ”€ biometrics/          # ๐Ÿคณ FIDO2 WebAuthn + liveness detection
โ”‚   โ”œโ”€โ”€ risk-engine/         # ๐Ÿ“Š AML/OFAC risk scoring engine
โ”‚   โ””โ”€โ”€ sdk/                 # ๐Ÿงฐ Public React SDK for integrators
โ”‚
โ”œโ”€โ”€ backend/                 # ๐ŸŸข tRPC + Express + Prisma API server
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ server.ts        # Express + CORS setup
โ”‚   โ”‚   โ”œโ”€โ”€ router.ts        # All tRPC procedures
โ”‚   โ”‚   โ””โ”€โ”€ db.ts            # Prisma ORM + in-memory fallback
โ”‚   โ””โ”€โ”€ prisma/
โ”‚       โ””โ”€โ”€ schema.prisma    # DB schema: Users, Sessions, ConsentLogs
โ”‚
โ”œโ”€โ”€ docker-compose.yml       # PostgreSQL + Redis containers
โ”œโ”€โ”€ package.json             # NPM Workspaces monorepo root
โ””โ”€โ”€ README.md

๐Ÿ” ZK Circuits

All circuits are located in packages/zk-core/circuits/ and compiled with Circom v2.1.8. Proofs use the Groth16 proving system (~200 byte proof size, constant verification time).

Circuit What it proves
age_proof.circom "I am above age X" โ€” without revealing birth date
income_range.circom "My income is between โ‚นA and โ‚นB" โ€” without revealing salary
sanctions_clear.circom "My name hash is NOT on the OFAC/AML blocked list"
credit_band.circom "My credit score is above Y" โ€” without revealing the score
profession_verify.circom "I work in profession code Z"
nationality_proof.circom "I am an Indian national"
composite_kyc.circom Master circuit combining all checks โ€” 230 constraints

The master circuit enforces all checks at the cryptographic level:

isCompositeValid <== temp4 * isNationalityValid;
isCompositeValid === 1;  // The circuit FAILS if ANY check fails

๐Ÿ‡ฎ๐Ÿ‡ณ India Stack Integration (@bharatkyc/india-stack)

Module Description
aadhaar.ts Parses Aadhaar Offline XML (from UIDAI portal) โ€” extracts DOB/income fields as private ZK inputs, never sent to server
esign.ts Issues DPDP-compliant digital consent receipts using eSign-SHA256 (legally valid under IT Act 2000)
aa.ts Account Aggregator integration โ€” pulls bank statement data for the income ZK proof
digilocker.ts DigiLocker document verification for education/profession credentials
abha.ts Ayushman Bharat Health Account integration for health KYC

๐Ÿ—บ๏ธ Application Flows

Citizen Wallet (localhost:3000)

  1. Credentials Wallet โ€” Upload Aadhaar Offline XML โ†’ parsed locally โ†’ ZK proof generated in-browser
  2. Biometric Liveness โ€” Face mesh + blink/head-turn detection โ†’ FIDO2 WebAuthn passkey registration
  3. Scan KYC Request โ€” Paste verifier's JSON config โ†’ generate ZK proof โ†’ submit to backend
  4. Consent & Revocation โ€” View all active consents โ†’ one-click revoke (triggers on-chain SBT burn)

Verifier Portal (localhost:3003)

  1. Set KYC requirements (age threshold, income range, sanctions check)
  2. Generate a verification session QR code
  3. Share QR/JSON with citizen
  4. Poll for proof submission status in real-time

Regulator Dashboard (localhost:3004)

  1. View aggregate statistics (total proofs, active consents, revocations)
  2. Browse full audit log of all consent events
  3. Monitor DPDP compliance across the platform

๐Ÿ› ๏ธ Tech Stack

Layer Technology Why
ZK Circuits Circom + SnarkJS Groth16 proofs โ€” tiny size, constant verification
Frontend React 18 + Vite + TypeScript Fast HMR, proper WASM support for SnarkJS
Backend API Node.js + Express + tRPC Type-safe end-to-end, no REST swagger needed
Database PostgreSQL + Prisma Structured consent audit queries
Session Cache Redis Fast verification session polling
Blockchain Polygon zkEVM EVM-compatible + ZK-native, low gas fees
Identity W3C DID + Verifiable Credentials Open standard, interoperable
Auth FIDO2 WebAuthn Phishing-resistant passkey binding
Compliance DPDP Act 2023 + eSign (IT Act 2000) Legally valid in India

๐Ÿš€ Getting Started

Prerequisites

  • Node.js v18+
  • npm v10+
  • Docker & Docker Compose (for PostgreSQL + Redis)

1. Clone the Repository

git clone https://github.com/guru-murtthy/BharatKYC.git
cd BharatKYC

2. Install Dependencies

npm install

3. Configure Environment

Create backend/.env from the example:

cp backend/.env.example backend/.env

Edit the values:

DATABASE_URL="postgresql://postgres:password@localhost:5432/bharatkyc"
REDIS_URL="redis://localhost:6379"
PORT=3001
NODE_ENV=development

Note: If DATABASE_URL is not set, the backend automatically uses an in-memory store โ€” perfect for offline demos!

4. Start Infrastructure (Optional)

docker-compose up -d

5. Run the Full Platform

# Start all apps and the backend simultaneously
npm run dev

This starts:

Service URL
Citizen Wallet http://localhost:3000
Backend API http://localhost:3001
Landing Page http://localhost:3002
Verifier Portal http://localhost:3003
Regulator Dashboard http://localhost:3004

Run Individual Apps

npm run dev:backend    # Backend API only
npm run dev:citizen    # Citizen Wallet only
npm run dev:verifier   # Verifier Portal only
npm run dev:regulator  # Regulator Dashboard only
npm run dev:landing    # Landing Page only

๐Ÿงฉ ZK Circuit Setup (Optional โ€” pre-compiled)

The ZK circuit build outputs are pre-compiled. To rebuild from scratch:

# Requires Circom v2.1.8 (auto-downloaded)
npm run build:circuits --workspace=packages/zk-core

This runs the full setup:

  1. Downloads circom binary
  2. Compiles composite_kyc.circom โ†’ R1CS + WASM
  3. Runs local Powers of Tau ceremony (pot12_final.ptau)
  4. Generates Groth16 proving/verification keys (.zkey)
  5. Exports Solidity verifier contract

๐Ÿ”— API Reference (tRPC Procedures)

Procedure Type Description
createSession Mutation Verifier creates a KYC verification request
submitZKProof Mutation Citizen submits proof + public signals for verification
getSessionStatus Query Poll a session's current status
getConsentLogs Query Fetch a citizen's full consent audit trail
revokeConsent Mutation Revoke a consent + burn ERC-5484 SBT
getRegulatorStats Query Aggregate metrics for the regulator dashboard

๐Ÿ›๏ธ DPDP Act 2023 Compliance

BharatKYC is designed ground-up for India's Digital Personal Data Protection Act 2023:

  • Right to Consent โ€” Every data share is tied to an eSign-authenticated consent receipt
  • Right to Revocation โ€” Citizens can revoke any consent from their wallet, triggering on-chain SBT burn
  • Data Minimisation โ€” ZK proofs ensure only boolean outcomes are shared, never raw personal data
  • Audit Trail โ€” Full immutable consent log accessible to CERT-In and sector regulators
  • Purpose Limitation โ€” Each verification session specifies the exact purpose; stored on-chain

๐Ÿ—‚๏ธ Smart Contracts

Contract Location Description
BharatKYCRegistry.sol packages/chain/contracts/ ERC-5484 Soulbound Token registry for KYC credentials on Polygon zkEVM

๐Ÿค Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/your-feature
  3. Commit your changes: git commit -m 'Add your feature'
  4. Push to the branch: git push origin feature/your-feature
  5. Open a Pull Request

๐Ÿ“„ License

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


๐Ÿ™ Acknowledgements

  • iden3/circom โ€” ZK circuit compiler
  • iden3/snarkjs โ€” JavaScript ZK proof library
  • UIDAI โ€” Aadhaar Offline XML specification
  • ReBIT โ€” Account Aggregator ecosystem
  • Polygon โ€” zkEVM infrastructure
  • Ministry of Electronics & IT โ€” DPDP Act 2023

Built with โค๏ธ for Bharat ๐Ÿ‡ฎ๐Ÿ‡ณ

BharatKYC Protocol ยท DPDP Act 2023 ยท India Stack Ecosystem

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages