Blue = rectilinear basis (+), orange = diagonal (x). The bar shows the polarisation.

BB84 Key Exchange: Photon Ledger and Basis Matrix (2D)

Alice and Bob agree a secret key with single photons; an eavesdropper cannot hide.
Photons sent-
Sifted bits (bases agree)-
Errors in sifted key-
Measured QBER-
Predicted QBER p + f/4 - fp/2-
Secret fraction 1 - 2h(Q)-
Secret key bits (asymptotic)-
Verdict-
Measured error rate of the sifted key (orange) vs prediction (white) and the 11% abort threshold (red)
Predicted secret fraction vs eavesdropped fraction f at the current channel error p
The science
Honest scope: this is the real BB84 protocol (Bennett and Brassard, 1984) on idealised single photons. It is secure key agreement over an ordinary channel, not faster-than-light or "interdimensional" communication: quantum mechanics forbids signalling that way, and Alice and Bob still need a normal classical channel to compare bases. Nothing in this sim reaches another dimension.

Protocol. Alice sends each photon with a random bit in a random basis: rectilinear (0 / 90 deg) or diagonal (45 / 135 deg). Bob measures in a random basis. If his basis equals Alice's he gets her bit; otherwise his result is random (50 %). They publicly compare bases only, keep the matching half (the sifted key) and discard the rest.

Reading the 2D view. Each ledger column is one photon (an independent slow sample drawn with the same probabilities as the counted stream): Alice's bit and basis, Eve's basis if she intercepted (red outline when she guessed wrong), a channel flip marker, Bob's basis and result, and the verdict (kept and correct, kept and wrong, discarded). The 2x2 matrix counts every photon by Alice's and Bob's basis: the diagonal is the sifted key, and its error rate is the QBER; the off-diagonal cells are pure coin flips (about 50 % wrong) and are thrown away.

Why eavesdropping shows. An intercept-resend spy Eve must guess a basis; the no-cloning theorem prevents copying. When she guesses wrong (50 %) she resends in the wrong basis and Bob, if he uses Alice's basis, errs half of the time. So Eve adds f/4 to the error rate (25 % if she listens to everything). With channel error p the exact result is

Q = p + f/4 - f p / 2

Key rate. With ideal single photons and an asymptotically long key, the Shor-Preskill bound gives the secret fraction r = 1 - 2 h(Q), h(Q) = -Q log2 Q - (1-Q) log2 (1-Q). It reaches zero at Q ~ 11 %, so above this the parties must abort.

Simplifications: perfect single-photon sources and detectors (real systems use weak laser pulses plus decoy states), only the intercept-resend attack, no photon loss or dark counts, all sifted bits used for the error estimate (real systems sample a subset), and the asymptotic rather than a finite-key bound. The 2D ledger shows a slowed-down sample of the stream; the counters use every photon.

Independent numerical checks
Made with 🟠 Blender