Skip to content

ZKAuth is a decentralized identity verification system that enables users to prove attributes about themselves (like being over 18) without revealing their actual personal data.

Notifications You must be signed in to change notification settings

roudra323/ZKAuth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” ZKAuth

Privacy-Preserving Identity Verification using Zero-Knowledge Proofs & ePassport Data

Verify your identity without revealing personal information. Powered by ZK-SNARKs and NFC passport reading.

Overview ยท How It Works ยท Architecture ยท Components ยท Quick Start ยท Use Cases


๐Ÿ“– Overview

ZKAuth is a decentralized identity verification system that enables users to prove attributes about themselves (like being over 18) without revealing their actual personal data. By combining:

  • ๐Ÿ“ฑ NFC-enabled passport reading on Android devices
  • ๐Ÿ” Zero-Knowledge Proof generation using ZoKrates
  • โ›“๏ธ On-chain proof verification via Ethereum smart contracts
  • ๐ŸŒ Web3-native DApp integration with modern frontend

Users can cryptographically prove claims about their identity while maintaining complete privacy over their sensitive passport data.

โœจ Key Features

Feature Description
๐Ÿ” Privacy-First Your passport data never leaves your device. Only cryptographic proofs are shared.
โœ… ICAO 9303 Compliant Full support for international ePassport standards
๐Ÿ”— On-Chain Verification Proofs verified by Ethereum smart contracts for trustless verification
๐Ÿ“ฑ Mobile-Native Android app with OCR, NFC, and QR code support
๐Ÿ›๏ธ Decentralized No central authority required for verification
๐Ÿ”„ Reusable Proofs Generate proofs once, use across multiple DApps

๐ŸŽฏ How It Works

ZKAuth operates through a seamless flow between the mobile app, web DApps, and blockchain smart contracts.

System Architecture Overview

ZKAuth System Architecture

The complete verification flow involves 7 key steps:

  1. MRZ Capture & NFC Scan - User reads their passport using the ZKAuth Android app
  2. Secure Storage - Passport data is encrypted and stored locally on the device
  3. QR Code Generation - DApp creates a verification challenge encoded as a QR code
  4. QR Scanning - User scans the QR code with the ZKAuth app
  5. ZK Proof Generation - App generates a zero-knowledge proof based on the challenge
  6. Proof Submission - Proof is sent to the verification server
  7. On-Chain Validation - Admin-side DApp fetches and validates the proof on-chain

Detailed Flow Diagrams

๐Ÿ”„ QR Code-Based Challenge Exchange

QR Code Challenge Flow

This diagram illustrates the interaction between the DApp and ZKAuth mobile app:

DApp Side:

  1. User interacts with DApp and selects "Verify Age"
  2. DApp creates a verification challenge with specific criteria
  3. Challenge is encoded as JSON and converted to QR code
  4. QR code is displayed on screen for the user

ZKAuth App Side:

  1. User scans the QR code with the mobile app
  2. App parses and validates the JSON challenge
  3. Challenge data is stored and prepared for proof generation
  4. App signals readiness for ZK proof generation

๐Ÿ›‚ Passport Verification Flow

Passport Verification Flow

This comprehensive flow shows the complete passport onboarding process:

User Onboarding:

  • User opens ZKAuth app and is prompted to add a passport
  • Choice between OCR (camera) scanning or manual MRZ input

Key Generation & NFC:

  • BAC key is derived from MRZ data
  • Passport chip is read via NFC communication

Security Verification:

  • โœ… BAC (Basic Access Control)
  • โœ… PACE (Password Authenticated Connection Establishment)
  • โœ… AA (Active Authentication)
  • โœ… CA (Chip Authentication)
  • โœ… CSCA (Certificate Authority Validation)

Data Handling:

  • Data fields extracted from passport chip
  • Encrypted and stored securely on device
  • Identity data ready for ZK proof generation

๐Ÿ—๏ธ Architecture

ZKAuth/
โ”œโ”€โ”€ ๐Ÿ“ฑ PassportAndroidApp/          # Android mobile application
โ”‚   โ”œโ”€โ”€ app/src/main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/example/jllarraz/  # Kotlin source code
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ passport/           # Passport reading logic
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ camera/             # OCR & QR scanning
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ nfc/                # NFC communication
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ zk/                 # ZK proof generation
โ”‚   โ”‚   โ”œโ”€โ”€ assets/zokrates/        # ZoKrates proving keys
โ”‚   โ”‚   โ””โ”€โ”€ res/                    # Android resources
โ”‚   โ””โ”€โ”€ libs/                       # External libraries (JMRTD)
โ”‚
โ”œโ”€โ”€ ๐ŸŒ ZK-Minimal-DApp/             # Web application & smart contracts
โ”‚   โ”œโ”€โ”€ Foundry-Backend/            # Solidity smart contracts
โ”‚   โ”‚   โ””โ”€โ”€ src/
โ”‚   โ”‚       โ”œโ”€โ”€ AuthBluePrint.sol   # Base authentication contract
โ”‚   โ”‚       โ””โ”€โ”€ RandomDApp.sol      # Example DApp implementation
โ”‚   โ”œโ”€โ”€ frontend/                   # Next.js React application
โ”‚   โ”‚   โ”œโ”€โ”€ app/                    # App router pages
โ”‚   โ”‚   โ”œโ”€โ”€ components/             # React UI components
โ”‚   โ”‚   โ””โ”€โ”€ contracts/              # Contract ABIs
โ”‚   โ””โ”€โ”€ zk-passport-auth/           # ZK verification system
โ”‚
โ””โ”€โ”€ ๐Ÿ“Š media/                       # Documentation assets

