The BB84 Protocol
Two parties, Alice and Bob, want to share a secret key over a public channel. An eavesdropper actively monitors this channel. Classical physics offers no way to guarantee the eavesdropper learns nothing. Any classical signal can be copied without disturbing it. BB84, invented in 1984, sidesteps this problem. It encodes key bits into quantum states. These states cannot be measured or copied without leaving a detectable trace. This single idea converts a passive information-theoretic assumption into an active physical guarantee. The protocol matters because it is the first scheme for quantum key distribution (QKD). It is still the most deployed such scheme. Commercial QKD networks in Geneva, Beijing, and Tokyo run variants of BB84 today. So do satellite links such as China's Micius. Banks, government agencies, and telecom operators use it to distribute symmetric keys. These keys serve one-time pads or AES. Its security does not depend on the hardness of factoring or discrete logarithms. It depends only on the laws of quantum mechanics. The big picture is this: BB84 does not transmit the key directly. It transmits random guesses about how to prepare and measure quantum states. Only afterward do Alice and Bob compare enough public information. This lets them extract a shared secret. It also bounds how much an eavesdropper could have learned. The protocol builds directly on The No-Cloning Theorem Revisited. That theorem forbids an eavesdropper from perfectly copying an unknown qubit. It also builds on the general framework of Quantum Key Distribution Principles. This article walks through the full mechanics of BB84. It covers state preparation, basis encoding, sifting, error estimation, and privacy amplification. It includes pseudocode, a worked numerical trace, and an honest discussion. That discussion addresses what security guarantee the protocol actually provides. It closes by foreshadowing how noisy, realistic channels are modeled. This modeling uses Quantum Channels and Operations.
- BB84 encodes each key bit in one of two conjugate bases (rectilinear or diagonal), chosen at random.
- Alice sends qubits; Bob measures in a random basis; only matching bases survive "sifting."
- No-cloning and measurement disturbance mean an eavesdropper's interference is statistically detectable.
- Error rate on a random sample of sifted bits estimates Eve's information and bounds key leakage.
- Error correction plus privacy amplification turns a noisy, partially-known raw key into a short, secure key.
- Security is information-theoretic, not computational — it survives even a quantum computer attacker.
BB84 turns eavesdropping into a measurable disturbance by encoding bits in randomly chosen, mutually incompatible quantum bases.
The idea
BB84 is a quantum key distribution protocol: a procedure by which two parties, conventionally Alice and Bob, establish a shared random secret key whose secrecy is guaranteed by physics rather than by computational hardness assumptions. The core mechanism is conjugate coding: each classical bit is encoded into a qubit using one of two mutually unbiased bases, chosen independently and uniformly at random for every qubit. The two bases used in the original protocol are the rectilinear basis and the diagonal basis , where
These two bases are mutually unbiased: a state prepared in one basis, when measured in the other, yields a uniformly random outcome, giving no information about the original bit. This is the operational content of complementarity for BB84, and it is what makes eavesdropping detectable — an eavesdropper who does not know the preparation basis cannot measure without a significant chance of disturbing the state, by the The No-Cloning Theorem Revisited and the disturbance principle of quantum measurement. The protocol proceeds in two conceptually distinct phases. In the quantum phase, Alice sends a stream of qubits, each randomly encoding a bit in a randomly chosen basis; Bob measures each in a randomly chosen basis of his own. In the classical post-processing phase, Alice and Bob use an authenticated (but not necessarily secret) classical channel to compare basis choices, discard mismatched measurements ("sifting"), estimate the error rate on a sample, and — if the error rate is low enough to prove security — run error correction and privacy amplification to distill a shorter, provably secure final key.
How it works
The protocol has five stages. We walk through each precisely, then give pseudocode covering the entire pipeline.
1. Quantum state preparation and transmission (Alice). For each of rounds, Alice picks two independent uniformly random bits: (the raw key bit) and (the basis choice, = rectilinear, = diagonal). She prepares the qubit:
and sends it to Bob over a quantum channel (fiber, free-space link, or satellite downlink).
2. Measurement (Bob). For each incoming qubit, Bob independently picks a random basis and measures. If (he guessed Alice's basis correctly), his outcome equals with certainty in the noiseless case. If , his outcome is uniformly random and uncorrelated with .
3. Basis reconciliation / sifting. Over the public classical channel, Alice and Bob announce their basis choices (never the bit values). They keep only the rounds where ; this subset is the sifted key. On average, half the rounds survive sifting, since the two basis choices agree with probability independently at each round.
4. Error estimation (parameter estimation). Alice and Bob publicly reveal a random subset of the sifted key (say, of size ) and compare values directly. The fraction of disagreements is the quantum bit error rate (QBER), . In an idealized noiseless channel with no eavesdropper, . Any eavesdropping strategy that extracts information necessarily introduces disturbance, raising above zero. If exceeds a threshold determined by the security proof (roughly for the BB84 protocol under the strongest known attacks, and lower in practical implementations with finite-key effects), Alice and Bob abort — the channel is deemed compromised or too noisy to guarantee security.
5. Error correction and privacy amplification. If is below threshold, Alice and Bob run classical information reconciliation (e.g., a Cascade or LDPC-based protocol) over the authenticated public channel to correct the remaining discrepancies in the unrevealed sifted bits, producing an identical string on both sides. They then apply privacy amplification — hashing the reconciled string down with a randomly chosen universal hash function — to compress out the bits an eavesdropper might partially know, yielding a shorter final key about which Eve's information is exponentially small. ``` BB84_PROTOCOL(N, error_threshold): // ---------- Quantum phase ---------- for i = 1 to N: a[i] = random_bit() // Alice's raw bit b[i] = random_bit() // Alice's basis: 0=rectilinear, 1=diagonal qubit = PREPARE(a[i], b[i]) // encode bit in chosen basis SEND_OVER_QUANTUM_CHANNEL(qubit) b_prime[i] = random_bit() // Bob's basis guess received = RECEIVE_FROM_QUANTUM_CHANNEL() a_prime[i] = MEASURE(received, b_prime[i]) // ---------- Classical post-processing ---------- // Step 1: Sifting sifted_indices = { i : PUBLIC_ANNOUNCE(b[i]) == PUBLIC_ANNOUNCE(b_prime[i]) } sifted_key_A = { a[i] : i in sifted_indices } sifted_key_B = { a_prime[i] : i in sifted_indices } // Step 2: Error estimation on a random public sample sample = RANDOM_SUBSET(sifted_indices, size = m) mismatches = COUNT(a[i] != a_prime[i] for i in sample) Q = mismatches / m remove sample from sifted_key_A, sifted_key_B // never reuse revealed bits if Q > error_threshold: ABORT("channel insecure or too noisy") // Step 3: Error correction (reconciliation) (corrected_A, corrected_B, leaked_bits) = RECONCILE(sifted_key_A, sifted_key_B) // e.g. Cascade protocol assert corrected_A == corrected_B // Step 4: Privacy amplification key_length = ESTIMATE_SECURE_LENGTH(len(corrected_A), Q, leaked_bits) hash_fn = CHOOSE_RANDOM_UNIVERSAL_HASH(key_length) final_key = hash_fn(corrected_A) return final_key ``` The figure below shows the pipeline end to end, including where information is discarded at each stage.
Complexity & correctness
Communication and computational complexity. Preparing and sending qubits costs quantum channel uses. Sifting, error sampling, and basis announcement each cost classical bits of communication and time for both parties, since every round is processed independently in constant time. Reconciliation protocols such as Cascade run in classical bit exchanges in typical implementations, dominated by iterative parity-check rounds. Privacy amplification via universal hashing takes time to evaluate a hash from a suitable family (e.g., Toeplitz-matrix hashing), and the output key length is but strictly smaller than the sifted key length. Overall the protocol is linear in the number of transmitted qubits, which is efficient — the overhead relative to naively wanting perfectly secret bits is a constant factor plus the cost of error correction and amplification, both of which scale linearly with mild logarithmic reconciliation overhead.
Sifting yield. Since Alice's and Bob's basis choices are independent fair coins, , so the expected sifted key length is , with fluctuations of order by the law of large numbers (a Chernoff bound gives exponentially small deviation probability for any fixed relative error).
Correctness in the absence of noise or eavesdropping. When , Bob measures in the same basis Alice used to prepare the state, and quantum measurement in the preparation basis returns the encoded bit with probability 1 (the states are eigenstates of the corresponding measurement operators). Hence sifted bits agree perfectly: , and the sifted key is already a valid shared secret, modulo confirming no eavesdropping occurred.
Security intuition — why eavesdropping is detectable. Suppose Eve intercepts a qubit and tries to learn before Bob measures it. She does not know . If she measures in the wrong basis (probability if she guesses uniformly), the state she forwards to Bob is no longer the original state: for example, if Alice sent and Eve measures in the diagonal basis, she collapses the qubit to or , each with probability , destroying the original information. When Bob later measures this disturbed state in the correct basis (rectilinear, matching Alice's), he now gets the correct bit with probability only instead of , because the state Eve forwarded is unbiased with respect to the rectilinear basis. Formally, for the simplest intercept-resend attack where Eve measures every qubit in a randomly chosen basis and resends the post-measurement state, a short calculation shows that conditioned on Eve guessing the wrong basis (probability ), Bob's result flips relative to Alice's with probability . So the induced error rate on sifted bits is
A full intercept-resend attack on every qubit is therefore detected with overwhelming probability once (the sample size for error estimation) is moderately large, since is far from the noise floor of a well-engineered channel (typically a few percent). This is the operational manifestation of the The No-Cloning Theorem Revisited: Eve cannot copy the unknown qubit and measure the copy, and any measurement she performs on the original necessarily perturbs it in a way Bob can statistically detect. More refined attacks (partial measurements, entangling probes) trade off information gain against disturbance, but rigorous security proofs — via the connection between BB84 and entanglement-based protocols, and via smooth min-entropy / de Finetti arguments — show that for any attack, Eve's total information about the final key is bounded by a function of , and this bound vanishes as . This is what justifies aborting above a threshold : below it, privacy amplification can be tuned to erase Eve's residual information.
Honest caveats. BB84's unconditional security proof assumes: an authenticated classical channel (an active man-in-the-middle on the classical channel breaks the protocol via impersonation, unrelated to quantum effects); ideal single-photon sources (real weak-coherent-pulse sources are vulnerable to photon-number-splitting attacks unless decoy states are used); and detectors free of side channels (real detectors have been broken via blinding attacks that exploit detector nonlinearity — a hardware, not protocol, vulnerability). The protocol guarantees information-theoretic security of the ideal mathematical description; deployed systems require substantial engineering to close these side channels.
Worked example
We trace a small run with qubits, no noise, and one intercept-resend eavesdropper who measures every qubit in a randomly chosen basis and resends the collapsed state.
| Alice's bit | Alice's basis | Eve's basis | Eve's outcome | Eve resends | Bob's basis | Bob's outcome | Basis match? | Sifted? | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | R | R | 0 | R | 0 | yes | ✓ (no error) | |
| 2 | 1 | R | D | rand=0 | R | rand (0 or 1) | yes | ✓ (may error) | |
| 3 | 0 | D | D | 0 | R | rand | no | discard | |
| 4 | 1 | R | R | 1 | D | rand | no | discard | |
| 5 | 1 | D | R | rand=1 | D | rand | yes | ✓ (may error) | |
| 6 | 0 | R | R | 0 | R | 0 | yes | ✓ (no error) | |
| 7 | 1 | D | D | 1 | D | 1 | yes | ✓ (no error) | |
| 8 | 0 | D | R | rand=0 | D | rand | yes | ✓ (may error) | |
| 9 | 1 | R | D | rand=1 | R | rand | yes | ✓ (may error) | |
| 10 | 0 | R | R | 0 | D | rand | no | discard | |
| 11 | 1 | D | R | rand=0 | R | rand | no | discard | |
| 12 | 0 | D | D | 0 | D | 0 | yes | ✓ (no error) |
(R = rectilinear, D = diagonal; "rand" = a fair-coin outcome forced by measuring in the wrong basis.) Walking through the sifted rounds ( — 8 of 12 rounds, close to the expected half):
- Rounds where Eve happened to guess the same basis as Alice (1, 6, 7, 12): the state reaching Bob is undisturbed, so whenever Bob's basis also matches, he recovers Alice's bit with certainty. No error.
- Rounds where Eve guessed the wrong basis (2, 5, 8, 9): Eve's measurement collapsed the qubit into a state unbiased with respect to Alice's original basis. Even though Bob's basis matches Alice's, Bob's outcome is now a fair coin flip independent of : each such round has probability of disagreeing with Alice.
Suppose in this run rounds 2 and 9 happen to come out matching by chance and round 5 and 8 come out mismatched. That gives errors out of sifted bits, an empirical — exactly matching the theoretical prediction for full intercept-resend, derived in the previous section. Alice and Bob's public sample would reveal this elevated error rate; comparing against a threshold (say ), they would abort, correctly concluding the channel is compromised. Had Eve not intercepted at all, all 8 sifted bits would agree, (up to real device noise), and the protocol would proceed to reconciliation and privacy amplification.
Common pitfalls & traps
| Pitfall | Why it happens | Consequence |
|---|---|---|
| Reusing sample bits revealed during error estimation as key material | Forgetting to discard the publicly announced subset | Eve, who overheard the public channel, knows those exact bits — catastrophic key leakage |
| Assuming the classical channel needs to be secret | Confusing "public" with "insecure" | Unnecessary complexity; BB84 only requires the classical channel be authenticated, not secret |
| Ignoring the authentication requirement on the classical channel | Treating BB84 as purely a quantum-channel problem | Enables a full man-in-the-middle attack independent of quantum security |
| Treating as proof of no eavesdropping | Overlooking partial-information attacks that induce arbitrarily small disturbance for small information gain | A sufficiently cautious Eve can extract a little information while staying under naive detection, which is exactly why formal security proofs bound leaked information as a function of Q, not just test |
| Using weak coherent pulses without decoy states | Real lasers occasionally emit more than one photon per pulse | Enables photon-number-splitting attacks, silently breaking the assumed single-photon security model |
| Skipping privacy amplification when | Assuming error correction alone suffices | Reconciliation reveals extra bits over the public channel that Eve can exploit; without amplification the final string is not private even if error-free |
Pioneers & history
Origins · 1 minCharles H. Bennett and how this was discovered
Bennett, alongside Gilles Brassard, proposed BB84 in 1984 as the first concrete protocol showing that quantum mechanics could provide provable cryptographic key distribution. He later co-invented quantum teleportation and helped formalize entanglement measures, becoming one of the central architects of the modern field of quantum information.
Where this matters
Commercial QKD systems from vendors such as ID Quantique and Toshiba deploy BB84 or its decoy-state variants to secure point-to-point fiber links between data centers, banks, and government facilities, typically feeding keys into classical symmetric encryption (AES) rather than serving as a one-time pad due to key-rate limits. National and metropolitan QKD networks — including deployments in Switzerland, China (the Beijing–Shanghai backbone), and South Korea — chain trusted relay nodes running BB84 to extend secure key distribution beyond direct line-of-sight fiber distances. Satellite-based QKD, demonstrated by the Micius mission, uses a BB84-family protocol to distribute keys between ground stations thousands of kilometers apart, motivated by fiber-loss limits that make purely terrestrial long-distance QKD impractical. Standards bodies (ETSI, ITU-T) have begun specifying QKD network interfaces explicitly built around BB84's sifting-and-amplification structure. In the broader research landscape, BB84 is the canonical example used to teach the operational meaning of the No-Cloning Theorem Revisited and serves as the entry point for the more general noisy-channel security analysis developed under Quantum Channels and Operations, where real detector loss, dark counts, and depolarizing noise are modeled explicitly to derive practical, finite-key security bounds.
Ask the tutor: How does the security proof formally bound Eve's information as a function of the observed error rate Q?
Does BB84 transmit the secret key itself through the quantum channel?
No. The quantum channel carries randomly chosen bit-and-basis pairs, not the final key. Only after sifting, error estimation, reconciliation, and privacy amplification does a shared secret emerge. Roughly half the transmitted qubits are discarded during sifting because Bob guessed the wrong basis, and more bits are consumed during error estimation and privacy amplification. The net effect is that BB84 produces a shorter, distilled key from a much larger stream of quantum transmissions, trading raw qubit count for a guarantee that the final string is (with overwhelming probability) unknown to any eavesdropper.
Why doesn't BB84 need the classical channel to be secret, only authenticated?
The classical post-processing steps — announcing bases, revealing error-estimation samples, running reconciliation — are all designed so that an eavesdropper who reads every message gains no more than what is already accounted for in the security proof. Privacy amplification specifically compensates for information Eve could glean from listening to reconciliation traffic. What breaks the protocol is tampering: if Eve can inject or alter classical messages undetected, she can impersonate Alice or Bob (a man-in-the-middle attack unrelated to quantum mechanics). Authentication, often achieved with a short pre-shared classical key and information-theoretically secure MACs, closes this gap.
What happens if the measured error rate Q is nonzero but below the abort threshold?
A nonzero Q is expected even without an eavesdropper, since real channels and detectors have intrinsic noise (dark counts, misalignment, decoherence). The protocol does not require Q=0; it requires Q to stay below a threshold for which the security proof guarantees that privacy amplification can still erase Eve's maximum possible information. Above threshold, the proof no longer bounds Eve's knowledge tightly enough to guarantee a secure key exists, so aborting is the only safe choice. Below threshold, error correction fixes the discrepancies and privacy amplification shrinks the key by an amount tied to Q.
How does no-cloning make eavesdropping detectable rather than just impossible?
No-cloning forbids Eve from producing a perfect copy of an unknown qubit to measure at her leisure while forwarding the original untouched. Instead, she must interact with the actual qubit Bob will receive, and any measurement that extracts information about a state prepared in an unknown basis generally disturbs that state. This disturbance surfaces statistically as an elevated error rate between Alice's and Bob's sifted bits. The protocol does not detect a specific eavesdropping event; it bounds, from the observed disturbance, an upper limit on how much information any eavesdropper — using any strategy consistent with quantum mechanics — could have obtained.
Is BB84 secure against a quantum computer, unlike RSA or Diffie-Hellman?
Yes, in the sense that its security does not rest on any computational hardness assumption at all; it is information-theoretic. RSA and Diffie-Hellman rely on factoring or discrete-log being hard, both of which Shor's algorithm breaks efficiently on a quantum computer. BB84's security instead follows from the structural fact that quantum states in unknown, mutually unbiased bases cannot be measured without disturbance — a law of physics, not an algorithmic limitation. This is precisely why QKD is promoted as "quantum-safe": it remains secure even if an adversary possesses an arbitrarily powerful quantum computer, provided the physical assumptions (authenticated channel, correctly characterized devices) hold.
What are the main practical vulnerabilities that don't show up in the idealized BB84 security proof?
Real implementations depart from the idealized single-photon model in ways attackers exploit. Weak coherent-pulse sources sometimes emit two or more photons, enabling photon-number-splitting attacks, mitigated with decoy-state protocols. Detectors can be blinded or have timing side channels that let an attacker control measurement outcomes without triggering expected error rates, addressed by measurement-device-independent QKD variants. Classical authentication infrastructure, random number generation quality, and side-channel leakage from modulators are further engineering concerns. The mathematical proof of BB84's security is sound for its stated assumptions; the security of a deployed system depends on how faithfully hardware meets those assumptions.
How does BB84 relate to entanglement-based QKD protocols like E91?
E91, proposed by Artur Ekert, distributes entangled photon pairs to Alice and Bob, who measure in randomly chosen bases and use violation of Bell inequalities to certify security. It can be shown that BB84 is equivalent, under a purification argument, to a version of E91 where Alice measures her half of an entangled pair rather than directly preparing a state. This equivalence underlies modern security proofs of BB84, which often analyze an entanglement-based version and then argue the prepare-and-measure version inherits the same guarantees, connecting BB84 to the broader theory of Quantum Key Distribution Principles.