Skip to content

Zrahay/Quantum-Secure-Email-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuMail - Quantum Secure Email Client

A secure email client implementing multi-layer encryption with AES-256-GCM, One-Time Pad (OTP), and Post-Quantum Cryptography (PQC) using CRYSTALS-Kyber to protect against both classical and quantum computer attacks.

Features

  • Multi-Layer Encryption: 3-layer encryption combining OTP, AES-256-GCM, and Post-Quantum Cryptography
  • Quantum-Resistant Security: CRYSTALS-Kyber algorithm (NIST-selected standard) protects against future quantum attacks
  • End-to-End Encryption: Messages are encrypted on the sender's device and decrypted only by the recipient
  • Secure Key Management: Quantum key exchange and secure key storage
  • Cross-Platform: Flutter-based frontend supports Windows, macOS, and Linux
  • Attachment Support: Encrypt and send file attachments securely
  • Modern Architecture: Microservices-based backend with Docker support

Architecture Overview

+------------------------------------------------------------------+
|                    Flutter Desktop Frontend                       |
|                  (Windows / macOS / Linux)                        |
+------------------------------------------------------------------+
                                |
                                v
+------------------------------------------------------------------+
|                   .NET 9 Backend API (:5001)                      |
|              Authentication & Email Management                    |
+------------------------------------------------------------------+
                                |
        +-----------------------+-----------------------+
        |                       |                       |
        v                       v                       v
+---------------+      +----------------+      +---------------+
|  PostgreSQL   |      | Crypto Layer   |      | Key Manager   |
|   Database    |      |   Services     |      |   (:2020)     |
+---------------+      +----------------+      +---------------+
                               |
           +-------------------+-------------------+
           |                   |                   |
           v                   v                   v
    +------------+     +------------+     +------------+
    | OTP Layer  |     | AES Layer  |     | PQC Layer  |
    |  (:2021)   |     |  (:2022)   |     |  (:2023)   |
    +------------+     +------------+     +------------+

Encryption Layers

Layer 1: One-Time Pad (OTP)

  • Perfect secrecy through XOR encryption with truly random keys
  • Keys are as long as the message for maximum security

Layer 2: AES-256-GCM

  • Industry-standard symmetric encryption
  • Authenticated encryption with associated data
  • 256-bit key strength

Layer 3: Post-Quantum Cryptography (PQC)

  • CRYSTALS-Kyber algorithm (NIST-selected standard)
  • Protects against quantum computer attacks
  • Hybrid encryption combining PQC with classical algorithms

Prerequisites

Required Software

  • PostgreSQL 17+ - Database server
  • .NET 9 SDK - Backend API runtime
  • Flutter SDK 3.8.1+ - Frontend development framework
  • Python 3.8+ - Crypto services runtime
  • Git - Version control

Python Dependencies

pip install flask flask-cors requests cryptography

Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/Quantum-Secure-Email-Client.git
cd Quantum-Secure-Email-Client

2. Database Setup

Install PostgreSQL

  • Download and install PostgreSQL 17+ from postgresql.org
  • Remember the password you set for the postgres user

Create Database and Run Schema

-- Connect to PostgreSQL as superuser
psql -U postgres

-- Create database
CREATE DATABASE quantum_auth;

-- Connect to the database and run schema files
\c quantum_auth
\i database/schema.sql
\i database/email_schema.sql

3. Environment Configuration

Copy the example environment file and configure it:

cp .env.example .env

Edit .env with your settings:

# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=quantum_auth
DB_USERNAME=postgres
DB_PASSWORD=your_postgres_password_here

# JWT Configuration
JWT_SECRET_KEY=your-super-secret-jwt-key-must-be-at-least-32-characters
JWT_ISSUER=QuMail
JWT_AUDIENCE=QuMail-Users
JWT_EXPIRES_MINUTES=60

Generate secure secrets:

# Generate a secure JWT secret key
openssl rand -base64 32

4. Start Services

