A demonstration project that simulates a post-quantum secure voice communication system using AES-GCM encryption and simulated Kyber KEM key exchange.
This project demonstrates how voice communication can be secured using post-quantum cryptography principles. It simulates a real-time voice encryption system that would be resistant to attacks from quantum computers.
- Real-time audio capture and playback using microphone and speakers
- AES-GCM encryption for symmetric encryption of audio chunks
- Simulated Kyber KEM for post-quantum key exchange
- WebSocket communication for real-time audio transmission
- Chunk-by-chunk encryption for low-latency processing
- Enhanced terminal output showing cryptographic operations
- Real-time encryption/decryption activity monitoring
- Session statistics and connection status
- Detailed key information display (private key, public key, shared secret)
Post-quantum cryptography refers to cryptographic algorithms that are designed to be secure against both classical and quantum computers. Traditional cryptographic systems like RSA and ECC (Elliptic Curve Cryptography) are vulnerable to quantum attacks using Shor's algorithm.
Kyber is a post-quantum key encapsulation mechanism based on the learning-with-errors (LWE) problem over module lattices. It's designed to be:
- Quantum-resistant: Secure against quantum computer attacks
- Efficient: Fast key generation, encapsulation, and decapsulation
- Standardized: Part of NIST's post-quantum cryptography standards
AES-GCM is a symmetric encryption algorithm that provides:
- Confidentiality: Data is encrypted and cannot be read without the key
- Authenticity: Ensures data hasn't been tampered with
- Integrity: Detects any modifications to the encrypted data
┌─────────────────┐ WebSocket ┌─────────────────┐
│ Client │◄─────────────────►│ Server │
│ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Microphone │ │ │ │ Speakers │ │
│ └─────────────┘ │ │ └─────────────┘ │
│ │ │ │ ▲ │
│ ▼ │ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ Audio │ │ │ │ Audio │ │
│ │ Capture │ │ │ │ Playback │ │
│ └─────────────┘ │ │ └─────────────┘ │
│ │ │ │ ▲ │
│ ▼ │ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ AES-GCM │ │ │ │ AES-GCM │ │
│ │ Encryption │ │ │ │ Decryption │ │
│ └─────────────┘ │ │ └─────────────┘ │
│ │ │ │ ▲ │
│ ▼ │ │ │ │
│ ┌─────────────┐ │ │ ┌─────────────┐ │
│ │ WebSocket │ │ │ │ WebSocket │ │
│ │ Sender │ │ │ │ Receiver │ │
│ └─────────────┘ │ │ └─────────────┘ │
└─────────────────┘ └─────────────────┘
- Python 3.7 or higher
- Microphone and speakers/headphones
- Internet connection (for installing dependencies)
-
Clone or download this project
# If you have git git clone https://github.com/dineshyadav03/postquantumkeyexchange.git cd postquantumkeyexchange # Or simply download and extract the files
-
Install dependencies
pip install -r requirements.txt
-
Verify installation
python test_installation.py
simple_voice_demo.py- Enhanced demo with detailed cryptographic output (recommended)pq_voice_demo.py- Original demo with basic functionalitytest_installation.py- Verify all dependencies are installedtest_audio.py- Test microphone and speaker functionalitytest_websocket.py- Test WebSocket connectivity
The demo requires two instances running simultaneously - one as a server and one as a client.
Open a terminal/command prompt and run:
python simple_voice_demo.py serverYou should see enhanced output like:
============================================================
POST-QUANTUM KEY EXCHANGE SIMULATION
============================================================
Simulating Kyber KEM (Key Encapsulation Mechanism)...
Private Key: 8f33d497b199f62e...836911e6
Public Key: 0ed2c293dbfd7fd0...a4e46ef8
Shared Secret: 44656d6f53686172...6d6d3132
Key exchange completed successfully!
============================================================
Derived AES-256 Key: c6bc51ca62465dd7...7b8d2a50
Ready for secure communication!
============================================================
============================================================
SECURE VOICE COMMUNICATION SERVER
============================================================
Starting audio capture and playback...
Starting WebSocket server...
Audio system ready!
Server listening for connections...
============================================================
Open another terminal/command prompt and run:
python simple_voice_demo.py clientYou should see enhanced output like:
============================================================
POST-QUANTUM KEY EXCHANGE SIMULATION
============================================================
Simulating Kyber KEM (Key Encapsulation Mechanism)...
Private Key: 8f33d497b199f62e...836911e6
Public Key: 0ed2c293dbfd7fd0...a4e46ef8
Shared Secret: 44656d6f53686172...6d6d3132
Key exchange completed successfully!
============================================================
Derived AES-256 Key: c6bc51ca62465dd7...7b8d2a50
Ready for secure communication!
============================================================
============================================================
SECURE VOICE COMMUNICATION CLIENT
============================================================
Starting audio capture and playback...
Connecting to server...
Audio system ready!
============================================================
Connected to server successfully!
Ready to capture and encrypt audio...
Ready to receive and decrypt audio...
============================================================
During operation, you'll see live encryption/decryption activity:
[ENCRYPT] Chunk #50 | Size: 4096 bytes | Nonce: a1b2c3d4...
[DECRYPT] Chunk #50 | Size: 4096 bytes | Nonce: a1b2c3d4...
[ENCRYPT] Chunk #100 | Size: 4096 bytes | Nonce: e5f6g7h8...
[DECRYPT] Chunk #100 | Size: 4096 bytes | Nonce: e5f6g7h8...
- Speak into the microphone on the client side
- Listen to the decrypted audio on the server side
- The audio should be transmitted securely with minimal delay
- Watch the terminal for real-time encryption/decryption activity
When you stop the demo, you'll see session statistics:
Session Statistics:
Total encrypted: 1250 chunks
Total decrypted: 1250 chunks
============================================================
Press Ctrl+C in either terminal to stop the respective instance.
- Sample Rate: 44.1 kHz
- Chunk Size: 1024 samples
- Channels: Mono (1 channel)
- Format: 32-bit float
- Algorithm: AES-256-GCM
- Key Size: 256 bits (32 bytes)
- Nonce Size: 96 bits (12 bytes)
- Authentication Tag: 128 bits (16 bytes)
- Method: PBKDF2 (Password-Based Key Derivation Function 2)
- Salt: Fixed salt for demo purposes
- Iterations: 100,000 rounds
- Output: 256-bit AES key
- Protocol: WebSocket over TCP
- Port: 8765
- Message Format: JSON
- Data Encoding: Base64
- ✅ Symmetric encryption of real-time audio
- ✅ Key derivation from shared secret
- ✅ Authenticated encryption (AES-GCM)
- ✅ Real-time processing with low latency
- 🔄 Kyber KEM key exchange (simulated with random key generation)
- 🔄 Post-quantum security (demonstrates the concept)
- ❌ Real Kyber KEM implementation (would require additional libraries)
- ❌ Perfect Forward Secrecy (keys don't change during session)
- ❌ Certificate validation (no PKI infrastructure)
- ❌ Network security (no TLS/DTLS)
- ❌ Production-ready code (this is a demonstration)
-
"No module named 'sounddevice'"
- Solution: Install dependencies with
pip install -r requirements.txt
- Solution: Install dependencies with
-
"No audio devices found"
- Solution: Check your microphone and speaker connections
- On Windows: Check Windows Audio service
- On Linux: Check ALSA/PulseAudio configuration
-
"WebSocket connection failed"
- Solution: Make sure the server is running before starting the client
- Check if port 8765 is available
-
"Audio quality is poor"
- Solution: Check microphone levels and speaker volume
- Ensure stable network connection (even for localhost)
-
"Permission denied" for microphone
- Solution: Grant microphone permissions to your terminal/IDE
- On macOS: System Preferences > Security & Privacy > Microphone
- Close unnecessary applications to reduce CPU usage
- Use wired headphones to reduce audio latency
- Ensure stable system performance for real-time processing
- Test with short phrases initially to verify functionality
This demo is designed to help understand:
- Post-quantum cryptography concepts and why they're important
- Real-time encryption challenges and solutions
- Audio processing in Python
- WebSocket communication for real-time data
- Symmetric encryption with authentication
- Key derivation from shared secrets
Potential improvements for a production system:
- Real Kyber KEM implementation using libraries like liboqs
- Perfect Forward Secrecy with key rotation
- TLS/DTLS integration for network security
- Certificate-based authentication
- Multi-user support with conference rooms
- Mobile app integration
- Voice activity detection to reduce bandwidth
- Audio compression before encryption
This project is for educational and demonstration purposes. Feel free to use and modify for learning about post-quantum cryptography and real-time audio encryption.
This is a demonstration project, but suggestions and improvements are welcome! Focus areas:
- Code clarity and documentation
- Educational explanations
- Performance optimizations
- Additional security features
Note: This is a demonstration project. For production use, consult with cryptography experts and use established, audited libraries for post-quantum cryptography.