๐Ÿงฉ Components

๐Ÿ“ฑ Passport Android App

A comprehensive Android application for reading and verifying ePassport documents.

Features

Category Capabilities
๐Ÿ“– Passport Reading OCR-based MRZ scanning, NFC chip reading, Manual data entry
๐Ÿ” Security Protocols BAC, PACE, EAC, Active Authentication, Chip Authentication
๐Ÿ” Verification CSCA certificate chain validation, Cryptographic hash verification
๐Ÿ“ฑ Mobile Features QR code scanning, ZK proof generation, Encrypted local storage

Technical Stack

  • Language: Kotlin
  • NFC/Passport: JMRTD 0.7.35, Bouncy Castle
  • OCR: Google ML Kit Text Recognition
  • Camera: CameraX, ML Kit Barcode Scanning
  • ZK Proofs: ZoKrates.js via WebView
  • Security: Android Security Crypto, EncryptedSharedPreferences

Requirements

  • Android 6.0+ (API Level 23)
  • NFC-enabled device
  • Camera for OCR/QR scanning

๐Ÿ“š Full Android App Documentation โ†’


๐ŸŒ ZK Minimal DApp

A decentralized web application for requesting and verifying ZK proofs.

Features

Feature Description
๐Ÿ”— Wallet Integration RainbowKit for seamless Web3 wallet connections
๐Ÿ“ฑ QR Generation Dynamic QR codes for verification requests
โ›“๏ธ Smart Contracts Ethereum-based proof verification
๐ŸŽจ Modern UI Next.js 15 + React 19 + Tailwind CSS
๐Ÿ‘จโ€๐Ÿ’ผ Admin Panel Dashboard for managing verification requests

Smart Contracts

AuthBluePrint.sol - Base abstract contract providing:

// Core authentication states
enum AuthState { NONE, REQUESTED, PENDING, VERIFIED, FAILED }

// Key functions
function genQRCodeInfo() public;           // Generate verification challenge
function validateProof(...) public;        // Verify ZK proof on-chain

RandomDApp.sol - Example implementation showing custom verification logic.

Technical Stack

  • Frontend: Next.js 15, React 19, TypeScript
  • Styling: Tailwind CSS, shadcn/ui
  • Web3: ethers.js, Wagmi, RainbowKit
  • Contracts: Solidity, Foundry, OpenZeppelin

๐Ÿ“š Full DApp Documentation โ†’


๐Ÿš€ Quick Start

Prerequisites

# Required tools
- Node.js 18+ & pnpm
- Android Studio (for mobile app)
- Foundry (for smart contracts)
- Git

1. Clone the Repository

git clone --recurse-submodules https://github.com/roudra323/ZKAuth.git
cd ZKAuth

2. Setup Smart Contracts

cd ZK-Minimal-DApp/Foundry-Backend
forge install
forge build
forge test

3. Setup Frontend

cd ../frontend
pnpm install

# Create environment file
cat > .env.local << EOF
NEXT_PUBLIC_CONTRACT_ADDRESS=your_contract_address
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=your_wallet_connect_id
EOF

pnpm dev

4. Setup Android App

  1. Open PassportAndroidApp/ in Android Studio
  2. Sync Gradle dependencies
  3. Configure CSCA certificates (optional)
  4. Build and run on NFC-enabled device

๐Ÿ’ก Use Cases

๐Ÿบ Age Verification

Prove you're over 18/21 without revealing your birthdate to access age-restricted services.

๐Ÿ›๏ธ KYC/AML Compliance

Verify nationality or identity for financial services while preserving privacy.

๐Ÿ—ณ๏ธ Anonymous Voting

Prove citizenship eligibility without linking votes to your identity.

๐ŸŽซ Event Access

Verify credentials for exclusive events without sharing personal data.

๐ŸŽฎ Gaming & Gambling

Comply with age regulations while maintaining user privacy.


๐Ÿ”’ Security Model

Privacy Guarantees

Layer Protection
๐Ÿ“ฑ Device Passport data encrypted with Android Keystore
๐Ÿ” Transmission Only ZK proofs leave the device, never raw data
โ›“๏ธ Blockchain Proofs verified without revealing inputs
๐Ÿ”„ Verification Zero-knowledge: verifier learns only true/false

Passport Security Protocols

  • ICAO 9303 - International standard compliance
  • BAC - Basic Access Control for chip access
  • PACE - Password Authenticated Connection Establishment
  • EAC - Extended Access Control for biometrics
  • Active Authentication - Proves chip authenticity
  • CSCA Validation - Country certificate chain verification

๐Ÿ› ๏ธ Development

Project Structure

Module Path Technology
Android App PassportAndroidApp/ Kotlin, Android SDK
Smart Contracts ZK-Minimal-DApp/Foundry-Backend/ Solidity, Foundry
Web Frontend ZK-Minimal-DApp/frontend/ Next.js, React, TypeScript
ZK Circuits ZK-Minimal-DApp/zk-passport-auth/ ZoKrates

Contributing

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

Guidelines

  • Use functional programming paradigms
  • Follow TypeScript best practices
  • Write comprehensive tests
  • Document new features

๐Ÿ“š References

Standards & Protocols

Libraries & Tools

  • JMRTD - Java Machine Readable Travel Documents
  • Foundry - Ethereum development toolkit
  • RainbowKit - Web3 wallet integration

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

The Passport Android App component is licensed under Apache License 2.0.


๐Ÿ™ Acknowledgments


Built with โค๏ธ for privacy-preserving identity verification

GitHub

About

ZKAuth is a decentralized identity verification system that enables users to prove attributes about themselves (like being over 18) without revealing their actual personal data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published