Quantum Secure Email Client - Complete Setup Guide
QuMail - Quantum Secure Email Client
A comprehensive quantum-resistantsecure email client with multi-layerthat implements multiple layers of encryption including AES-256-GCM, One-Time Pad (OTP), and Post-Quantum Cryptography (PQC) using CRYSTALS-Kyber to protect against both classical and quantum computer attacks.
🏗️ Architecture Overview
This application consists of multiple components working togethertogether to provide end-to-end encryption:
-
Frontend: Flutter desktop application for Windows
) -
Backend: .NET 8 Web API
withhandling authentication and email management - Database: PostgreSQL for user authentication and email storage
-
Crypto Services: Multiple Python services for different encryption layers
- Key Manager (Port 2020): Manages quantum keys
- Key Manager: Manages quantum cryptographic keys
- OTP API:
Port 2021):One-Time Pad encryption/decryption - AES Server:
Port 2022):AES-256-GCM encryption/decryption - Main Backend API (Port 5001): Handles PQC operations and all email functionality
- PQC Server: Post-Quantum Cryptography operations
- Main Backend API: Handles all email functionality and authentication
📋 Prerequisites
Before setting up the application, ensure you have the following installed:
Python Dependencies
pip install flask flask-cors requests cryptography
🚀 Quick Start
1. Clone the Repository
git clone <repository-url> cd Qunatum-Secure-Email-Clientcd quantum
2. Database Setup
Install PostgreSQL
- Download and install PostgreSQL 17+ from postgresql.org
- During installation, remember the password you set for the
postgresuser
Option B: Manual Setup
Step 1: Start Crypto Services
# Terminal 1 - Key Manager# Terminal 1 - Key Manager (Port 2020)cd Key_Manager/km python server.py # Terminal 2 - OTP API# Terminal 2 - OTP API (Port 2021)cd level1 python otp_api_test.py # Terminal 3 - AES Server# Terminal 3 - AES Server (Port 2022)cd level2new python server2.py # Terminal 4 - PQC Server cd level3 python pqc_server.py
Step 2: Start Backend API
# Terminal 5 - Backend API# Terminal 4 - Backend API (Port 5001)cd Email_client/QuMail.EmailProtocol dotnet rundotnet run --urls "http://localhost:5001"
Step 3: Start Frontend
# Terminal 6 - Flutter Frontend# Terminal 5 - Flutter Frontendcd frontend flutter pub get flutter run -d windows
🔧 Detailed Setup Instructions
Database Setup (Detailed)
Windows PostgreSQL Setup
- Download PostgreSQL installer from postgresql.org
- Run the installer and follow the setup wizard
- Set a strong password for the
postgressuperuser - Add PostgreSQL to your PATH environment variable
- Verify installation:
psql --version
Configure Backend
-
Navigate to the backend directory:
cd Email_client/QuMail.EmailProtocol -
Restore dependencies:
dotnet restore
-
Build the project:
dotnet build
-
Run the backend:
dotnet run --urls "http://localhost:5001" -
Run the backend:
dotnet run
Frontend Setup (Detailed)
Install Flutter SDK
- Download Flutter SDK from flutter.dev
- Extract to a directory (e.g.,
C:\flutter) - Add Flutter to your PATH environment variable
- Verify installation:
flutter doctor
Key Manager Service
cd Key_Manager/km
python server.py
- Runs on:
http://localhost:2020 - Manages quantum keys for encryption
- Stores keys in
key_store.json
OTP API Service
cd level1
python otp_api_test.py
- Runs on:
http://localhost:2021 - Provides One-Time Pad encryption/decryption
- Requires
encoder.exein the same directory
AES Server Service
cd level2new
python server2.py
- Runs on:
http://localhost:2022 - Provides AES-256-GCM encryption/decryption
- Integrates with Key Manager for key exchange
Backend API Service (Handles PQC Operations)
PQC Server Service
cd level3
python pqc_server.py- Provides Post-Quantum Cryptography operations
- Uses CRYSTALS-Kyber algorithm
Backend API Service
cd Email_client/QuMail.EmailProtocol dotnet rundotnet run --urls "http://localhost:5001"
- Runs on:
http://localhost:5001 - Provides Post-Quantum Cryptography operations via PQCController
- Uses CRYSTALS-Kyber algorithm
- Handles all email functionality and authentication
- Integrates with all crypto services
🔍 Verification & Testing
Check Service Health
# Check if all services are running # Replace with actual URLs shown in service startup logscurl http://localhost:5001/api/healthcurl http://localhost:2020/health curl http://localhost:2021/api/otp/health curl http://localhost:2022/api/health curl http://localhost:2023/health
Test User Credentials
-
Email:
test@example.com -
Password:
password123
Create New User
You can create new users through the registration endpoint:
# Replace with the actual backend URL shown in startup logs curl -X POST http://localhost:5001/api/auth/register \ -H "Content-Type: application/json" \ -d '{ "email": "newuser@example.com", "password": "newpassword123", "name": "New User" }'
🚨 Troubleshooting
Common Issues
Database Connection Issues
# Check if PostgreSQL is running pg_ctl status # Restart PostgreSQL service (Windows) net stop postgresql-x64-17 net start postgresql-x64-17 # Check database connection psql -U postgres -d quantum_auth -c "SELECT version();"
Port Conflicts
If you encounter port conflicts, check what's using the ports:
# Windows - check for port usage# Windowsnetstat -ano | findstr :5001netstat -ano | findstr :2020 netstat -ano | findstr :2021 netstat -ano | findstr :2022 netstat -ano | findstr :2023 netstat -ano | findstr :500 # Kill process by PID taskkill /F /PID <process_id>
Flutter Build Issues
# Clean Flutter cache flutter clean flutter pub get # Check Flutter doctor flutter doctor # Rebuild flutter build windows
-
key_manager.log- Key Manager service logs -
otp_api.log- OTP API service logs -
aes_server.log- AES Server logs -
pqc_server.log- PQC Server logs
📁 Project Structure
Qunatum-Secure-Email-Client/
quantum/
├── 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 services
│ ├── Models/ # Data models
│ └── appsettings.json # Configuration
├── frontend/ # Flutter frontend application
│ ├── lib/ # Dart source code
│ ├── 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
│ └── encoder.exe # OTP encoder binary
├── level2new/ # AES encryption service
│ ├── server2.py # AES API server
│ └── aes_gcm_demo.exe # AES GCM binary
├── level3/ # PQC encryption service
│ ├── pqc_server.py # PQC API server
│ └── pqc_server_backup.py # Backup PQC server
├── logs/ # Service log files
├── start_server.bat # Windows startup script
├── start_backend.bat # Backend startup script
└── README.md # This file
🔐 Security Considerations
Environment Variables
- NEVER commit
.envfiles to version control - Use strong, unique passwords for database access
- Generate secure JWT secret keys (minimum 32 characters)
- Generate unique application secret keys for each deployment
- Rotate secrets regularly in production
- Use environment-specific configurations
- Consider using secret management services in production
Application Security
- Keep all dependencies updated
- Use HTTPS in production environments
- Implement proper input validation
- Monitor logs for suspicious activity
🚀 Production Deployment
Environment Setup
- Use environment variables for all sensitive configuration
- Set up proper logging and monitoring
- Configure reverse proxy (nginx/Apache)
- Enable SSL/TLS certificates
- Set up database replication and backups
Performance Optimization
- Configure connection pooling
- Implement caching strategies
- Optimize database queries
- Use CDN for static assets
- Monitor resource usage
📞 Support
Support
If you encounter issues during setup:
- 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
- Check database connectivity and schema
📄 License
License
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Coding! 🚀
For additional help or questions, please refer to the project documentation or create an issue in the repository.
0 commit comments