BB84 Protocol
BB84, introduced by Bennett and Brassard in 1984, is the canonical prepare-and-measure protocol for quantum key distribution. It turns random choices of basis and bit into a shared secret key by exploiting a simple quantum fact: nonorthogonal states cannot be perfectly distinguished without risk of disturbance. In the quantum communication section of SJ Wiki, BB84 is the local reference point for QKD, trusted-device security models, and the way physical quantum signals are converted into classical cryptographic key material.
This page is now combined with the treatment in Nielsen and Chuang, especially Chapter 12 of Quantum Computation and Quantum Information. That textbook gives the clean conceptual route from BB84 to security: first prove security for an entanglement-based protocol, use random sampling to bound errors, use CSS codes to handle bit and phase errors, then reduce the protocol until only BB84 state preparation and single-qubit measurement remain. The older engineering discussion is preserved where it clarifies practical QKD, but the notation and security framing here follow Nielsen and Chuang.
Definitions
The two BB84 bases are the basis and the basis:
The diagonal states are
Nielsen and Chuang write Alice's random basis string as . One common convention is for the basis and for the basis. Alice also has random data bits . She sends , meaning
| Basis | |||
|---|---|---|---|
| 0 | |||
| 1 |
Raw data are the measurement outcomes before public basis comparison. Bob has his own random basis string and measurement outcomes .
Sifted key is the subsequence kept after Alice announces and Alice and Bob discard all positions where . In an ideal noiseless channel, the kept positions satisfy .
Check bits are a random subset of the sifted positions revealed publicly to estimate the error rate. Revealed check bits are discarded.
QBER is the quantum bit error rate on compared sifted bits:
Information reconciliation is public classical error correction. In Nielsen and Chuang's CSS-code proof, a classical code corrects the bit errors: Alice announces enough information, such as , for Bob to correct his noisy string to the same codeword .
Privacy amplification compresses the reconciled string so that Eve's remaining information about the final key is negligible. In the same proof, a subcode implements this compression: Alice and Bob compute the coset in and use the coset label as the key.
Holevo information for an ensemble is
where is von Neumann entropy. Holevo's theorem says that for any measurement producing classical outcome from Alice's classical variable ,
For BB84, this theorem is not the entire proof, but it supplies the information-theoretic language for bounding Eve's accessible information after Alice and Bob have certified that their state is close to ideal.
Key results
The basic BB84 protocol can be written in the notation of Nielsen and Chuang as follows.
- Alice chooses random data bits and a random basis string .
- She sends each bit as a -basis or -basis qubit according to .
- Bob receives the qubits, announces reception, and measures each qubit in a random or basis.
- Alice announces .
- Alice and Bob discard positions where Bob used the wrong basis.
- They keep a fixed-size sifted block if enough positions remain; otherwise they abort.
- Alice randomly chooses check positions and announces them.
- Alice and Bob compare the check bits. If more than the allowed threshold disagree, they abort.
- On the remaining bits, they run information reconciliation and privacy amplification to obtain the final key.
The sifting rate is about with uniform basis choices because
The wrong-basis measurement is unbiased. If Alice sends and Bob measures in the basis, then
This is the local calculation behind eavesdropping detection. In an intercept-resend attack, Eve guesses Alice's basis correctly half the time. In the other half, she resends a state in the wrong basis. Conditioned on Alice and Bob later keeping the round, Bob then disagrees with Alice with probability . The expected QBER on sifted positions is therefore
Nielsen and Chuang's security proof is stronger than this intercept-resend calculation. The proof starts from an EPR-based protocol where Alice and Bob would like to share states close to
If their actual joint state has fidelity close to this ideal Bell-pair state, then Eve's information about the outcomes of -basis measurements is small. The information bound is expressed using Holevo's theorem: Eve may hold the purification of the noisy process, but once the Alice-Bob state is certified close to ideal, the entropy available to Eve is small, and hence her accessible classical information is small.
The next step is random sampling. Alice and Bob sacrifice randomly selected check bits. If the check error count is at most , then, with high probability for large blocks, the untested bits have no more than the tolerated number of errors. In the EPR proof, the same idea bounds bit-flip and phase-flip errors in the Bell basis.
CSS codes provide the bridge to ordinary BB84. Let be classical linear codes chosen so that the corresponding CSS code corrects the relevant error patterns. The code reconciles Alice and Bob's bit strings: Bob corrects his string to Alice's codeword. The subcode performs privacy amplification: the final key is the coset of the reconciled word modulo . Because the proof reduces an explicitly secure entanglement-distillation protocol to this classical procedure without changing Eve's conditioned quantum state, BB84 inherits the security claim in the idealized model.
For a simplified one-way asymptotic analysis, the secret fraction has the classical advantage-distillation shape
where is Alice's remaining raw bit, is Bob's correlated bit, and denotes Eve's side information. In the symmetric ideal BB84 case, the common Shor-Preskill-style expression is
where
The formula says that bit errors cost reconciliation information and phase-error uncertainty costs privacy amplification. It is not a full device key-rate formula. Finite-size statistics, detector behavior, source flaws, authentication costs, leakage during reconciliation, and decoy-state estimates all affect a deployed system.
Nielsen and Chuang explicitly mark the proof as idealized. It assumes the transmitted states are the BB84 qubit states in the model. Practical optical QKD often uses attenuated lasers, not deterministic single photons. For phase-randomized weak coherent pulses with mean photon number ,
Multi-photon pulses motivate decoy-state BB84, where Alice varies to estimate the single-photon yield and error rate and to limit photon-number-splitting attacks.
Visual
The sequence shows every BB84 phase from bit/basis sampling through final key extraction. The note gives the explicit bit-to-state mapping, and the public-channel messages are separated from the quantum transmission so the reader can see exactly when bases, check bits, reconciliation data, and privacy-amplification choices are revealed. The abort branch is driven by the estimated QBER and verification outcome.
| Proof stage in Nielsen and Chuang | Operational meaning in BB84 | Security role |
|---|---|---|
| EPR pair generation | Imaginary entanglement-based version of the protocol | Makes ideal secrecy transparent |
| Random sampling | Public comparison of check bits | Bounds bit and phase error rates |
| CSS code | Classical information reconciliation | Corrects Bob's noisy string |
| Subcode | Privacy amplification by cosets | Compresses away Eve's information |
| Reduction to prepare-and-measure | Alice sends or states and Bob measures immediately | Removes quantum memory and quantum computation |
| Holevo bound | for Eve's accessible measurement information | Converts closeness-to-ideal into an information bound |
Worked example 1: Trace a secure BB84 block
Problem. Alice sends 12 BB84 signals. The table gives Alice's bits and bases, Bob's bases, and Bob's measurement results. Determine the sifted strings, estimate the QBER from the first four sifted positions, and decide whether this toy block should continue if the allowed check threshold is errors in four check bits.
| Round | Alice bit | Alice basis | Bob basis | Bob bit |
|---|---|---|---|---|
| 1 | 1 | Z | Z | 1 |
| 2 | 0 | X | Z | 1 |
| 3 | 1 | X | X | 1 |
| 4 | 0 | Z | X | 0 |
| 5 | 1 | Z | Z | 0 |
| 6 | 0 | X | X | 0 |
| 7 | 0 | Z | Z | 0 |
| 8 | 1 | X | Z | 0 |
| 9 | 1 | X | X | 1 |
| 10 | 0 | Z | Z | 0 |
| 11 | 0 | X | X | 1 |
| 12 | 1 | Z | X | 1 |
Method.
-
Keep only positions where Alice's and Bob's bases match: rounds 1, 3, 5, 6, 7, 9, 10, and 11.
-
Read Alice's sifted string:
- Read Bob's sifted string:
- Use the first four sifted positions as check bits:
| Sift index | Alice | Bob | Disagree? |
|---|---|---|---|
| 1 | 1 | 1 | no |
| 2 | 1 | 1 | no |
| 3 | 1 | 0 | yes |
| 4 | 0 | 0 | no |
- Count check errors:
- Estimate QBER on the check sample:
- Compare against the threshold . Since , the protocol aborts.
Checked answer. The sifted strings are and . The check sample has one error in four compared bits, so this toy block fails the stated threshold and Alice and Bob do not run reconciliation or privacy amplification. The remaining unrevealed positions would have been and , which also shows why reconciliation would be needed if the block had passed.
Worked example 2: Compute a Holevo-style secret-fraction bound
Problem. In a simplified asymptotic BB84 analysis, suppose the observed QBER is . Treat Alice and Bob's post-sifting correlation as a binary symmetric channel, so
Assume the security proof and parameter estimation bound Eve's accessible information by bits per sifted bit. Use
to lower-bound the secret fraction.
Method.
- Compute the binary entropy:
- Approximate the logarithms:
- Substitute:
- Compute Alice-Bob mutual information:
- Subtract Eve's information bound:
- Interpret the result for a block of sifted unrevealed bits:
final bits before additional finite-size and authentication margins.
Checked answer. The simplified bound gives at least about secret bits per sifted bit. This is a Holevo/Csiszar-Korner style calculation, not a complete finite-key proof: in a real BB84 security analysis, the estimate of is itself derived from the observed parameters, and public reconciliation leakage plus failure probabilities must be subtracted explicitly.
Code
import math
import random
def binary_entropy(q):
if q <= 0.0 or q >= 1.0:
return 0.0
return -q * math.log2(q) - (1.0 - q) * math.log2(1.0 - q)
def bb84_trial(rounds=100_000, intercept_probability=0.0):
alice_bits = [random.randrange(2) for _ in range(rounds)]
alice_bases = [random.randrange(2) for _ in range(rounds)] # 0=Z, 1=X
bob_bases = [random.randrange(2) for _ in range(rounds)]
bob_bits = []
for bit, basis, bob_basis in zip(alice_bits, alice_bases, bob_bases):
sent_bit = bit
sent_basis = basis
if random.random() < intercept_probability:
eve_basis = random.randrange(2)
eve_bit = sent_bit if eve_basis == sent_basis else random.randrange(2)
sent_bit = eve_bit
sent_basis = eve_basis
bob_bit = sent_bit if bob_basis == sent_basis else random.randrange(2)
bob_bits.append(bob_bit)
sifted = [i for i in range(rounds) if alice_bases[i] == bob_bases[i]]
errors = sum(alice_bits[i] != bob_bits[i] for i in sifted)
qber = errors / len(sifted)
# Shor-Preskill asymptotic idealization for symmetric BB84.
secret_fraction = max(0.0, 1.0 - 2.0 * binary_entropy(qber))
return len(sifted) / rounds, qber, secret_fraction
for p in [0.0, 0.25, 0.50, 1.0]:
sift_rate, qber, secret = bb84_trial(intercept_probability=p)
print(
f"intercept={p:.2f} "
f"sift_rate={sift_rate:.3f} "
f"qber={qber:.3f} "
f"ideal_secret_fraction={secret:.3f}"
)
This is a protocol sketch, not a QKD implementation. It has no authenticated transcript, no finite-key confidence interval, no real reconciliation code, no decoy-state estimation, and no detector model. It is useful for checking the sifting rate, the full intercept-resend QBER, and the entropy penalty in the idealized expression.
Common pitfalls
- Keeping mismatched-basis bits. In BB84, those bits are random relative to Alice's values and must not enter the key.
- Revealing check bits and then reusing them. Once a bit is publicly compared, it is public.
- Treating intercept-resend as the only attack. Nielsen and Chuang's proof is valuable because it handles coherent attacks through the EPR/CSS reduction, not just one-qubit measurements by Eve.
- Treating the Holevo bound as a complete BB84 proof. Holevo bounds accessible information once the relevant quantum state has been constrained; sampling, reconciliation, and privacy amplification still do real work.
- Forgetting reconciliation leakage. Every public syndrome, parity, or interactive message must be accounted for before choosing the final key length.
- Reading as a deployed product formula. Finite-size effects, inefficient reconciliation, decoy statistics, authentication, device assumptions, and composable security parameters change the final rate.
- Ignoring source assumptions. Attenuated lasers produce multi-photon pulses with nonzero probability; decoy-state analysis is the standard way to keep weak coherent BB84 secure.
- Assuming the classical channel can be unauthenticated. Without authentication, Eve can mount a man-in-the-middle attack and run separate sessions with Alice and Bob.
Connections
- Quantum Communication for the area overview and the no-cloning intuition.
- Quantum Key Distribution for Holevo information, secret-key-rate accounting, B92, E91, decoy BB84, MDI-QKD, TF-QKD, and DI-QKD.
- Quantum Network for how BB84 links are composed into trusted-node or access networks.
- Quantum Internet and Quantum Repeater for architectures beyond direct lossy QKD links.
- Quantum Algorithms for no-cloning and measurement language used in the security intuition.
- Quantum Error Correction for the CSS-code machinery behind the Nielsen-Chuang security proof.
- Classical Cryptography, Perfect Secrecy and One-Time Pad, and Message Authentication Codes for how QKD-generated keys are consumed and authenticated.
- Primary textbook reference: Nielsen and Chuang, Quantum Computation and Quantum Information, Chapter 12, especially the Holevo bound and the reduction of CSS-code QKD to secure BB84.