Skip to content

ishaanparikh14/A-Decentralized-Multimodal-Biometric-Authentication-Framework-Using-Machine-Learning-and-Blockchain

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DID++ Decentralized Biometric Identity System

A fully decentralized multi-modal biometric identity system that eliminates local databases by utilizing IPFS for storage and Ethereum Sepolia for state management.

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    DID++ System Architecture                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚  Face Image  β”‚    β”‚ Voice Audio  β”‚    β”‚ ID Document  β”‚       β”‚
β”‚  β”‚   (~1.5MB)   β”‚    β”‚   (~1.5MB)   β”‚    β”‚   (~1MB)     β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚         β”‚                   β”‚                   β”‚                β”‚
β”‚         β–Ό                   β–Ό                   β–Ό                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚              ML Processing Engine                    β”‚        β”‚
β”‚  β”‚  β€’ ArcFace (512-D face embedding)                   β”‚        β”‚
β”‚  β”‚  β€’ ECAPA-TDNN (192-D voice embedding)               β”‚        β”‚
β”‚  β”‚  β€’ EasyOCR + ArcFace (640-D document embedding)     β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                            β”‚                                     β”‚
β”‚                            β–Ό                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚           AES-256-CBC Encryption                     β”‚        β”‚
β”‚  β”‚  β€’ Unique 16-byte IV per session                    β”‚        β”‚
β”‚  β”‚  β€’ PKCS7 padding                                    β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                            β”‚                                     β”‚
β”‚                            β–Ό                                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚  β”‚           Encrypted Metadata JSON (~5KB)             β”‚        β”‚
β”‚  β”‚  {                                                   β”‚        β”‚
β”‚  β”‚    "encrypted_face_embedding": "...",               β”‚        β”‚
β”‚  β”‚    "encrypted_voice_embedding": "...",              β”‚        β”‚
β”‚  β”‚    "encrypted_doc_data": "...",                     β”‚        β”‚
β”‚  β”‚    "identity_hash": "..."                           β”‚        β”‚
β”‚  β”‚  }                                                   β”‚        β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β”‚                            β”‚                                     β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚
β”‚              β–Ό                           β–Ό                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚   IPFS (Pinata)      β”‚   β”‚  Ethereum Sepolia    β”‚           β”‚
β”‚  β”‚                      β”‚   β”‚                      β”‚           β”‚
β”‚  β”‚  Stores encrypted    β”‚   β”‚  Stores:             β”‚           β”‚
β”‚  β”‚  metadata (~5KB)     β”‚   β”‚  β€’ DID β†’ CID mapping β”‚           β”‚
β”‚  β”‚                      β”‚   β”‚  β€’ Identity hash     β”‚           β”‚
β”‚  β”‚  Returns: CID        β”‚   β”‚    (32 bytes)        β”‚           β”‚
β”‚  β”‚  (Content ID)        β”‚   β”‚  β€’ Verification logs β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Reduction Pipeline:
~4MB raw biometrics β†’ ~5KB IPFS metadata β†’ 32-byte blockchain hash
           β‰ˆ800x reduction        β‰ˆ150x reduction
                    Total: ~125,000x reduction

πŸ“‹ Features

Decentralized Storage

  • IPFS: Encrypted biometric metadata stored on IPFS via Pinata
  • Ethereum Sepolia: Immutable registry of DIDs, CIDs, and identity hashes
  • No Local Database: All data is stored on decentralized infrastructure

Multi-Modal Biometrics

  • Face Recognition: 512-D ArcFace embeddings via InsightFace
  • Voice Recognition: 192-D ECAPA-TDNN embeddings via SpeechBrain
  • Document Verification: OCR + face extraction from ID documents

Security

  • AES-256-CBC Encryption: All biometric data encrypted before leaving the server
  • Unique IVs: 16-byte initialization vector per session
  • In-Memory Processing: Decrypted data never written to disk

Smart Contracts

  • DIDRegistry: Maps DIDs to IPFS CIDs and identity hashes
  • VerificationLog: Immutable audit trail of verification events

πŸš€ Quick Start

1. Clone and Install

cd DID_Ishaan_Abhiram

# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Linux/Mac

# Install dependencies
pip install -r requirements.txt

2. Configure Environment

# Copy example config
copy .env.example .env  # Windows
# cp .env.example .env  # Linux/Mac

