Skip to content

Mr-Infect/Post-quantum-encryption

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PCQ Messenger - Post-Quantum Secure Chat

A quantum-resistant messaging application with real-time encryption comparison dashboard.

🌟 Features

  • πŸ” Real Kyber-512 Post-Quantum Encryption - Production-grade quantum-resistant cryptography
  • πŸ›‘οΈ Hybrid Encryption - Combines classical (X25519) + quantum-resistant (Kyber) for maximum security
  • πŸ’¬ Multi-User Chat - Unlimited clients across different networks
  • 🎨 Modern Web UI - Premium dark theme with real-time updates
  • πŸ“Š Live Monitoring Dashboard - Grafana dashboard comparing Classical vs PQ vs Hybrid encryption
  • ⚑ Real-Time Metrics - Performance, security, and throughput comparison

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client 1  β”‚         β”‚   Client 2  β”‚         β”‚   Client N  β”‚
β”‚  (Any Net)  β”‚         β”‚  (Any Net)  β”‚         β”‚  (Any Net)  β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚                       β”‚                       β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                        β”‚ Chat Server β”‚
                        β”‚  (Port 8080)β”‚
                        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                        β”‚ Prometheus  β”‚
                        β”‚  (Port 9090)β”‚
                        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                               β”‚
                        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                        β”‚   Grafana   β”‚
                        β”‚  (Port 3000)β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        (Admin Only)

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Docker & Docker Compose (for admin monitoring)
  • pip

1. Install Dependencies

pip install -r requirements.txt

2. Start the Server

On the server machine (or admin machine):

./run_server.sh

The server will start on 0.0.0.0:8080 (accessible from any network).

3. Start Admin Monitoring (Optional - Admin Only)

On the admin machine:

./run_admin.sh

This starts:

The dashboard automatically loads with encryption comparison metrics.

4. Connect Clients

On any client machine:

./run_client.sh <server-ip>

Or simply:

./run_client.sh

Then enter:

  • Server IP (e.g., 192.168.1.100 or your-server.com)
  • Your username
  • Encryption mode (Hybrid recommended)

The web interface will open automatically in your browser.

πŸ“Š Grafana Dashboard Metrics

The admin dashboard displays real-time comparisons:

Metric Classical Post-Quantum Hybrid
Encryption Speed ⚑ Fastest 🐌 Slower βš–οΈ Balanced
Security Level πŸ”‘ 128-bit classical πŸ” 128-bit quantum πŸ›‘οΈ 128-bit both
Key Size πŸ“¦ 32 bytes πŸ“¦ 1184 bytes πŸ“¦ Combined
Ciphertext Overhead βœ… Minimal ⚠️ Larger βš–οΈ Moderate

πŸ”’ Security Guarantees

Classical Encryption (X25519 + AES-256-GCM)

  • βœ… Secure against classical computers
  • ❌ Vulnerable to quantum computers (Shor's algorithm)
  • 🎯 128-bit classical security

Post-Quantum Encryption (Kyber-512)

  • βœ… Secure against quantum computers
  • βœ… NIST-standardized (FIPS 203)
  • 🎯 128-bit quantum security

Hybrid Encryption (Recommended)

  • βœ… Secure if EITHER algorithm remains unbroken
  • βœ… Defense-in-depth approach
  • 🎯 Maximum security: max(classical, quantum)

🌐 Cross-Network Setup

Option 1: Public Server

  1. Deploy server on a cloud VM (AWS, DigitalOcean, etc.)
  2. Note the public IP
  3. Clients connect using: ./run_client.sh <public-ip>

Option 2: Port Forwarding

  1. Forward port 8080 on your router to server machine
  2. Find your public IP: curl ifconfig.me
  3. Clients connect using your public IP

Option 3: Tunneling (ngrok)

# On server machine
ngrok tcp 8080

# Use the ngrok URL in clients
./run_client.sh <ngrok-url>

πŸ“ Project Structure

PCQ-messenger-backup/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ crypto_classical.py    # X25519 + AES-GCM
β”‚   β”œβ”€β”€ crypto_kyber.py         # Real Kyber-512 implementation
β”‚   β”œβ”€β”€ crypto_hybrid.py        # Hybrid encryption
β”‚   β”œβ”€β”€ server.py               # WebSocket chat server
β”‚   β”œβ”€β”€ client.py               # CLI client
β”‚   β”œβ”€β”€ web_ui.py               # Flask web interface
β”‚   β”œβ”€β”€ metrics.py              # Prometheus metrics
β”‚   └── networking.py           # Network utilities
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ style.css               # Premium dark theme
β”‚   └── app.js                  # WebSocket client
β”œβ”€β”€ templates/
β”‚   └── chat.html               # Chat interface
β”œβ”€β”€ monitoring/
β”‚   β”œβ”€β”€ docker-compose.yml      # Monitoring stack
β”‚   β”œβ”€β”€ prometheus.yml          # Prometheus config
β”‚   β”œβ”€β”€ grafana-dashboard.json  # Pre-configured dashboard
β”‚   └── grafana-provisioning/   # Auto-provisioning
β”œβ”€β”€ run_server.sh               # Server launcher
β”œβ”€β”€ run_client.sh               # Client launcher
β”œβ”€β”€ run_admin.sh                # Admin monitoring launcher
└── requirements.txt            # Python dependencies

πŸ› οΈ Advanced Usage

CLI Client (No Browser)

python -m app.client ws://<server-ip>:8080 --username YourName --mode hybrid

Custom Ports

# Server
./run_server.sh 0.0.0.0 8080 9090

# Client web UI
python -m app.web_ui --port 5001

View Metrics Directly

# Server metrics
curl http://<server-ip>:9090/metrics

# Client metrics (if running)
curl http://localhost:8001/metrics

πŸ”§ Troubleshooting

"Connection refused" error

  • Check server is running: netstat -tulpn | grep 8080
  • Check firewall: sudo ufw allow 8080
  • Verify server IP is correct

Dependencies installation fails

# Install system dependencies for liboqs
sudo apt-get update
sudo apt-get install -y cmake ninja-build libssl-dev

# Then retry
pip install -r requirements.txt

Grafana dashboard not loading

# Restart monitoring stack
cd monitoring
docker-compose down
docker-compose up -d

πŸ“ˆ Performance Benchmarks

Typical performance on modern hardware:

Operation Classical Post-Quantum Hybrid
Key Generation ~0.1ms ~0.5ms ~0.6ms
Encryption (1KB) ~0.05ms ~0.08ms ~0.09ms
Decryption (1KB) ~0.05ms ~0.08ms ~0.09ms
Handshake ~0.2ms ~1.0ms ~1.2ms

🀝 Contributing

This is a demonstration project showcasing post-quantum cryptography integration.

πŸ“„ License

MIT License - See LICENSE file for details

πŸ™ Acknowledgments

  • liboqs - Open Quantum Safe project for Kyber implementation
  • NIST - Post-Quantum Cryptography Standardization
  • Grafana & Prometheus - Monitoring infrastructure

πŸ“ž Support

For issues or questions, please open an issue on the repository.


⚠️ Security Note: While this implementation uses production-grade cryptography libraries, it's designed for educational and demonstration purposes. For production deployments, conduct a thorough security audit.

About

A quantum-resistant messaging application with real-time encryption comparison dashboard.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors