Skip to content

Interactive simulator demonstrating the BB84 Quantum Key Distribution protocol using quantum principles of superposition and measurement

Notifications You must be signed in to change notification settings

PRODHOSH/bb84_simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

92 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Typing SVG

React TypeScript Three.js Vite Tailwind CSS Docker

Live Demo GitHub Stars License


๐ŸŽฌ Demo & Screenshots

๐ŸŒŸ 3D Quantum Simulation in Action

3D Simulation Demo

Real-time photon transmission with polarization states

Home Page

Home Page - Quantum-themed landing

Simulation Page

3D Simulation - Interactive photon visualization

Theory Page

Theory - Educational content

Analytics Dashboard

Analytics - Real-time charts & metrics

๐Ÿ”ฌ Photon Polarization States

Polarization States

Four quantum polarization states: Vertical, Horizontal, Diagonal, Anti-diagonal


๐Ÿ”ญ Overview

Experience quantum cryptography like never before - Watch individual photons travel through space in real-time 3D as they establish an unbreakable secret key!

BB84 Quantum Key Distribution Simulator is a cutting-edge web application that brings quantum mechanics to life. Built with React, Three.js, and modern web technologies, it provides an immersive 3D visualization of the groundbreaking BB84 protocol invented by Charles Bennett and Gilles Brassard in 1984.

๐ŸŽฏ The Quantum Advantage

Traditional encryption can be broken with enough computing power. Quantum Key Distribution uses the laws of physics themselves to guarantee security - making it future-proof against even quantum computers!

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  "Any observation of a quantum system disturbs its state"   โ”‚
โ”‚        - The principle that makes BB84 unbreakable          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

๐ŸŽฎ Interactive 3D Simulation

  • Real-time photon animation in 3D space
  • Adjustable photon count (8-32)
  • Color-coded basis matching
    • ๐ŸŸข Green = Bases match (key kept)
    • ๐Ÿ”ด Red = Bases differ (discarded)
  • Smooth camera controls and zoom
  • Particle effects for quantum states

๐Ÿ”ฌ Quantum Physics Visualization

  • 4 Polarization States fully rendered:
    • Vertical (|) - Horizontal (โ€”)
    • Diagonal (/) - Anti-diagonal ()
  • Rectilinear (+) & Diagonal (ร—) bases
  • Photon state collapse on measurement
  • Quantum uncertainty demonstrated

๐Ÿ‘๏ธ Eavesdropper Simulation

  • Toggle Eve mode with one click
  • Real-time error injection
  • QBER calculation (Quantum Bit Error Rate)
  • Security threshold visualization
  • Automatic detection of tampering

๐Ÿ“Š Advanced Analytics

  • Interactive dashboard with charts
  • Key generation statistics
  • Efficiency metrics
  • Error rate analysis
  • Basis matching breakdown
  • Export simulation results

๐ŸŽจ Stunning UI/UX

๐Ÿ’Ž Modern Design Features

  • ๐ŸŒŸ Animated starfield background with colorful particles
  • ๐ŸŽจ Quantum gradient color scheme (Blue โ†’ Purple)
  • โœจ Glow effects on interactive elements
  • ๐ŸŽญ Smooth transitions and animations
  • ๐Ÿ“ฑ Fully responsive design for all devices
  • ๐ŸŒ™ Dark theme optimized for long viewing
  • ๐ŸŽฏ Intuitive controls with tooltips
  • ๐Ÿ’ฌ Built-in AI chatbot for instant help

๐Ÿš€ Quick Start

Prerequisites

Choose one of the following:

  • Node.js 18+ with npm/yarn/bun
  • Docker (no Node.js required)

Option 1: Using Node.js

# Clone the repository
git clone https://github.com/PRODHOSH/bb84_simulation.git
cd bb84_simulation

# Install dependencies
npm install

# Start development server
npm run dev

Option 2: Using Docker ๐Ÿณ

# Clone the repository
git clone https://github.com/PRODHOSH/bb84_simulation.git
cd bb84_simulation

# Build and run with Docker
docker build -t bb84-simulation .
docker run -p 3000:80 bb84-simulation

# Access at http://localhost:3000

Build for Production

# Node.js
npm run build
npm run preview

# Or with Docker
docker build -t bb84-simulation .
docker run -d -p 3000:80 bb84-simulation

๐Ÿณ Docker Compose (Optional)

For easier container management, create a docker-compose.yml:

version: '3.8'
services:
  bb84-simulator:
    build: .
    ports:
      - "3000:80"
    restart: unless-stopped

Then run:

docker-compose up -d

Multi-Stage Build Process

Stage Base Image Purpose
Builder node:20-alpine Install deps, build app
Production nginx:alpine Serve static files

Final Image Size: ~50MB (optimized Alpine images)


๐ŸŽฏ How to Use

๐ŸŽฌ Step-by-Step Guide

  1. โš™๏ธ Set Parameters

    • Adjust photon count using the slider (8-32)
    • Toggle Eve to simulate eavesdropping
  2. โ–ถ๏ธ Run Simulation

    • Click "Run Simulation" button
    • Watch photons travel in 3D space
  3. ๐Ÿ‘€ Observe

    • Green photons = Matching bases (kept)
    • Red photons = Different bases (discarded)
    • See polarization states in real-time
  4. ๐Ÿ“Š Analyze Results

    • View secret key generated
    • Check error rates
    • Explore analytics dashboard

๐Ÿ”ฌ The Science

Protocol Steps

