QcryptLab
๐โ๏ธ Interactive web platform for learning quantum cryptography and quantum computing fundamentals with real-time BB84 protocol simulations, Bloch sphere visualizations, and hands-on quantum circuit building
Install / Use
/learn @LalithKanna/QcryptLabREADME
Quantum Cryptography Tutorial Website
A comprehensive educational platform for learning quantum computing fundamentals and quantum key distribution protocols using interactive visualizations.
๐ฏ Project Overview
This project provides an interactive web-based tutorial for quantum cryptography, featuring:
- Quantum Computing Basics - Interactive tutorials with Bloch sphere visualizations
- BB84 Protocol Simulation - Step-by-step quantum key distribution implementation
- Real-time Quantum Simulations - Using Qiskit and QuTiP for backend computations
- Educational Interface - Drag-and-drop circuit builder and interactive demonstrations
๐ ๏ธ Technology Stack
Frontend
- HTML5/CSS3/Vanilla JavaScript - Pure web technologies for maximum compatibility
- Interactive Visualizations - Canvas-based quantum state representations
- Responsive Design - Mobile-friendly educational interface
Backend
- Python Flask - Lightweight web framework
- Qiskit - IBM's quantum computing framework for circuit simulation
- QuTiP - Quantum Toolbox in Python for advanced simulations
- Matplotlib - Server-side visualization generation with base64 encoding
Key Features
- CORS-enabled API - Seamless frontend-backend communication
- Real-time Bloch Sphere Generation - Dynamic quantum state visualization
- Complete BB84 Implementation - Alice, Bob, and Eve simulation
- Educational Error Handling - User-friendly quantum computing education
๐ Project Structure
quantum-crypto-tutorial/
โโโ README.md # Project documentation
โโโ requirements.txt # Python dependencies
โโโ run.py # Application entry point
โโโ frontend/ # Client-side application
โ โโโ index.html # Main landing page
โ โโโ quantum-basics/ # Quantum computing tutorials
โ โ โโโ quantum-intro.html # Introduction to quantum computing
โ โ โโโ qubits-tutorial.html # Qubits and superposition
โ โ โโโ quantum-gates.html # Quantum gate operations
โ โ โโโ quantum-circuits.html # Interactive circuit builder
โ โโโ bb84-protocol/ # Quantum key distribution
โ โ โโโ bb84-tutorial.html # BB84 protocol theory
โ โ โโโ bb84-simulator.html # Interactive BB84 simulation
โ โโโ css/ # Stylesheets
โ โ โโโ styles.css # Global styles and layout
โ โ โโโ quantum-visualizations.css # Quantum-specific styling
โ โ โโโ bb84-interface.css # BB84 protocol interface
โ โโโ js/ # JavaScript modules
โ โ โโโ main.js # Core application logic
โ โ โโโ quantum-visualizer.js # Circuit builder and visualizations
โ โ โโโ bloch-sphere.js # Bloch sphere rendering
โ โ โโโ bb84-simulator.js # BB84 protocol interface
โ โโโ assets/ # Static assets
โ โโโ images/ # Educational images and icons
โโโ backend/ # Server-side application
โ โโโ app.py # Main Flask application
โ โโโ quantum_simulator/ # Quantum simulation modules
โ โ โโโ __init__.py
โ โ โโโ enhanced_quantum_circuit_simulator.py # Qiskit-based circuit simulation
โ โ โโโ state_visualizer.py # Statevector calculations
โ โ โโโ advanced_simulator.py # QuTiP integration
โ โ โโโ bloch_sphere_visualizer.py # Bloch sphere visualization
โ โโโ cryptography/ # Quantum cryptography implementations
โ โ โโโ __init__.py
โ โ โโโ bb84_protocol.py # Complete BB84 implementation
โ โ โโโ quantum_channel.py # Quantum channel simulation
โ โ โโโ security_analysis.py # Eavesdropping detection
โ โโโ utils/ # Utility modules
โ โโโ __init__.py
โ โโโ image_generator.py # Base64 image encoding
โ โโโ data_validators.py # Input validation
๐ Installation and Setup
Prerequisites
- Python 3.8 or higher
- Modern web browser with JavaScript enabled
- Internet connection for initial setup
Step 1: Clone the Repository
git clone <repository-url>
cd quantum-crypto-tutorial
Step 2: Install Python Dependencies
pip install -r requirements.txt
Step 3: Start the Backend Server
python run.py
The Flask server will start on http://localhost:5000
Step 4: Serve the Frontend
You have several options:
Option A: Python HTTP Server
cd frontend
python -m http.server 3000
Access the application at http://localhost:3000
Option B: Direct File Access
Open frontend/index.html directly in your web browser
Option C: Live Server (if using VS Code) Use the Live Server extension to serve the frontend directory
๐ Learning Modules
1. Quantum Computing Fundamentals
- Introduction to Quantum Computing - Basic concepts and principles
- Qubits and Superposition - Understanding quantum states with Bloch sphere
- Quantum Gates and Operations - Interactive gate manipulation
- Interactive Circuit Builder - Drag-and-drop quantum circuit construction
2. Quantum Cryptography
- BB84 Protocol Theory - Understanding quantum key distribution
- Interactive BB84 Simulation - Step-by-step protocol implementation
๐ง API Endpoints
Quantum Computing Endpoints
GET /api/quantum-basics/<lesson>- Retrieve tutorial contentPOST /api/simulate-circuit- Execute quantum circuit simulationPOST /api/visualize-bloch- Generate Bloch sphere visualizationPOST /api/advanced-simulation- Complex quantum dynamics with QuTiP
BB84 Protocol Endpoints
POST /api/bb84/simulate- Complete BB84 protocol executionGET /api/bb84/tutorial- BB84 educational contentPOST /api/bb84/step-simulation- Individual protocol step simulation
Utility Endpoints
GET /api/health- Service health checkGET /api/quantum-states- Common quantum state information
๐ก Key Features
Interactive Quantum Circuit Builder
- Drag-and-drop interface for quantum gates (H, X, Y, Z, CNOT)
- Real-time statevector calculation and visualization
- Circuit diagram generation with Qiskit
- Educational error messages and validation
Bloch Sphere Visualizations
- Dynamic 3D Bloch sphere rendering using Matplotlib
- Interactive parameter adjustment (ฮธ, ฯ angles)
- Real-time quantum state probability calculations
- Base64 encoded images for web display
Complete BB84 Implementation
- Alice's random bit and basis generation
- Quantum state preparation and encoding
- Quantum channel simulation with noise
- Bob's random measurement basis selection
- Key sifting and eavesdropping detection
- Security analysis with QBER calculation
๐งช Educational Features
Progressive Learning Path
- Start with classical vs quantum computing concepts
- Learn about qubits and superposition
- Explore quantum gates and their effects
- Build quantum circuits interactively
- Understand quantum cryptography principles
- Simulate the BB84 protocol step-by-step
Interactive Demonstrations
- Classical vs quantum search algorithm comparison
- Qubit measurement simulation with probability visualization
- Custom quantum state creation and analysis
- Real-time protocol security analysis
๐ Security Considerations
- Input validation for all quantum parameters
- Rate limiting on simulation endpoints
- Resource constraints for circuit size (max 10 qubits)
- Educational-focused error messages
- No persistent data storage (stateless design)
๐จ Customization Guide
Adding New Quantum Gates
- Define gate function in
circuit_simulator.py - Add gate to
supported_gatesdictionary - Update frontend gate palette in
quantum-visualizer.js - Add corresponding CSS styling
Extending BB84 Protocol
- Implement new protocol variations in
bb84_protocol.py - Add corresponding API endpoints in
app.py - Create frontend interface components
- Update educational content
Adding New Visualizations
- Create visualization functions in
state_visualizer.py - Add API endpoints for new visualizations
- Implement frontend rendering logic
- Update educational tutorials
๐ Troubleshooting
Common Issues
Backend fails to start:
- Verify Python version (3.8+)
- Check all dependencies are installed:
pip install -r requirements.txt - Ensure port 5000 is not in use
Frontend cannot connect to backend:
- Verify CORS settings in
app.py - Check that backend is running on
http://localhost:5000 - Confirm frontend is making requests to correct URL
Quantum simulations fail:
- Check circuit parameters are within limits (max 10 qubits)
- Verify gate specifications are properly formatted
- Review server logs for detailed error messages
Visualizations not displaying:
- Ensure matplotlib is properly installed with Agg backend
- Check browser developer console for JavaScript errors
- Verify base64 image encoding is working correctly
๐ฎ Future Development
Planned Features
- Additional quantum algorithms (Shor's, Grover's)
- More quantum cryptography protocols (E91, SARG04)
- Advanced error correction demonstrations
- Quantum machine learning tutorials
- Multi-language support
Technical Improvements
- WebAssembly integration for client-side simulations
- Real quantum hardware integration (IBM Quantum, IonQ)
- Progressive Web App (PWA) capabilities
- Advanced 3D visualizations with WebGL
๐ Educational Resources
Prerequisites
- Basic linear algebra (vectors, matrices)
- Elementary probability theory
- High school level mathematics
- No prior quantum physics knowledge required
Learning Outcomes
After completing this tutorial, students will:
- Understand fundamental
Related Skills
proje
Interactive vocabulary learning platform with smart flashcards and spaced repetition for effective language acquisition.
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star โญ๏ธ this repository and use the link in the readme to join our open source AI research team.
groundhog
400Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
workshop-rules
Materials used to teach the summer camp <Data Science for Kids>
