BB84

Quantum Key Distribution · Bennett–Brassard 1984

Simulate preparation, measurement and sifting, then compare sampled error rates with and without an intercept-resend Eve; full interception gives about 25% QBER on an ideal noiseless channel.

Classical simulation — no photons or quantum security. SHA-256 key derivation here is not a security proof for privacy amplification.

SIMULATED — This demo models selected BB84 steps classically. No photons or quantum states are produced; no finite-key QKD security proof is computed.

The QBER slider sets a teaching threshold. A security cutoff depends on the device assumptions and finite-key analysis.

Press Run Without Eve or Run With Eve to send photons down the channel.

Line angle = basis + bit: 90° · ⊕ bit 1 0° · ⊕ bit 0 45° · ⊗ bit 0 135° · ⊗ bit 1
ALICE BOB

Click a photon as it lands to read what Alice encoded on it.

Photons sent: 0 Sifted: 0 (0%) Errors: 0 (unobserved) Key bits: 0
Key bit — bases matched Error — noise or Eve Discarded — bases differ Eve intercept ⊕ rectilinear · ⊗ diagonal

Sifting — keep the photon only when the bases match

Showing a sample of photons. Bob picks his basis independently and at random, with no knowledge of Alice's — so bases agree about half the time.

For each sampled photon: Alice's bit, Alice's basis, Bob's basis, and whether the photon is kept or discarded.
#
Alice bit
Alice basis
Bob basis
Sift

Run the protocol to build the per-photon sifting table.

All photons at a glance kept discarded error (sacrificed)

BB84 PROTOCOL

SECURITY ANALYSIS

0% 100%
How a large quantum computer affects common cryptographic schemes compared with BB84.
Security TypeBasisQuantum computer breaks it?
RSA-2048FactoringYES — Shor's algorithm
ECDSA P-256Discrete logYES — Shor's algorithm
AES-256Brute forceREDUCED — Grover (128-bit eff.)
ML-KEM (Kyber)LatticeBELIEVED NO — unproven
BB84 QKDPhysicsNO — information-theoretic*

* Assuming an authenticated classical channel, devices that match the security proof's model, and correct post-processing — practical attacks target the implementation. A message later encrypted with AES-GCM (step 6) is protected computationally, not information-theoretically.

Two distinct theorems do the work here. No-cloning (Wootters & Zurek, 1982; Dieks, 1982): no operation can produce a perfect copy of an arbitrary unknown quantum state. It is a statement about copying being impossible, not about disturbance — it is why Eve cannot duplicate the photon and let the original pass through untouched. Measurement disturbance: measuring in the wrong basis collapses the state and randomizes the outcome. This is what lets Alice and Bob detect Eve. No-cloning removes Eve's copy-and-forward option; measurement disturbance exposes the attack this demo simulates. This panel models the simplest full attack, intercept-resend: measure each photon and send Bob a replacement. But Eve does not know Alice's basis. If she guesses wrong: • She collapses the photon to her basis • She resends in her measured state • Bob, using Alice's correct basis, gets a random result 50% of the time • Full interception produces a ~25% QBER — the expected disturbance for intercept-resend in the ideal four-state model A general Eve has subtler strategies: entangling probes, storing quantum states until the bases are announced, collective measurements across many signals, or attacks on the hardware itself. BB84's security does not rest on intercept-resend being Eve's best move — it rests on a security proof that bounds Eve's information from the observed error rate under an explicit model of the devices. Physics supplies the constraints that proof uses; it does not by itself secure the equipment around the channel.

REAL-WORLD LIMITATIONS

✗ Distance: fiber loss cuts the key rate sharply with distance; practical range depends on protocol and detectors, and long links lean on trusted relays or newer designs (twin-field QKD) ✗ Infrastructure: requires single-photon sources and detectors ✗ Key distribution only: does not provide authentication or signatures ✗ Trusted nodes: long-distance networks require trusted relay points which reintroduce classical vulnerabilities ✗ Side channels: timing, power, or implementation flaws can leak information not protected by quantum mechanics This simulation assumes a perfect implementation — the no-cloning theorem protects the quantum channel, not the hardware around it. QKD and post-quantum cryptography are complementary: PQC for most infrastructure, QKD for highest-value point-to-point links.

DEPLOYED QKD NETWORKS (2026)

China: 2,000km Beijing–Shanghai ground network + Micius satellite Europe: EuroQCI linking EU member states (in deployment) Asia: Metropolitan networks in South Korea, Japan, Singapore

TRY PUBLIC POST-PROCESSING

The main six-step run intentionally skips reconciliation. After an accepted run, try a small-code correction and a separately seeded extractor on the same retained bits. Alice publicly sends three syndrome bits per seven-bit block and a 16-bit verification tag. Bob can repair at most one error per block; a mismatched tag rejects other errors with a residual collision probability of 2−16.

Starts at zero because this simulation cannot infer Eve's conditional knowledge from QBER. Enter a hypothetical bound between zero and the retained length. A zero-bit result is valid; extracted bits are not used as an AES-256 key here.

Run an accepted exchange above to inspect the retained bits.

Teaching model, not a finite-key QKD proof. The budget illustrates the two-universal-hashing result of Renner and König (TCC 2005); see the Quantum Entropy extractor lab.

WHEN ARE BASES ANNOUNCED?

Choose a message order. Eve is assumed to control delivery, store each qubit until Alice's basis announcement when permitted, and forward a replacement before Bob measures. This is an idealized, classical simulation of a particular attack, not a general QKD security claim.

Select an order to compare all four BB84 states under full intercept-resend.

The receipt/measurement ordering is explained in Vidick and Wehner, Introduction to Quantum Cryptography, §8.1.2 (2023).