Skip to content

MugishaProsper/quantum.cryptography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simulated Quantum Cryptography

A Python-based simulation of quantum-inspired cryptographic communication between Alice and Bob, with optional eavesdropper (Eve) interference.

Overview

This project demonstrates cryptographic concepts including:

  • Quantum-inspired key generation and hashing
  • AES-CBC encryption for secure message transmission
  • Message integrity verification using cryptographic hashes
  • Eavesdropper simulation to demonstrate tampering detection

Features

  • Quantum-Inspired Encryption: Optional quantum key generation for enhanced hash security
  • Classical Encryption Fallback: Disable quantum features to use standard SHA-256 hashing
  • Eavesdropper Simulation: Simulate man-in-the-middle attacks with Eve tampering messages
  • Integrity Verification: Detect message tampering through hash comparison

Installation

  1. Clone the repository:
git clone https://github.com/MugishaProsper-Simulated-Quantum-Cryptography.git
cd Simulated-Quantum-Cryptography
  1. Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Quick Start

Command Line Interface

python main.py

Graphical User Interface

python interface.py

Usage

GUI Mode (Recommended for Testing)

Run the graphical interface:

python interface.py

Features:

  • Toggle quantum encryption on/off
  • Enable/disable eavesdropper simulation
  • Configure Eve's tampering behavior
  • Real-time color-coded communication log
  • Generate new secret keys
  • Clear log history

CLI Mode

Run the command-line program:

python main.py

Interactive Prompts

  1. Enable quantum encryption? (y/n)

    • y: Use quantum-inspired hashing with random quantum keys
    • n: Use standard SHA-256 hashing
  2. Simulate eavesdropper (Eve)? (y/n)

    • y: Enable Eve to intercept communication
    • n: Direct communication between Alice and Bob
  3. Should Eve tamper with the message? (y/n)

    • Only appears if Eve is enabled
    • Modifies the encrypted message in transit
  4. Should Eve tamper with the hash? (y/n)

    • Only appears if Eve is enabled
    • Modifies the encrypted hash in transit

Example Session

=== Simulated Quantum Cryptography System ===

Enable quantum encryption? (y/n, default=y): y
Simulate eavesdropper (Eve)? (y/n, default=n): y
  Should Eve tamper with the message? (y/n, default=y): y
  Should Eve tamper with the hash? (y/n, default=n): n

==================================================

Enter your message: Hello, Bob!

[Alice] Message encrypted and sent
  Encrypted message: 70q3AspF3ldk3UPdvOAZAg==+UHhgLzDbFv4KGuHNjRfAobmkL...
  Encrypted hash: 7awrwEGRKonZasMe6LHwsA==xYE0toTlU297fFUmuT3eJ8KW6M...
  Quantum mode: Enabled

[Eve] Intercepting communication...
  Message tampered: True
  Hash tampered: False

[Bob] Receiving and verifying message...

❌ Decryption/Verification failed: Padding is incorrect.

Project Structure

Simulated-Quantum-Cryptography/
├── main.py                    # Entry point and user interface
├── requirements.txt           # Python dependencies
├── README.md                  # This file
├── docs/
│   ├── ARCHITECTURE.md        # System architecture documentation
│   └── API.md                 # Module API reference
└── src/
    ├── __init__.py            # Package initialization
    ├── communication.py       # Alice and Bob communication protocol
    ├── encryptor.py           # AES encryption utilities
    ├── decryptor.py           # AES decryption utilities
    ├── hash_utils.py          # Quantum-inspired hashing
    ├── quantum_key.py         # Quantum key generation
    ├── eavesdropper.py        # Eve tampering simulation
    └── utils.py               # General utilities

How It Works

1. Key Generation

  • A shared secret key is generated using os.urandom()
  • If quantum mode is enabled, a quantum key is also generated for hashing

2. Message Sending (Alice)

  • Alice creates a hash of her message (with or without quantum key)
  • The hash is encrypted with the shared secret key
  • The message itself is also encrypted with the shared secret key

3. Optional Interception (Eve)

  • Eve can intercept and tamper with encrypted messages or hashes
  • Tampering modifies random characters in the encrypted data

4. Message Receiving (Bob)

  • Bob decrypts both the message and the hash
  • Bob recalculates the hash of the decrypted message
  • If hashes match, integrity is verified; otherwise, tampering is detected

Security Notes

⚠️ This is a simulation for educational purposes only

  • This is NOT actual quantum cryptography (no quantum entanglement or superposition)
  • Uses classical cryptographic primitives (AES, SHA-256)
  • The "quantum" aspect simulates randomness and key distribution concepts
  • Not suitable for production security applications

Requirements

  • Python 3.10+
  • pycryptodome >= 3.19.0

License

This project is for educational purposes.

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

About

just a proof of concept

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages