Experiment setup

BB84 Protocol Simulator

Configure the quantum channel, then run a full key exchange on Qiskit Aer.

Guest mode · runs in memory

Quick presets

Loads parameters below

Parameters

Photons Alice prepares and sends. Roughly half survive sifting.

102505007501000

Channel decoherence via Qiskit Aer depolarizing_error(ε).

0.000.100.200.300.400.50
You're in guest mode — everything works, nothing is stored. Create a free account to keep a history of your experiments.

  1. Encoding. Alice maps random bits to $\{|0\rangle, |1\rangle\}$ (rectilinear) or $\{|+\rangle, |-\rangle\}$ (diagonal), chosen at random per photon.
  2. Channel noise. Qiskit's depolarizing channel $\mathcal{E}_\varepsilon(\rho) = (1-\varepsilon)\,\rho + \varepsilon\,\tfrac{I}{2}$ flips the measured bit with probability $\varepsilon/2$, so $\mathbb{E}[\text{QBER}] = \varepsilon/2$.
  3. Eavesdropping. Eve guesses the wrong basis half the time; each wrong guess randomizes Bob's result, giving $\mathbb{E}[\text{QBER}] = 25\%$ on an ideal channel.
  4. Sifting. Bases are compared publicly and mismatched positions are discarded — about half the qubits survive.
  5. Parameter estimation. A random sample of $\min(\lfloor n_s/4 \rfloor, 20)$ sifted bits is revealed to estimate the QBER, then discarded.
  6. Key rate. Under one-way post-processing (Shor–Preskill / Devetak–Winter) the secret fraction is $R = \max(0,\,1 - 2h(\text{QBER}))$, which vanishes at $\text{QBER} \approx 11\%$.

Theoretical forecast

N=64
Expected QBER
0.0%
Key rate R
1.000
Sifted bits (≈ N/2)32
QBER sample size8
Expected final key24 bits
Secure key expected

Forecast is the asymptotic expectation. Real runs estimate QBER on a finite sample, so small N can land on either side of the threshold.