Option A: Automated Setup (Windows)

start_server.bat

Option B: Manual Setup

Step 1: Start Crypto Services

# Terminal 1 - Key Manager
cd Key_Manager/km
python server.py

# Terminal 2 - OTP API
cd level1
python otp_api_test.py

# Terminal 3 - AES Server
cd level2new
python server2.py

# Terminal 4 - PQC Server
cd level3
python pqc_server.py

Step 2: Start Backend API

# Terminal 5 - Backend API
cd Email_client/QuMail.EmailProtocol
dotnet run

Step 3: Start Frontend

# Terminal 6 - Flutter Frontend
cd frontend
flutter pub get
flutter run -d windows  # or -d macos, -d linux

Option C: Docker Deployment

# Development
docker-compose -f docker/docker-compose.yml up -d

# Production
docker-compose -f docker/docker-compose-prod.yml up -d

Project Structure

Quantum-Secure-Email-Client/
|-- database/                    # Database schema files
|   |-- schema.sql              # Authentication tables
|   |-- email_schema.sql        # Email tables
|-- Email_client/                # .NET Backend API
|   |-- QuMail.EmailProtocol/
|       |-- Controllers/        # API controllers
|       |-- Services/           # Business logic & crypto services
|       |-- Models/             # Data models
|       |-- appsettings.json    # Configuration
|-- frontend/                    # Flutter frontend application
|   |-- lib/                    # Dart source code
|   |-- test/                   # Flutter unit tests
|   |-- pubspec.yaml            # Flutter dependencies
|-- Key_Manager/                 # Key management service
|   |-- km/
|       |-- server.py           # Key Manager API
|-- level1/                      # OTP encryption service
|   |-- otp_api_test.py         # OTP API server
|-- level2new/                   # AES encryption service
|   |-- server2.py              # AES API server
|-- level3/                      # PQC encryption service
|   |-- pqc_server.py           # PQC API server
|-- docker/                      # Docker configuration
|   |-- docker-compose.yml      # Development compose
|   |-- docker-compose-prod.yml # Production compose
|-- tests/                       # Test suite
|-- logs/                        # Service log files
|-- start_server.bat            # Windows startup script

Service Ports

Service Port
Key Manager 2020
OTP API 2021
AES Server 2022
PQC Server 2023
Backend API 5001

Testing

Backend Tests (.NET)

cd Email_client/QuMail.EmailProtocol.Tests
dotnet test --verbosity normal

Frontend Tests (Flutter)

cd frontend
flutter test

Python Crypto Tests

cd tests/python
pip install -r requirements.txt
pytest -v

Security Considerations

Environment Variables

  • NEVER commit .env files to version control
  • Use strong, unique passwords for database access
  • Generate secure JWT secret keys (minimum 32 characters)
  • Rotate secrets regularly in production

Database Security

  • Use strong PostgreSQL passwords
  • Limit database user privileges
  • Enable SSL connections in production
  • Implement regular database backups

Application Security

  • Keep all dependencies updated
  • Use HTTPS in production environments
  • Implement proper input validation
  • Monitor logs for suspicious activity

Troubleshooting

Database Connection Issues

# Check if PostgreSQL is running
pg_ctl status

# Check database connection
psql -U postgres -d quantum_auth -c "SELECT version();"

Port Conflicts

# Linux/Mac - check port usage
lsof -i :2020
lsof -i :5001

# Windows - check port usage
netstat -ano | findstr :2020
netstat -ano | findstr :5001

Flutter Build Issues

flutter clean
flutter pub get
flutter doctor

.NET Build Issues

dotnet clean
dotnet restore
dotnet build

Contributing

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

License

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

Copyright (c) 2025 Shubhang Sinha

Support

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review log files in the logs/ directory
  3. Verify all services are running on correct ports
  4. Ensure all dependencies are properly installed
  5. Open an issue in the repository

About

A secure email client leveraging post-quantum cryptography for end-to-end encrypted communication.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5