The 3D relay model treats a fiber hop as one lumped rate R(L) = R₀·T(L). This 2D companion drops that abstraction and simulates the actual BB84 quantum protocol photon by photon: Alice encodes a random bit in a random polarization basis (rectilinear 0°/90° or diagonal 45°/135°), the photon is lost stochastically per the same fiber attenuation law, an optional intercept-resend eavesdropper (Eve) measures and re-sends in her own random basis, and Bob measures in his own random basis using the real quantum-mechanical (Malus's law / Born rule) probability of each outcome:
Attenuation: T(L) = 10^(−α·L / 10), α ≈ 0.2 dB/km
Measurement: P(bit = 0 | incoming angle θ, basis φ) = cos²(θ − φ)
Sifting: keep only bits where Bob's basis matches Alice's basis
QBER: fraction of sifted bits where Bob ≠ Alice
Secure rate: R = f₀·T(L)·½·max(0, 1 − 2·H₂(QBER)), H₂ = binary entropy
No-cloning forbids Eve from copying the photon, so she must measure it — and measuring in the wrong basis (which she cannot avoid, since she does not know Alice's basis choice) collapses it to a different state before she resends it. When Bob later happens to use Alice's original basis (the case sifting keeps), that disturbance shows up as a wrong bit exactly half the time Eve guessed the basis wrong — which is half the time. The result, reproduced by this simulator's own random photon statistics rather than assumed: QBER ≈ 0.25 × (Eve's intercept probability). Security is lost once QBER passes the Shor–Preskill BB84 threshold of ≈11.00%, where the secure-rate formula's privacy-amplification term 1 − 2·H₂(QBER) hits zero — an eavesdropper intercepting every photon produces QBER ≈ 25%, so BB84 always exposes a full-intercept attack.
- Fiber length sets the photon survival probability T(L) via the same Beer–Lambert attenuation law as ordinary telecom light — this is exactly why a single QKD hop is capped near 100–200 km before the raw photon rate collapses, the real reason trusted-node relays (see the 3D model) or quantum repeaters exist.
- Eve intercept probability is applied independently to each photon, so it doubles as a model of partial line-tapping, not just an all-or-nothing attack.
- Discarded (non-sifted, mismatched-basis) photons are shown faint and grey — real BB84 throws away roughly half of every transmission before privacy amplification even begins.