BB84 Quantum Key Distribution: Eavesdropper, Noise and Secret-Key Rate

Alice sends single polarised photons in two random bases; Bob measures in random bases. Keep the matching ones, compare a sample, and the error rate reveals an intercept-resend eavesdropper. Photon states and Born-rule measurements are simulated one by one.

Live readouts

Independent numerical checks

The science

Each photon is a qubit with polarisation angle a: rectilinear basis (+) uses 0°/90° for bits 0/1, diagonal (x) uses 45°/135°. Measuring a state at angle a in a basis at angle b gives outcome 0 with probability cos²(a-b) (Born rule) and collapses the photon to that outcome. Same basis: deterministic. Different basis: 50/50.

After the transmission Alice and Bob publicly compare bases and keep only matching ones (sifting, 50% of detected pulses). An intercept-resend eavesdropper who attacks a fraction f of photons picks the wrong basis half the time and then randomises Bob's result half the time, so she adds f/4 errors. With an independent flip probability e (misalignment, detector error) the expected quantum bit error rate is Q = e + f/4 - ef/2.

Asymptotic secret fraction (Shor-Preskill): r = 1 - 2 h2(Q) with binary entropy h2; it reaches zero at Q ≈ 11.0%. Key per pulse = eta * 1/2 * r. Chance to notice an attack at fraction f when k sifted bits are sampled: 1-(1-f/4)^k.

Simplifications: ideal single-photon source (real systems use weak pulses plus decoy states, and photon-number-splitting attacks exist), no dark counts, asymptotic key length (no finite-size penalty), only intercept-resend considered (it is the simplest attack, not the optimal one), authenticated classical channel assumed.