A Python-based simulation of the BB84 Quantum Key Distribution (QKD) protocol — one of the earliest and most secure quantum cryptography methods.
This project demonstrates qubit encoding, measurement, basis comparison, and shared key generation using Qiskit, along with Bloch sphere visualizations of quantum states.
- Step-by-step BB84 protocol simulation
- Random qubit generation for Alice and Bob
- Basis matching and bit comparison
- Bloch sphere visualization of qubit states
- Final shared secret key generation
- Alice sends qubits to Bob encoded randomly in two bases: Rectilinear (
+) and Diagonal (×). - Bob measures each qubit using a random basis.
- They publicly compare bases (not the bit values).
- Bits where the bases matched form the shared secret key.
1. Clone the repository
git clone https://github.com/your-username/quantum-cipher.git
cd quantum-cipher2. Install dependencies
pip install -r requirements.txt3. Run the simulation
python bb84_simulation.pyBB84 Quantum Key Distribution - Wikipedia
IBM Quantum Cloud Documentation





