BB84 Quantum Cryptography Simulation

Experience quantum key distribution interactively.

About This Simulation

This interactive webpage simulates the BB84 quantum key distribution protocol, a fundamental method for secure communication. The protocol enables two parties, Alice and Bob, to establish a shared secret key over a quantum channel while detecting any potential eavesdropping attempts by a third party (Eve). If Eve tries to intercept and measure quantum states, errors are introduced, revealing her presence.

Use the controls below to set the number of qubits and toggle eavesdropping to see how it affects key security. Various visualizations will help you understand the process and results.

Simulation Settings

Quantum State Visualization

⚛️ What it shows: This section provides a visual representation of the quantum states used in the BB84 protocol. Each qubit is transmitted using a random basis (rectilinear or diagonal), and measurements are performed accordingly. If an eavesdropper intercepts the qubits, disturbances may appear in the visualization, helping Alice and Bob detect interference.

Key Distribution Analysis

📊 What it shows: This chart compares the bits of the secret key generated by Alice and the key received by Bob. Only qubits measured in the same basis contribute to the final key. A high match rate means successful key distribution.

Eavesdropping Impact

📈 What it shows: This line chart tracks the bits that Eve (the eavesdropper) attempts to intercept. More interception increases the chance of detection due to measurement-induced errors.

Key Matching Histogram

📊 What it shows: This histogram represents the percentage of key bits that successfully matched between Alice and Bob. If eavesdropping is active, the match percentage is likely lower.

Eavesdropping Success Rate

🥧 What it shows: This pie chart displays the proportion of bits intercepted by Eve versus those that remained unchanged. If a large portion was intercepted, Alice and Bob may need to discard the key and restart.