QuSec - Quantum Security Framework
Introduction
It leverages Qiskit to simulate a quantum-safe teleportation-based QDS protocol layered with the SARG04 decoy-state method to detect active tampering, forgery, and interception attacks.
PyPI Link
🚀 Features
- Teleportation-Based QDS: Transmits signature payload using a 3-qubit Bell-state entanglement and Pauli corrections.
- SARG04 Protocol Integration: Employs mathematical decoy states ($\mu$, $\nu$, vacuum) for sifting and quantum channel security.
- Attack Simulations: Test real-time quantum threat vectors including Forgery, Impersonation, Intercept-Resend, Replay, and Channel Tampering.
- Multi-Backend Execution:
Simulator: Ideal local execution via Qiskit Aer.Noisy: Local simulation mapped with a configurable depolarizing noise model.Hardware: Secure execution loop ready for real IBM Quantum API connections.
- Dynamic Threat Analysis: Dynamically calculates Quantum Bit Error Rate (QBER) and statistically evaluates it against security thresholds.
📦 Installation Guide
To install QuSec, ensure you have Python 3.9+ installed.
1. Set up a virtual environment (Recommended)
python -m venv venv
source venv/bin/activate # On macOS/Linux
# venv\Scripts\activate # On Windows
2. Install QuSec
Install QuSec directly in editable mode for local development:
pip install -e .
(Optional) If you plan on running your circuits on real IBM Quantum Hardware, install the hardware add-on:
pip install -e ".[hardware]"
💻 Quickstart
QuSec comes with a beautiful, fully-interactive Terminal User Interface (TUI).
To launch the framework and start a secure message transfer, simply run:
qusec run
Advanced Usage Flags
You can skip the interactive menus by passing parameters directly to the CLI:
- View detailed transmission steps (Bit-by-Bit):
qusec run --verbose
- Select a specific execution backend:
qusec run --backend noisy
- Machine-readable JSON output (Great for CI/CD or logging):
qusec run --json
- Tweak the mathematical constraints:
qusec run --shots 2000 --threshold 0.04
Run qusec run --help to see all available configuration options!
🛡️ Simulating Attacks
When using the interactive simulator (qusec run), you will be prompted to simulate a cyberattack vector.
- No Attack: The message transfers securely. QBER remains $0.0$, and the signature is
VERIFIED. - Forgery / Impersonation: Attempting to supply fake signature data. The verification layer catches the mathematical anomaly and blocks the transmission:
REJECTED. - Quantum Channel Tampering: Induces simulated
XandZerrors in the teleportation channel. You will see the QBER instantly spike above the defined threshold (default0.06), triggering aTHREAT DETECTEDsystem halt.
🌐 Real-World Hardware & Transport Architecture
QuSec has been upgraded into a functional, real-world secure transport framework:
Sender Laptop Receiver Laptop
┌───────────────────────┐ ┌───────────────────────┐
│ QuSec Node (Sender) │ │ QuSec Node (Receiver) │
│ ├── Gateway API │ │ ├── Gateway API │
│ ├── Key Pool │ │ ├── Key Pool │
│ └── Teleport Engine │ │ └── Teleport Engine │
└──────────┬────────────┘ └───────────┬───────────┘
│ USB Serial │ USB Serial
┌──────────▼────────────┐ ┌───────────▼───────────┐
│ ESP32 Sender │◄─── Classical Wireless ──►│ ESP32 Receiver │
│ (TRNG + Wi-Fi Relay) │ (Wi-Fi / ESP-NOW) │ (TRNG + Wi-Fi Relay) │
└───────────────────────┘ └───────────────────────┘
│ Ethernet │ Ethernet
┌──────────▼────────────┐ ┌───────────▼───────────┐
│ Optical Transceiver │◄════ Optical Fibre Cable ═►│ Optical Transceiver │
│ Media Converter │ (Quantum Channel) │ Media Converter │
└───────────────────────┘ └───────────────────────┘
Components
- 4 ESP32 Microcontrollers: Sender, Receiver, Attacker (Eve), and Auditor (QAuditor).
- Optical Transceivers & Fibre Cable: Full-duplex optical transceiver pair carrying quantum distribution and teleportation frames over Ethernet.
- 2 Ethernet Cables: Connecting Sender and Receiver laptops to their respective optical media converters.
- Auto-Detection: QuSec automatically probes USB serial ports (
/dev/cu.usbserial*,/dev/ttyUSB*) to detect ESP32 hardware and network interfaces to detect Ethernet converters.
Honest Note on Security Model: Key creation, reconciliation, and OTP encryption execute on the laptop endpoints. The browser-to-gateway hop is local plaintext. The system provides laptop-to-laptop quantum-secure transport.
🛠️ CLI Commands
1. Link Diagnostics (qusec doctor)
Self-test verifying Python environment, ESP32 USB detection, hardware TRNG entropy, Ethernet media converter link, and socket bindings:
qusec doctor
2. Continuous Interactive Quantum Chat (qusec chat)
Runs continuous two-way interactive quantum chat directly in your terminal. Starts automatically as soon as users begin messaging, and loops continuously until turned off:
# On Sender Laptop:
qusec chat --role sender
# On Receiver Laptop:
qusec chat --role receiver --peer-host <SENDER_IP>
- Real-time two-way messaging with quantum state teleportation.
- Auto-initializes entanglement and key pool as soon as the first message is sent.
- Concurrently runs the background Web Platform Gateway (
http://127.0.0.1:8765) for social media website integration. - Loops continuously until you turn it off (
/quitorCtrl+C).
3. Interactive Node & Live UI Dashboard (qusec node)
Launches the live operational terminal dashboard:
# On Sender Laptop:
qusec node --role sender
# On Receiver Laptop:
qusec node --role receiver --peer-host <SENDER_IP>
Terminal UI Display:
┌ QuSec · Sender ────────────── ● Fibre OK ● ESP32 OK ┐
│ Session a91f · Key pool 4,820 bits · QBER 2.1% │
├ Pipeline ────────────────────────────────────────────┤
│ Encode ✓ Entangle ✓ Test ✓ Teleport ▶ Correct · │
├ Log ─────────────────────────────────────────────────┤
│ 14:02:11 Bell pairs sent: 512 (64 test pairs) │
│ 14:02:12 Fidelity 0.97, CHSH 2.71 → channel trusted │
└──────────────────────────────────────────────────────┘
3. Social Media Platform Bridge Gateway (qusec gateway)
Starts the local REST + SSE platform bridge for web applications:
qusec gateway --role sender --port 8765
GET /api/status: Node status, active session, key pool, and quantum channel metrics.POST /api/send: Send message ({"to": "receiver", "message": "...", "mode": "teleportation"|"otp"}).GET /api/events: Real-time Server-Sent Events (SSE) stream.POST /api/rekey: Trigger key pool replenishment round.
4. Key Pool Inspector (qusec keys)
Inspects active cryptographic key material, rekey triggers, and burn-on-use stats:
qusec keys
5. Quantum-Secure Send (qusec send)
Transmits a message over the quantum link via state teleportation or One-Time-Pad:
qusec send --to receiver "Hello Quantum Teleportation" --mode teleportation
qusec send --to receiver "Top Secret" --mode otp
⚡ ESP32 Firmware
The ready-to-flash Arduino C++ firmware is provided in:
firmware/esp32_qusec/esp32_qusec.ino
Flash to each ESP32 board using Arduino IDE or PlatformIO:
- True Hardware RNG via
esp_random() - Wi-Fi Access Point / Station Classical Relay (Port
9877) - Serial protocol interface at
115200baud
Metadata
Release files for qusec 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| qusec-0.2.0.tar.gz | 65.6 kB | Without provenance | Details for qusec-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qusec-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for qusec-0.2.0-py3-none-any.whl |
Total release size: 136.2 kB
Release files / qusec-0.2.0.tar.gz
| Download URL | qusec-0.2.0.tar.gz |
|---|---|
| Size | 65.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb9e8788ecf084c9c73ed216c0bcf3556d25268ef749874d15251c8ab8445d0f
|
|
BLAKE2b-256 checksum How to use checksums |
75d324983a961e70cce9d6f13c7a7d9788ebfd81a91516df4b9b604764b1d987
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / qusec-0.2.0-py3-none-any.whl
| Download URL | qusec-0.2.0-py3-none-any.whl |
|---|---|
| Size | 70.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed8a0bb85d11f7c1aebc5fbdf9c484fcdaf2a972f40bdd8c811a7c6aa37da939
|
|
BLAKE2b-256 checksum How to use checksums |
7f562736e02be9c875219d8936ea5d8305bfc6a5f02210844b16136aadb38579
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for qusec 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.