# Edit .env with your credentials:
# - ALCHEMY_KEY: Get from https://alchemy.com
# - PINATA_JWT: Get from https://pinata.cloud
# - MASTER_KEY: Generate with: python -c "import secrets; print(secrets.token_hex(32))"
# - PRIVATE_KEY: Your Sepolia wallet private key

3. Deploy Smart Contracts

Deploy the contracts in contracts/ to Sepolia using Remix, Hardhat, or Foundry:

// 1. Deploy DIDRegistry.sol first
// 2. Deploy VerificationLog.sol with DIDRegistry address
// 3. Update .env with contract addresses

4. Run the Backend

python -m app.main
# or
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

5. Run the Frontend

cd frontend
npm install
npm run dev

πŸ“‘ API Endpoints

Registration

POST /api/register
- Uploads: face (JPEG), voice (WAV/WebM), id_doc (JPEG)
- Returns: DID, IPFS CID, identity hash, blockchain TX

Verification

POST /api/verify
- Form data: did, face, voice, id_doc (optional)
- Process: Blockchain β†’ IPFS β†’ Decrypt β†’ Compare
- Returns: Verification scores, confidence level, blockchain TX

History

GET /api/user/{did}
- Queries blockchain event logs
- Returns: Full timeline of registration and verification events

Status

GET /api/health
GET /api/config
GET /api/status

πŸ” Smart Contracts

DIDRegistry.sol

function registerDID(string did, string metadataCID, bytes32 identityHash)
function getMetadataCID(string did) returns (string)
function getDIDRecord(string did) returns (DIDRecord)

VerificationLog.sol

function logVerification(string did, bytes32 verificationHash, string metadataCID, uint8 confidenceLevel, bool success)
function getVerificationCount(string did) returns (uint256)
function getRecentVerifications(string did, uint256 limit) returns (VerificationRecord[])

πŸ“Š Data Reduction Pipeline

Stage Size Reduction
Raw Biometrics ~4 MB -
ML Embeddings ~5 KB 800x
Encrypted IPFS ~5 KB 800x
Blockchain Hash 32 bytes ~125,000x

πŸ”§ Configuration

Biometric Weights

FACE_WEIGHT=0.40    # 40% face contribution
VOICE_WEIGHT=0.35   # 35% voice contribution
DOC_WEIGHT=0.25     # 25% document contribution

Verification Threshold

VERIFICATION_THRESHOLD=0.75  # 75% minimum for successful verification

πŸ“ Project Structure

De-centralised_Identity/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ config.py           # Configuration management
β”‚   β”œβ”€β”€ main.py             # FastAPI application
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ registration.py # Registration endpoint
β”‚   β”‚   β”œβ”€β”€ verification.py # Verification endpoint
β”‚   β”‚   └── history.py      # History endpoint
β”‚   └── services/
β”‚       β”œβ”€β”€ blockchain.py   # Ethereum integration
β”‚       β”œβ”€β”€ encryption.py   # AES-256-CBC encryption
β”‚       β”œβ”€β”€ ipfs.py         # Pinata IPFS integration
β”‚       └── ml_engine.py    # Biometric processing
β”œβ”€β”€ contracts/
β”‚   β”œβ”€β”€ DIDRegistry.sol     # DID registry contract
β”‚   └── VerificationLog.sol # Verification log contract
β”œβ”€β”€ frontend/
β”‚   └── src/
β”‚       β”œβ”€β”€ App.jsx
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ RegisterPage.jsx
β”‚       β”‚   β”œβ”€β”€ VerifyPage.jsx
β”‚       β”‚   └── HistoryPage.jsx
β”‚       └── components/
β”œβ”€β”€ .env
β”œβ”€β”€ requirements.txt
└── README.md

πŸ›‘οΈ Security Considerations

  1. Master Key: Store securely, never commit to version control
  2. Private Key: Use testnet wallets only, never mainnet keys
  3. IPFS Data: All data encrypted before upload
  4. In-Memory Only: Decrypted biometrics never touch disk

πŸ“œ License

MIT License - See LICENSE file for details.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

DID++ v2.0 - Fully Decentralized Biometric Identity

DID_Ver3

DID_Ver3

About

A fully decentralized multimodal biometric authentication system using ML and blockchain. Combines face, voice, and document verification with encrypted embeddings stored on IPFS and immutable audit logs on Ethereum. Eliminates centralized databases while ensuring secure, privacy-preserving identity verification.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 49.7%
  • JavaScript 31.6%
  • CSS 10.8%
  • Solidity 7.7%
  • HTML 0.2%