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.

Key takeaways
  • 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.
The core insight

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 {∣0⟩,∣1⟩}\{|0\rangle, |1\rangle\} and the diagonal basis {∣+⟩,∣−⟩}\{|+\rangle, |-\rangle\}, where

∣+⟩=∣0⟩+∣1⟩2,∣−⟩=∣0⟩−∣1⟩2.|+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}, \qquad |-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}.

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 NN rounds, Alice picks two independent uniformly random bits: ai∈{0,1}a_i \in \{0,1\} (the raw key bit) and bi∈{0,1}b_i \in \{0,1\} (the basis choice, 00 = rectilinear, 11 = diagonal). She prepares the qubit:

  • bi=0,ai=0→∣0⟩b_i = 0, a_i = 0 \to |0\rangle
  • bi=0,ai=1→∣1⟩b_i = 0, a_i = 1 \to |1\rangle
  • bi=1,ai=0→∣+⟩b_i = 1, a_i = 0 \to |+\rangle
  • bi=1,ai=1→∣−⟩b_i = 1, a_i = 1 \to |-\rangle

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 bi′∈{0,1}b_i' \in \{0,1\} and measures. If bi′=bib_i' = b_i (he guessed Alice's basis correctly), his outcome ai′a_i' equals aia_i with certainty in the noiseless case. If bi′≠bib_i' \neq b_i, his outcome is uniformly random and uncorrelated with aia_i.

3. Basis reconciliation / sifting. Over the public classical channel, Alice and Bob announce their basis choices bi,bi′b_i, b_i' (never the bit values). They keep only the rounds where bi=bi′b_i = b_i'; this subset is the sifted key. On average, half the rounds survive sifting, since the two basis choices agree with probability 1/21/2 independently at each round.

4. Error estimation (parameter estimation). Alice and Bob publicly reveal a random subset of the sifted key (say, of size mm) and compare values directly. The fraction of disagreements is the quantum bit error rate (QBER), QQ. In an idealized noiseless channel with no eavesdropper, Q=0Q = 0. Any eavesdropping strategy that extracts information necessarily introduces disturbance, raising QQ above zero. If QQ exceeds a threshold determined by the security proof (roughly 11%11\% 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 QQ 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.

Figure
BB84 pipeline: from random qubits to a short secure key
Alice random bits aᵢ random bases bᵢ qubits |0⟩|1⟩|+⟩|-⟩ quantum channel (Eve here) Bob random bases bᵢ′ measure → aᵢ′ Sifting: publicly compare bᵢ vs bᵢ′ keep only matching-basis rounds (~50% survive) Error estimation: reveal random sample compute QBER Q; abort if Q > threshold Error correction (Cascade / LDPC reconciliation) Privacy amplification universal hashing → short key Final secret key K

Complexity & correctness

Communication and computational complexity. Preparing and sending NN qubits costs O(N)O(N) quantum channel uses. Sifting, error sampling, and basis announcement each cost O(N)O(N) classical bits of communication and O(N)O(N) time for both parties, since every round is processed independently in constant time. Reconciliation protocols such as Cascade run in O(Nlog⁡N)O(N \log N) classical bit exchanges in typical implementations, dominated by iterative parity-check rounds. Privacy amplification via universal hashing takes O(N)O(N) time to evaluate a hash from a suitable family (e.g., Toeplitz-matrix hashing), and the output key length is O(N)O(N) 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 N/2N/2 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, Pr⁡[bi=bi′]=1/2\Pr[b_i = b_i'] = 1/2, so the expected sifted key length is N/2N/2, with fluctuations of order O(N)O(\sqrt{N}) 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 bi=bi′b_i = b_i', 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 ∣0⟩,∣1⟩,∣+⟩,∣−⟩|0\rangle,|1\rangle,|+\rangle,|-\rangle are eigenstates of the corresponding measurement operators). Hence sifted bits agree perfectly: Q=0Q = 0, 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 aia_i before Bob measures it. She does not know bib_i. If she measures in the wrong basis (probability 1/21/2 if she guesses uniformly), the state she forwards to Bob is no longer the original state: for example, if Alice sent ∣0⟩|0\rangle and Eve measures in the diagonal basis, she collapses the qubit to ∣+⟩|+\rangle or ∣−⟩|-\rangle, each with probability 1/21/2, 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 1/21/2 instead of 11, 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 1/21/2), Bob's result flips relative to Alice's with probability 1/21/2. So the induced error rate on sifted bits is

Q=Pr⁡[Eve wrong basis]×Pr⁡[error∣wrong basis]=12×12=14.Q = \Pr[\text{Eve wrong basis}] \times \Pr[\text{error} \mid \text{wrong basis}] = \frac{1}{2}\times\frac{1}{2} = \frac{1}{4}.

A full intercept-resend attack on every qubit is therefore detected with overwhelming probability once mm (the sample size for error estimation) is moderately large, since Q=1/4≫0Q = 1/4 \gg 0 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 QQ, and this bound vanishes as Q→0Q \to 0. This is what justifies aborting above a threshold Q∗Q^*: 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 N=12N = 12 qubits, no noise, and one intercept-resend eavesdropper who measures every qubit in a randomly chosen basis and resends the collapsed state.

iiAlice's bit aia_iAlice's basis bib_iEve's basisEve's outcomeEve resendsBob's basis bi′b_i'Bob's outcome ai′a_i'Basis match?Sifted?
10RR0∣0⟩|0\rangleR0yes✓ (no error)
21RDrand=0∣+⟩|+\rangleRrand (0 or 1)yes✓ (may error)
30DD0∣+⟩|+\rangleRrandnodiscard
41RR1∣1⟩|1\rangleDrandnodiscard
51DRrand=1∣1⟩|1\rangleDrandyes✓ (may error)
60RR0∣0⟩|0\rangleR0yes✓ (no error)
71DD1∣−⟩|-\rangleD1yes✓ (no error)
80DRrand=0∣0⟩|0\rangleDrandyes✓ (may error)
91RDrand=1∣−⟩|-\rangleRrandyes✓ (may error)
100RR0∣0⟩|0\rangleDrandnodiscard
111DRrand=0∣0⟩|0\rangleRrandnodiscard
120DD0∣+⟩|+\rangleD0yes✓ (no error)

(R = rectilinear, D = diagonal; "rand" = a fair-coin outcome forced by measuring in the wrong basis.) Walking through the sifted rounds (1,2,5,6,7,8,9,121,2,5,6,7,8,9,12 — 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 aia_i: each such round has probability 1/21/2 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 22 errors out of 88 sifted bits, an empirical Q=0.25Q = 0.25 — exactly matching the theoretical prediction Q=1/4Q = 1/4 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 11%11\%), they would abort, correctly concluding the channel is compromised. Had Eve not intercepted at all, all 8 sifted bits would agree, Q=0Q = 0 (up to real device noise), and the protocol would proceed to reconciliation and privacy amplification.

Common pitfalls & traps

PitfallWhy it happensConsequence
Reusing sample bits revealed during error estimation as key materialForgetting to discard the publicly announced subsetEve, who overheard the public channel, knows those exact bits — catastrophic key leakage
Assuming the classical channel needs to be secretConfusing "public" with "insecure"Unnecessary complexity; BB84 only requires the classical channel be authenticated, not secret
Ignoring the authentication requirement on the classical channelTreating BB84 as purely a quantum-channel problemEnables a full man-in-the-middle attack independent of quantum security
Treating Q=0Q=0 as proof of no eavesdroppingOverlooking partial-information attacks that induce arbitrarily small disturbance for small information gainA 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 Q=0Q=0
Using weak coherent pulses without decoy statesReal lasers occasionally emit more than one photon per pulseEnables photon-number-splitting attacks, silently breaking the assumed single-photon security model
Skipping privacy amplification when Q>0Q>0Assuming error correction alone sufficesReconciliation 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
CH
Charles H. Bennett
1943–present · IBM Research; co-inventor of BB84 and a founder of quantum information theory

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.

History
1970
Stephen Wiesner circulates unpublished work on "conjugate coding," the conceptual seed of quantum money and BB84.
1984
Bennett and Brassard publish the BB84 protocol, the first full quantum key distribution scheme.
1991
Artur Ekert proposes an entanglement-based QKD protocol (E91), later shown to be closely related to BB84's security.
2000
Full unconditional security proofs of BB84 against arbitrary (coherent) eavesdropping attacks are established.
2017
China's Micius satellite demonstrates BB84-based quantum key distribution over a satellite-to-ground link, extending practical range to over a thousand kilometers.

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.

Before this

Where this leads