graph TB
    A[๐ŸŽฒ Alice: Generate Random Bits] --> B[๐Ÿ“ก Alice: Choose Random Bases]
    B --> C[๐ŸŒŸ Alice: Encode Photons]
    C --> D{๐Ÿ‘๏ธ Eve Intercepts?}
    D -->|Yes| E[โš ๏ธ Eve: Measures & Disturbs]
    D -->|No| F[โœ… Clean Transmission]
    E --> G[๐Ÿ“ฌ Bob: Receives Photons]
    F --> G
    G --> H[๐Ÿ” Bob: Random Measurement]
    H --> I[๐Ÿ“ข Public Basis Comparison]
    I --> J[๐Ÿ”‘ Keep Matching Bases]
    J --> K[๐Ÿ“Š Error Rate Check]
    K --> L{QBER > 25%?}
    L -->|Yes| M[โŒ Abort - Eve Detected]
    L -->|No| N[โœ… Secure Key Ready!]
    
    style A fill:#286EFF
    style N fill:#00FF88
    style M fill:#FF4444
    style D fill:#AA50FF
Loading

Quantum States

Basis State Symbol Bit Value
Rectilinear (+) Vertical | 0
Rectilinear (+) Horizontal โ€” 1
Diagonal (ร—) Diagonal / 0
Diagonal (ร—) Anti-diagonal \ 1

Security Guarantee

No-Cloning Theorem + Heisenberg Uncertainty = Unbreakable Security โœจ


๐Ÿ’ป Tech Stack

๐Ÿ› ๏ธ Built With Modern Tools

React TypeScript Three.js React Three Fiber Vite Tailwind CSS Shadcn/ui Docker Nginx Supabase

Category Technologies
Frontend React 18, TypeScript 5, Vite 5
3D Graphics Three.js, React Three Fiber, React Three Drei
Styling Tailwind CSS, Shadcn/ui, Radix UI
State React Context, TanStack Query
Backend Supabase (PostgreSQL, Auth)
Charts Recharts
Routing React Router v6
Deployment Docker, Nginx, Vercel

๐Ÿ“š Educational Value

Perfect for:

  • ๐ŸŽ“ Students learning quantum cryptography
  • ๐Ÿ‘จโ€๐Ÿซ Educators teaching quantum mechanics
  • ๐Ÿ”ฌ Researchers demonstrating QKD concepts
  • ๐Ÿ’ผ Professionals exploring post-quantum security
  • ๐ŸŒŸ Enthusiasts fascinated by quantum physics

Learning Resources


๐ŸŽฏ Project Structure

bb84_simulation/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ simulation/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PhotonScene.tsx       # 3D visualization
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ PhotonParticle.tsx    # Individual photon
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ KeyResults.tsx        # Results display
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ AnalyticsDashboard.tsx
โ”‚   โ”‚   โ””โ”€โ”€ ui/                       # Reusable UI components
โ”‚   โ”œโ”€โ”€ contexts/
โ”‚   โ”‚   โ””โ”€โ”€ SimulationContext.tsx     # State management
โ”‚   โ”œโ”€โ”€ hooks/
โ”‚   โ”‚   โ””โ”€โ”€ useBB84Simulation.ts      # Core BB84 logic
โ”‚   โ”œโ”€โ”€ pages/
โ”‚   โ”‚   โ”œโ”€โ”€ Home.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Theory.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Simulation.tsx
โ”‚   โ”‚   โ””โ”€โ”€ NotFound.tsx
โ”‚   โ””โ”€โ”€ lib/
โ”‚       โ””โ”€โ”€ utils.ts
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ team.html                     # Team page
โ”‚   โ””โ”€โ”€ images/
โ””โ”€โ”€ ...config files

๐Ÿ‘ฅ Meet the Team

VIT University Engineering Physics Project

๐Ÿ”ง Joshwa - Hardware Engineer
๐Ÿ’ป Prodhosh - Full-Stack Developer
๐Ÿ“„ Raghav - Documentation Lead
๐Ÿ“Š Sachin - Presentation Specialist
๐Ÿ“Š Sudhir - Presentation Specialist
๐Ÿ“„ Vijay Nishal - Documentation Lead

โ†’ View Full Team


๐ŸŒŸ Highlights

๐Ÿ† What Makes This Special

โœ… Industry-Grade Code - Production-ready React/TypeScript
โœ… Real Physics - Accurate quantum mechanics simulation
โœ… 3D Graphics - Smooth 60fps rendering with Three.js
โœ… Interactive Learning - Hands-on quantum education
โœ… Modern Stack - Latest web technologies
โœ… Open Source - Free for educational use
โœ… AI Chatbot - Instant help and explanations
โœ… Responsive Design - Works on all devices


๐Ÿ”ฎ Roadmap

  • VR Support for immersive quantum experience
  • E91 Protocol (entanglement-based QKD)
  • Bloch Sphere visualization
  • Noise Models for realistic channels
  • Performance Metrics comparison
  • Multi-language support
  • Tutorial Mode with guided tours
  • Advanced Analytics with ML predictions

๐Ÿค Contributing

Contributions make the open-source community amazing! Any contributions are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ”— Links

Live Demo GitHub Portfolio


๐Ÿ’ฌ Connect

Prodhosh VS

GitHub LinkedIn Portfolio Instagram


โญ If this project helped you, please give it a star!

Made with โค๏ธ and Quantum Physics

About

Interactive simulator demonstrating the BB84 Quantum Key Distribution protocol using quantum principles of superposition and measurement

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published