Alice sends each photon in a random bit (0/1) encoded in a randomly chosen basis: rectilinear + (0°/90°) or diagonal × (45°/135°). Bob measures every photon in his own randomly chosen basis:
P(correct read | same basis) = 1
P(correct read | wrong basis) = 1/2 (random guess)
Afterwards Alice and Bob publicly compare only their bases (never the bits). Photons where the bases matched form the sifted key — about half of everything sent. With no eavesdropper and a clean channel, sifted bits agree perfectly.
Eve, intercept-resend attack: she measures each photon in a random basis of her own and forwards a freshly prepared photon in that basis. When her basis happens to match Alice's (50% of the time) she reads the bit correctly and Bob sees no error. When it doesn't (the other 50%), her measurement collapses the state and her resent photon is wrong half the time from Bob's point of view:
QBER(Eve intercept-resend) = 1/2 × 1/2 = 25%
That 25% quantum bit error rate — far above what channel noise alone explains — is exactly how Alice and Bob detect eavesdropping and can throw the compromised key away. This is the security guarantee behind the BB84 protocol (Bennett & Brassard, 1984), still the basis of every deployed QKD system.
- Photon rate — how many photons per second Alice sends.
- Channel noise — an independent random bit-flip probability, simulating a lossy fibre even without an eavesdropper.
- Eve toggle — switches the intercept-resend attack on the middle of the channel on/off.
- History strip — drag it sideways to scroll back through every photon this run has sent; click "Live" to jump back to the front.