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.
- 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
+------------------------------------------------------------------+
| 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) |
+------------+ +------------+ +------------+
- Perfect secrecy through XOR encryption with truly random keys
- Keys are as long as the message for maximum security
- Industry-standard symmetric encryption
- Authenticated encryption with associated data
- 256-bit key strength
- CRYSTALS-Kyber algorithm (NIST-selected standard)
- Protects against quantum computer attacks
- Hybrid encryption combining PQC with classical algorithms
- 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
pip install flask flask-cors requests cryptographygit clone https://github.com/yourusername/Quantum-Secure-Email-Client.git
cd Quantum-Secure-Email-Client- Download and install PostgreSQL 17+ from postgresql.org
- Remember the password you set for the
postgresuser
-- 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.sqlCopy the example environment file and configure it:
cp .env.example .envEdit .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=60Generate secure secrets:
# Generate a secure JWT secret key
openssl rand -base64 32start_server.batStep 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.pyStep 2: Start Backend API
# Terminal 5 - Backend API
cd Email_client/QuMail.EmailProtocol
dotnet runStep 3: Start Frontend
# Terminal 6 - Flutter Frontend
cd frontend
flutter pub get
flutter run -d windows # or -d macos, -d linux# Development
docker-compose -f docker/docker-compose.yml up -d
# Production
docker-compose -f docker/docker-compose-prod.yml up -dQuantum-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 | Port |
|---|---|
| Key Manager | 2020 |
| OTP API | 2021 |
| AES Server | 2022 |
| PQC Server | 2023 |
| Backend API | 5001 |
cd Email_client/QuMail.EmailProtocol.Tests
dotnet test --verbosity normalcd frontend
flutter testcd tests/python
pip install -r requirements.txt
pytest -v- NEVER commit
.envfiles to version control - Use strong, unique passwords for database access
- Generate secure JWT secret keys (minimum 32 characters)
- Rotate secrets regularly in production
- Use strong PostgreSQL passwords
- Limit database user privileges
- Enable SSL connections in production
- Implement regular database backups
- Keep all dependencies updated
- Use HTTPS in production environments
- Implement proper input validation
- Monitor logs for suspicious activity
# Check if PostgreSQL is running
pg_ctl status
# Check database connection
psql -U postgres -d quantum_auth -c "SELECT version();"# Linux/Mac - check port usage
lsof -i :2020
lsof -i :5001
# Windows - check port usage
netstat -ano | findstr :2020
netstat -ano | findstr :5001flutter clean
flutter pub get
flutter doctordotnet clean
dotnet restore
dotnet build- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2025 Shubhang Sinha
If you encounter issues:
- Check the troubleshooting section above
- Review log files in the
logs/directory - Verify all services are running on correct ports
- Ensure all dependencies are properly installed
- Open an issue in the repository