Skip to content

Repository files navigation

BioCryptNet - Biometric-Conditioned Neural Encryption System

Project Overview

BioCryptNet is a novel cryptographic framework that integrates biometric identity and artificial intelligence to enhance data security and privacy. The system utilizes facial embeddings derived from deep learning-based recognition models to generate unique, user-specific encryption keys and employs a key-conditioned chaotic autoencoder to perform encryption and decryption.

Key Features

  • Biometric Key Generation: Extracts unique facial embeddings from user images to serve as cryptographic keys
  • Key-Conditioned Autoencoder: Neural network architecture that uses facial embeddings to encrypt/decrypt data
  • Chaotic Module: Introduces controlled randomness using logistic maps to enhance security
  • Multi-Modal Support: Encrypts both text and image data
  • Security Analysis: Real-time entropy and statistical analysis of encrypted data

Project Architecture

Backend (FastAPI)

backend/
├── main.py                      # FastAPI application with endpoints
├── services/
│   ├── face_embedding.py       # Facial embedding extraction service
│   ├── chaotic_autoencoder.py  # Neural network models with chaotic module
│   └── encryption_service.py   # Encryption/decryption service
└── requirements.txt             # Python dependencies

Key Components:

  1. FaceEmbeddingService: Uses face_recognition library to extract 128-dimensional facial embeddings
  2. ChaoticAutoencoder: Implements key-conditioned autoencoders with chaotic modulation
  3. EncryptionService: Handles encryption/decryption operations for text and images

Frontend (React + Vite)

frontend/
├── src/
│   ├── App.jsx                 # Main application component
│   ├── App.css                 # Styling
│   └── main.jsx                # Entry point
├── package.json                # Node.js dependencies
└── vite.config.js              # Vite configuration

Features:

  • Face image upload for embedding extraction
  • Text and image encryption interfaces
  • Decryption with real-time results
  • Security metrics visualization

Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • Node.js 16 or higher
  • pip and npm/yarn package managers

Backend Setup

  1. Navigate to the backend directory:
cd backend
  1. Create a virtual environment (recommended):
python -m venv venv
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
  1. Install Python dependencies:
pip install -r requirements.txt

Note: The face-recognition library requires dlib, which may need additional system dependencies:

  • Windows: May require Visual C++ build tools
  • macOS: brew install cmake
  • Linux: sudo apt-get install cmake

Frontend Setup

  1. Navigate to the frontend directory:
cd frontend
  1. Install Node.js dependencies:
npm install

Running the Application

Start the Backend Server

From the backend directory:

uvicorn main:app --reload --host 0.0.0.0 --port 8000

The API will be available at http://localhost:8000

API documentation (Swagger UI) is available at http://localhost:8000/docs

Start the Frontend Development Server

From the frontend directory:

npm run dev

The frontend will be available at http://localhost:3000

Usage

Step-by-Step Guide

  1. Extract Facial Embedding:

    • Upload a face image through the web interface
    • The system extracts a 128-dimensional facial embedding vector
    • This embedding serves as your unique cryptographic key
  2. Encrypt Data:

    • Choose between text or image encryption
    • Enter your text or upload an image
    • Click "Encrypt" - the system uses your facial embedding to encrypt the data
    • View security metrics (entropy, statistics) of the encrypted data
  3. Decrypt Data:

    • Use the same facial embedding (upload the same face image)
    • Click "Decrypt" to recover the original data
    • Only the correct facial embedding can successfully decrypt

API Endpoints

  • POST /api/extract-embedding: Extract facial embedding from uploaded image
  • POST /api/encrypt: Encrypt text or image data using facial embedding
  • POST /api/decrypt: Decrypt ciphertext using facial embedding
  • POST /api/security-analysis: Analyze security metrics of encrypted data
  • GET /api/health: Health check endpoint

Security Analysis

The system provides several security metrics:

  • Entropy: Measures randomness in encrypted data (higher is better, >7.0 is excellent)
  • Statistical Measures: Mean, standard deviation, min/max values
  • Chaotic Modulation: Ensures variability even with identical keys

Technical Details

Facial Embedding Extraction

  • Uses the face_recognition library (based on dlib's facial recognition model)
  • Extracts 128-dimensional vectors representing facial features
  • Normalized embeddings ensure consistent key generation

Key-Conditioned Autoencoder

  • Image Autoencoder:

    • Encoder: Convolutional layers (64→128→256 channels)
    • Latent dimension: 256
    • Decoder: Transposed convolutions
    • Key conditioning through concatenation and addition
  • Text Autoencoder:

    • Encoder: Fully connected layers (256→512→256)
    • Key conditioning: Concatenation in latent space
    • Supports variable-length text (up to 256 bytes)

Chaotic Module

  • Implements logistic map: x_{n+1} = r * x_n * (1 - x_n)
  • Parameter r = 3.95 (near chaos threshold)
  • Modulates neuron activations by 10% using chaotic sequences
  • Key-derived seeding ensures reproducibility for same user

Project Limitations & Future Work

Current Limitations

  • Simplified text encryption (frequency-based encoding)
  • Image decryption requires original dimensions (stored in ciphertext)
  • Face recognition requires clear, frontal face images
  • No training phase implemented (models use random initialization)

Future Enhancements

  • Train autoencoders on large datasets for better reconstruction
  • Implement more sophisticated text encoding schemes
  • Add support for video encryption
  • Deploy pre-trained models for better performance
  • Add user management and embedding storage
  • Implement secure key derivation functions
  • Add support for multiple faces in one image

Security Considerations

Privacy

  • No Raw Image Storage: Only embeddings (128 floats) are used, not original images
  • Local Processing: All operations can be performed locally
  • Embedding Protection: In production, store embeddings securely with encryption

Cryptographic Security

  • This is a proof-of-concept system for research purposes
  • For production use, additional security measures are required:
    • Key derivation functions (KDF)
    • Authenticated encryption
    • Secure key storage
    • Resistance analysis against known attacks

Troubleshooting

Backend Issues

  • Import Errors: Ensure all dependencies are installed: pip install -r requirements.txt
  • Face Recognition Errors: Install system dependencies for dlib (see Installation)
  • CUDA Errors: The system works on CPU, but GPU acceleration requires CUDA setup

Frontend Issues

  • CORS Errors: Ensure backend is running and CORS middleware is configured
  • Connection Refused: Check that backend server is running on port 8000
  • Module Not Found: Run npm install in the frontend directory

Performance

  • Face Embedding Extraction: ~1-2 seconds per image (CPU)
  • Text Encryption: <100ms for typical text
  • Image Encryption: ~500ms-1s for 128x128 images (CPU)
  • Decryption: Similar timing to encryption

License

This project is developed for educational and research purposes.

Authors

BioCryptNet Development Team

Acknowledgments

  • Face recognition capabilities powered by face_recognition library
  • Deep learning framework: PyTorch
  • Web framework: FastAPI
  • Frontend: React + Vite

Submission Deliverables

  1. Project Source Code: Complete backend and frontend implementation
  2. Run Instructions: Detailed setup and execution guide (this README)
  3. Architecture Documentation: Technical details and system design
  4. Security Analysis: Metrics, findings, and lessons learned

Note: This is a research prototype. For production deployment, additional security hardening and testing are essential.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages