Categories: Cryptography, Quantum information.

BB84 protocol

The BB84 or Bennett-Brassard 1984 protocol is a quantum key distribution (QKD) protocol, whose purpose is to securely transmit a string of random bits over a quantum channel for later use as a one-time pad. It is provably information-secure, thanks to the fact that quantum channels cannot be eavesdropped without interfering with the signal.

Alice wants to send a secret key to Bob. Between them, they have one quantum channel and one classical channel. Both channels may have eavesdroppers without compromising the security of the BB84 protocol, as long as Alice and Bob authenticate all data sent over the classical channel.

First, Alice securely generates a sequence of random (classical) bits. Note that the BB84 protocol is only suitable for random (high-entropy) data, because the later stages of the protocol involve revealing parts of the data over the (insecure) classical channel.

For each bit, Alice randomly chooses a qubit basis, either {0,1}\{ \Ket{0}, \Ket{1} \} (eigenstates of the zz-spin σ^z\hat{\sigma}_z) or {,+}\{ \Ket{-}, \Ket{+} \} (eigenstates of the xx-spin σ^x\hat{\sigma}_x). Using the basis she chose, she then transmits the bits to Bob over the quantum channel, encoding them as follows:

00or+11or\begin{aligned} 0 \:\:\rightarrow\:\: \Ket{0} \:\mathrm{or}\: \Ket{+} \qquad \quad 1 \:\:\rightarrow\:\: \Ket{1} \:\mathrm{or}\: \Ket{-} \end{aligned}

Crucially, Bob has no idea which basis Alice used for any of the bits. For every bit, he chooses σ^z\hat{\sigma}_z or σ^x\hat{\sigma}_x at random, and makes a measurement of the qubit, yielding 0 or 1. If he guessed the basis correctly, he gets the bit value intended by Alice, but if he guessed incorrectly, he randomly gets 0 or 1 with a 50-50 probability:

0|+2=0|2=1|+2=1|2=12\begin{aligned} | \Inprod{0}{+} |^2 = | \Inprod{0}{-} |^2 = | \Inprod{1}{+} |^2 = | \Inprod{1}{-} |^2 = \frac{1}{2} \end{aligned}

After Alice has sent all her qubits, the next step is basis reconciliation: over the classical channel, Bob announces, for each bit, which basis he chose, and Alice tells him if he was right or wrong. Bob discards all bits where he guessed wrongly. If their quantum channel did not have any noise or eavesdroppers, Alice and Bob now have a perfectly correlated secret string of bits.

Eavesdropper detection

But what if there is actually an eavesdropper? Consider a third party, Eve, who wants to intercept Alice’ secret string. The main advantage of using QKD compared to classical protocols is that such an eavesdropper can be detected.

Suppose that Eve is performing an intercept-resend attack (not very effective, but simple), where she listens on the quantum channel. For each qubit received from Alice, Eve chooses σ^z\hat{\sigma}_z or σ^x\hat{\sigma}_x at random and measures it. She records her results and resends the qubits to Bob using the basis she chose, which may or may not be what Alice intended.

If Eve guesses Alice’ basis correctly, her presence is not revealed, and the protocol proceeds as normal. However, if she guesses wrongly (which has a probability of 50%), her bit value might be incorrect, and she will resend whatever she measured to Bob encoded in the wrong basis.

If we assume that Eve chose wrongly, Bob might measure using Eve’s basis, which will yield a 50% error rate due to Eve’s mistake. Otherwise, Bob might measure using Alice’ basis, which will also yield a 50% error rate due to the disagreement with Eve.

In the end, the probability is 0.5 that Eve chose correctly, which, multiplied by the 0.5 error rate from Bob’s choice, will result in a 0.25 error rate due to Eve’s presence. To detect this, after basis reconciliation, Bob reveals a part of his secret string as a sacrifice, which allows Alice to estimate the error rate. If the rate is too high, Eve is detected, and the protocol can be aborted, although that is not mandatory.

This was an intercept-resend attack. There exist other attacks, but similar logic holds. It has been proven by Shor and Preskill in 2000 that as long as the error rate is below 11%, the BB84 protocol is fully secure, i.e. there cannot be any eavesdroppers.

Error correction

In practice, even without Eve, quantum channels are imperfect, and will introduce some errors in the qubits received by Bob. Suppose that after basis reconciliation, Alice and Bob have the strings {a1,...,aN}\{a_1, ..., a_N\} and {b1,...,bN}\{b_1, ..., b_N\}, respectively. We define pp as the probability that Alice and Bob agree on the nnth bit, which we assume to be greater than 50%:

p=P(an=bn)>12\begin{aligned} p = P(a_n = b_n) > \frac{1}{2} \end{aligned}

Ideally, p=1p = 1. To improve pp, the following simple scheme can be used: starting at n=1n = 1, Alice and Bob reveal AA and BB over the classical channel, where \oplus is an XOR:

A=anan+1B=bnbn+1\begin{aligned} A = a_n \oplus a_{n+1} \qquad \quad B = b_n \oplus b_{n+1} \end{aligned}

If A=BA = B, then an+1a_{n+1} and bn+1b_{n+1} are discarded to prevent a listener on the classical channel from learning anything about the string. If ABA \neq B, all of ana_n, bnb_n, an+1a_{n+1} and bn+1b_{n+1} are discarded, and then Alice and Bob move on to n=3n = 3, etc.

Given that A=BA = B, the probability that an=bna_n = b_n, which is what we want, is given by:

P(an=bnA=B)=P(an=bnA=B)P(A=B)=P(an=bnan+1=bn+1)P(an=bnan+1=bn+1)+P(anbnan+1bn+1)=P(an=bn)P(an+1=bn+1)P(an=bn)P(an+1=bn+1)+P(anbn)P(an+1bn+1)\begin{aligned} P(a_{n} = b_{n} | A = B) &= \frac{P(a_{n} = b_{n} \land A = B)}{P(A = B)} \\ &= \frac{P(a_{n} = b_{n} \land a_{n+1} = b_{n+1})}{P(a_{n} = b_{n} \land a_{n+1} = b_{n+1}) + P(a_{n} \neq b_{n} \land a_{n+1} \neq b_{n+1})} \\ &= \frac{P(a_{n} = b_{n}) \: P(a_{n+1} = b_{n+1})}{P(a_{n} = b_{n}) \: P(a_{n+1} = b_{n+1}) + P(a_{n} \neq b_{n}) \: P(a_{n+1} \neq b_{n+1})} \end{aligned}

We use the definition of pp to get the following inequality, which can be verified by plotting:

P(an=bnA=B)=p2p2+(1p)2>p\begin{aligned} P(a_{n} = b_{n} | A = B) = \frac{p^2}{p^2 + (1 - p)^2} > p \end{aligned}

Alice and Bob can repeat this error correction scheme multiple times, until their estimate of pp is satisfactory. This involves discarding many bits, so the length NnewN_\mathrm{new} of the string they end up with after one iteration is given by:

Nnew=12NoldP(A=B)=12Nold(p2+(1p)2)\begin{aligned} N_\mathrm{new} = \frac{1}{2} N_\mathrm{old} P(A = B) = \frac{1}{2} N_\mathrm{old} \big( p^2 + (1 - p)^2 \big) \end{aligned}

More efficient schemes exist, which do not consume so many bits.

Privacy amplification

Suppose that after the error correction step, p=1p = 1, so Alice and Bob fully agree on the random string. However, in the meantime, Eve has been listening, and has been doing a good job building up her own string {e1,...,eN}\{e_1, ..., e_N\}, such that she knows more that 50% of the bits:

q=P(en=an)>12\begin{aligned} q = P(e_n = a_n) > \frac{1}{2} \end{aligned}

Privacy amplification is an optional final step of the BB84 protocol which aims to reduce Eve’s qq. Alice and Bob use their existing strings to generate a new one {a1,...,aM}\{a_1', ..., a_M'\}:

a1=a1a2=b1b2a2=a3a4=b3b4\begin{aligned} a_1' = a_1 \oplus a_2 = b_1 \oplus b_2 \qquad a_2' = a_3 \oplus a_4 = b_3 \oplus b_4 \qquad \cdots \end{aligned}

Note that this halves the string’s length; more efficient schemes exist, which consume less.

To see why this improves Alice and Bob’s privacy, suppose that Eve is following along, and creates a new string {e1,...,eM}\{e_1', ..., e_M'\} where em=e2m1e2me_m' = e_{2m - 1} \oplus e_{2m}. The probability that Eve’s result agrees with Alice and Bob’s string is given by:

P(em=am)=P(e1=a1e2=a2)+P(e1a1e2a2)=P(e1=a1)P(e2=a2)+P(e1a1)P(e2a2)\begin{aligned} P(e_m' = a_m') &= P(e_1 = a_1 \land e_2 = a_2) + P(e_1 \neq a_1 \land e_2 \neq a_2) \\ &= P(e_1 = a_1) \: P(e_2 = a_2) + P(e_1 \neq a_1) \: P(e_2 \neq a_2) \end{aligned}

Recognizing qq ‘s definition, we find the following inequality, which can be verified by plotting:

P(em=am)=q2+(1q)2<q\begin{aligned} P(e_m' = a_m') = q^2 + (1 - q)^2 < q \end{aligned}

After repeating this step several times, qq will be close to 1/2, which is the ideal value: for q=q = 0.5, Eve would only know 50% of the bits, which is equivalent to her guessing at random.


  1. N. Brunner, Quantum information theory: lecture notes, 2019, unpublished.
  2. J.B. Brask, Quantum information: lecture notes, 2021, unpublished.