# arunaya1812/quantumproject1 architecture

> Architecture diagram of the GitHub repository arunaya1812/quantumproject1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arunaya1812/quantumproject1
- Repository: https://github.com/arunaya1812/quantumproject1

## Overview

This repository is a BB84 quantum-key-distribution simulator and attack-detection prototype, extended with temporal ML detection and authenticated key establishment. The principal workflow simulates Alice and Bob exchanging photons, measures attack signals across windows, and either rejects a suspicious session or reconciles and derives an authenticated key. A separate documented workflow generates timelines, engineers temporal features, and trains a Random Forest detector. Edges reflect the excerpts, SOURCE INDEX references, or README-described workflow; unsampled details are not inferred.

Main entry points: [`bb84/secure_session.py`](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/secure_session.py) (Session Orchestrator), [`bb84/protocol.py`](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/protocol.py) (BB84 Protocol), [`bb84/timeline.py`](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/timeline.py) (Window Simulator), [`bb84/eavesdropper.py`](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/eavesdropper.py) (Attack Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["BB84 Simulation"]
  node_protocol["BB84 Protocol<br/>[protocol.py]"]
  node_qiskit["Qiskit Backend<br/>[qiskit_protocol.py]"]
  node_photon["Photon Model<br/>[photon.py]"]
  node_channel["Quantum Channel<br/>[channel.py]"]
  node_eavesdropper["Attack Models<br/>[eavesdropper.py]"]
  node_decoy["Decoy Statistics<br/>[decoy.py]"]
  node_timeline["Window Simulator<br/>[timeline.py]"]
end

subgraph group_detection["Attack Detection"]
  node_adaptive["Threshold Detectors"]
  node_features["Detection Features<br/>[features.py]"]
  node_unified["Unified Detector"]
end

subgraph group_secure["Secure Sessions"]
  node_session["Session Orchestrator<br/>[secure_session.py]"]
  node_pqc["PQC Authentication<br/>[pqc.py]"]
end

subgraph group_data["Dataset and ML"]
  node_rawdata["Timeline Dataset"]
  node_featurepipe["Temporal Feature Engineering"]
  node_trainer["Random Forest Training<br/>[train_model.py]"]
  node_model["Trained Detector<br/>[rf_detector.joblib]"]
end

node_alicebob(("Alice and Bob"))

node_alicebob -->|"request session"| node_session
node_session -->|"simulate windows"| node_timeline
node_session -->|"evaluate windows"| node_unified
node_session -->|"run BB84"| node_protocol
node_session -->|"select backend"| node_qiskit
node_session -->|"authenticate and derive"| node_pqc
node_protocol -->|"encode and measure"| node_photon
node_protocol -->|"transmit photons"| node_channel
node_protocol -->|"apply attack"| node_eavesdropper
node_channel -->|"transmit"| node_photon
node_eavesdropper -->|"intercept and resend"| node_photon
node_qiskit -->|"use bases"| node_photon
node_qiskit -->|"apply attack"| node_eavesdropper
node_timeline -->|"run windows"| node_protocol
node_timeline -->|"configure attacks"| node_eavesdropper
node_timeline -->|"measure decoy gap"| node_decoy
node_unified -->|"combine thresholds"| node_adaptive
node_unified -->|"use features"| node_features
node_session -->|"sign exchanges"| node_pqc
node_rawdata -->|"generate from"| node_timeline
node_rawdata -->|"engineer features"| node_featurepipe
node_featurepipe -->|"train from features"| node_trainer
node_trainer -->|"save model"| node_model

click node_session "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/secure_session.py"
click node_protocol "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/protocol.py"
click node_qiskit "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/qiskit_protocol.py"
click node_photon "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/photon.py"
click node_channel "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/channel.py"
click node_eavesdropper "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/eavesdropper.py"
click node_decoy "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/decoy.py"
click node_timeline "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/timeline.py"
click node_adaptive "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/adaptive_threshold.py"
click node_features "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/features.py"
click node_unified "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/unified_detector.py"
click node_pqc "https://github.com/arunaya1812/quantumproject1/blob/main/bb84/pqc.py"
click node_rawdata "https://github.com/arunaya1812/quantumproject1/blob/main/generate_timeline_dataset.py"
click node_featurepipe "https://github.com/arunaya1812/quantumproject1/blob/main/feature_engineering.py"
click node_trainer "https://github.com/arunaya1812/quantumproject1/blob/main/train_model.py"
click node_model "https://github.com/arunaya1812/quantumproject1/blob/main/models/rf_detector.joblib"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_protocol,node_qiskit,node_photon,node_channel,node_eavesdropper,node_decoy,node_timeline toneBlue
class node_adaptive,node_features,node_unified toneAmber
class node_session,node_pqc toneMint
class node_rawdata,node_featurepipe,node_trainer,node_model toneRose
class node_alicebob toneIndigo
```

## Components

### BB84 Simulation

- [BB84 Protocol](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/protocol.py): `bb84/protocol.py`
- [Qiskit Backend](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/qiskit_protocol.py): `bb84/qiskit_protocol.py`
- [Photon Model](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/photon.py): `bb84/photon.py`
- [Quantum Channel](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/channel.py): `bb84/channel.py`
- [Attack Models](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/eavesdropper.py): `bb84/eavesdropper.py`
- [Decoy Statistics](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/decoy.py): `bb84/decoy.py`
- [Window Simulator](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/timeline.py): `bb84/timeline.py`

### Attack Detection

- [Threshold Detectors](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/adaptive_threshold.py): `bb84/adaptive_threshold.py`
- [Detection Features](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/features.py): `bb84/features.py`
- [Unified Detector](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/unified_detector.py): `bb84/unified_detector.py`

### Secure Sessions

- [Session Orchestrator](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/secure_session.py): `bb84/secure_session.py`
- [PQC Authentication](https://github.com/arunaya1812/quantumproject1/blob/main/bb84/pqc.py): `bb84/pqc.py`

### Dataset and ML

- [Timeline Dataset](https://github.com/arunaya1812/quantumproject1/blob/main/generate_timeline_dataset.py): `generate_timeline_dataset.py`
- [Temporal Feature Engineering](https://github.com/arunaya1812/quantumproject1/blob/main/feature_engineering.py): `feature_engineering.py`
- [Random Forest Training](https://github.com/arunaya1812/quantumproject1/blob/main/train_model.py): `train_model.py`
- [Trained Detector](https://github.com/arunaya1812/quantumproject1/blob/main/models/rf_detector.joblib): `models/rf_detector.joblib`

### Other components

- **Alice and Bob**

## Connections

- Alice and Bob → Session Orchestrator: request session (evidence: `README.md`)
- Session Orchestrator → Window Simulator: simulate windows (evidence: `bb84/secure_session.py`)
- Session Orchestrator → Unified Detector: evaluate windows (evidence: `bb84/secure_session.py`)
- Session Orchestrator → BB84 Protocol: run BB84 (evidence: `bb84/secure_session.py`)
- Session Orchestrator → Qiskit Backend: select backend (evidence: `bb84/secure_session.py`)
- Session Orchestrator → PQC Authentication: authenticate and derive (evidence: `bb84/secure_session.py`)
- BB84 Protocol → Photon Model: encode and measure (evidence: `bb84/protocol.py`)
- BB84 Protocol → Quantum Channel: transmit photons (evidence: `bb84/protocol.py`)
- BB84 Protocol → Attack Models: apply attack (evidence: `bb84/protocol.py`)
- Quantum Channel → Photon Model: transmit (evidence: `bb84/channel.py`)
- Attack Models → Photon Model: intercept and resend (evidence: `bb84/eavesdropper.py`)
- Qiskit Backend → Photon Model: use bases (evidence: `bb84/qiskit_protocol.py`)
- Qiskit Backend → Attack Models: apply attack (evidence: `bb84/qiskit_protocol.py`)
- Window Simulator → BB84 Protocol: run windows (evidence: `bb84/timeline.py`)
- Window Simulator → Attack Models: configure attacks (evidence: `bb84/timeline.py`)
- Window Simulator → Decoy Statistics: measure decoy gap (evidence: `bb84/timeline.py`)
- Unified Detector → Threshold Detectors: combine thresholds (evidence: `bb84/unified_detector.py`)
- Unified Detector → Detection Features: use features (evidence: `bb84/unified_detector.py`)
- Session Orchestrator → PQC Authentication: sign exchanges (evidence: `bb84/secure_session.py`)
- Timeline Dataset → Window Simulator: generate from (evidence: `generate_timeline_dataset.py`)
- Timeline Dataset → Temporal Feature Engineering: engineer features (evidence: `README.md`)
- Temporal Feature Engineering → Random Forest Training: train from features (evidence: `README.md`)
- Random Forest Training → Trained Detector: save model (evidence: `train_model.py`)
