Sifted — correct bit Sifted — error (Eve's disturbance) Discarded (basis mismatch) Lost to fiber attenuation

BB84 Photon-Level Quantum Key Distribution (2D)

This 2D companion to the QKD trusted-node relay 3D model zooms into a single fiber hop and asks a question the relay-chain view abstracts away: what actually happens to each individual photon? Instead of a lumped rate formula, this simulator sends real BB84 photons one at a time — each with a randomly chosen bit and polarization basis — through a fiber channel whose loss follows the same Beer–Lambert attenuation law used industry-wide, computes every measurement Bob (and, optionally, an intercepting Eve) makes using the true quantum-mechanical Malus's-law probability, and derives the sifted key's quantum bit error rate directly from those simulated outcomes rather than assuming it. Turning on Eve shows exactly why intercept-resend eavesdropping is physically detectable: her unavoidable wrong-basis guesses inject real, measurable errors into the sifted key, driving the QBER toward the textbook 25% ceiling and past the ≈11% security threshold where privacy amplification can no longer produce a secure key at all.