1. Worked problem §
How many possible keys encrypt a fixed four-bit message to a specified ciphertext?
Hint 1
Solve C=M XOR K.
Worked solution
Exactly one: K=M XOR C. Uniform selection among all 16 keys makes the ciphertext uniform.
Quantum Cryptography · Chapter 01
What must a key hide, and from whom?
Starting point: Qubits, measurement, and elementary probability.
Anchor example: A one-time pad with a public parity leak.
Method: Trace the protocol, calculate an example, and identify the security assumptions.
Watch for: A random-looking key need not be secret from Eve.
This lesson includes explanations, worked examples, and problems with solutions. Advanced results whose proofs are outside the chapter are identified explicitly.
Alice and Bob want to agree on a key that Eve cannot guess, even though Eve controls the channel between them. Quantum mechanics will not hand them a secret out of nothing: it lets them test whether Eve has been listening and bounds how much she could know. To see why that is valuable—and what it does not buy—we first need a precise account of what a key is supposed to do.
A security claim is only as strong as the resource it assumes. Before asking what quantum mechanics adds, this section fixes the classical benchmark: what a one-time pad promises, what it costs, and what it leaves unprotected.
Alice holds a classical message \(M\) and a key \(K\) of the same length, both bit strings. She sends the ciphertext \(C=M\oplus K\), and Bob, who also has \(K\), recovers \(M=C\oplus K\). The scheme is symmetric, deterministic, and costs one key bit per message bit.
Its security claim is conditional on four resources. The key must be uniform, independent of the message, secret from Eve, and used once. Drop any one and the claim fails in a different way: a biased key leaves a statistical trace (Section 1.1.2), reuse leaks relations between messages (Section 1.1.3), and a compromised key is simply known to Eve. QKD produces key material that is close to uniform and independent of Eve even when she controls the channel, but it does not remove the one-time-use requirement.
The pad also has blind spots. It hides content, not length, and it supplies neither integrity nor authentication: anyone can flip ciphertext bits, and the receiver will decrypt a corrupted message. These are separate tasks requiring separate resources. Against an unbounded Eve the guarantee is information-theoretic—no amount of extra computation helps her—whereas a computational cipher assumes Eve cannot solve a specific problem. Before comparing schemes, state the resource each one assumes and the task it actually implements.
Encrypt 1011 with key 0110. What does Eve learn if the same key also encrypts 0011?
The ciphertexts are \(1011\oplus0110=1101\) and \(0011\oplus0110=0101\). XORing them cancels the key and gives \(1101\oplus0101=1000\), which is exactly \(1011\oplus0011\). Eve learns how the two messages differ without learning either. One guess about one message then determines the other.
Perfect secrecy says that seeing the ciphertext changes nothing about Eve's beliefs. Formally, for every message \(m\) and ciphertext \(c\) with \(P(C=c)>0\),
\[P(M=m\mid C=c)=P(M=m).\]The definition compares a posterior with a prior. It says nothing about whether the prior itself is uniform.
Why does a uniform pad satisfy it? Fix \(m\) and \(c\), each of length \(n\). Exactly one key produces that ciphertext from that message, namely \(k=m\oplus c\). Uniformity and independence give
\[P(C=c\mid M=m)=P(K=m\oplus c)=2^{-n},\]and the right side does not depend on \(m\). Summing over messages gives \(P(C=c)=2^{-n}\), so Bayes' rule returns the prior:
\[P(M=m\mid C=c)=\frac{P(C=c\mid M=m)\,P(M=m)}{P(C=c)}=P(M=m).\]Two features of this calculation are easy to miss. First, the message distribution may be arbitrarily biased: if Eve already believes one message is likely, she still believes that after seeing \(c\), because the ciphertext supplies no new evidence. Second, the key must be uniform relative to Eve. A key that looks random to Alice but is known to Eve is not a key in this sense.
A biased key shows the failure concretely. Take a one-bit message, a uniform message prior, and \(P(K=0)=0.9\). Then \(P(C=0\mid M=0)=0.9\) while \(P(C=0\mid M=1)=0.1\). Observing \(C=0\) raises the posterior for \(M=0\) from \(1/2\) to
\[\frac{0.9\cdot0.5}{0.9\cdot0.5+0.1\cdot0.5}=0.9.\]Secrecy also costs key length. Fix a ciphertext \(c\). Correct decryption assigns at most one message to each key, so at most \(|K|\) messages can be recovered from \(c\). Perfect secrecy, for a prior that gives every message positive probability, requires every message to remain possible given \(c\), so all \(|M|\) messages must be recoverable. Hence \(|K|\ge|M|\). QKD does not repeal this accounting; it supplies the shared randomness that encryption later consumes.
Two-bit messages are encrypted with a uniform key drawn from \(\{00,01,10\}\). Which message is ruled out by the ciphertext \(00\), and why does that violate perfect secrecy?
With \(C=00\) the compatible messages are the three keys themselves, \(\{00,01,10\}\). If the message prior is uniform, \(P(M=11\mid C=00)=0\) while \(P(M=11)=1/4\). Three keys cannot hide four messages: every ciphertext excludes at least one message. Adding the fourth key restores perfect secrecy.
Perfect secrecy is a statement about a single use. Reuse the same pad for two messages and the key cancels:
\[C_1\oplus C_2=(M_1\oplus K)\oplus(M_2\oplus K)=M_1\oplus M_2.\]Eve now holds a relation between the plaintexts. If she can guess one message, even partially, she recovers the corresponding part of the other. The one-time condition is not bureaucratic; it is what prevents this cancellation.
Confidentiality and integrity fail for different reasons, so repairing one does not repair the other. An attacker who cannot read \(C\) can still replace it with \(C\oplus\Delta\), and decryption then yields \(M\oplus\Delta\). Bob cannot notice unless the message or the channel supplies authentication. A one-time pad used correctly therefore guarantees confidentiality and nothing else.
It helps to draw the QKD setting as two channels with different powers for Eve.
| Channel | Eve may | What the claim assumes |
|---|---|---|
| Quantum | replace, block, entangle, or store signals | her actions obey the stated quantum model |
| Classical | read and delay messages | a forgery succeeds with probability at most \(\epsilon_{\rm auth}\) |
If the classical channel were public but unauthenticated, Eve could sit between Alice and Bob, run one exchange with each, and relay messages. Both parties would see ordinary quantum statistics while each final key was shared with Eve rather than with each other. This is why QKD consumes an initial short secret to authenticate, and why that cost must be budgeted rather than assumed away.
Worked derivation. Alice and Bob hold independent uniform bits \(X_1,X_2\) and publicly announce \(P=X_1\oplus X_2\). Are the individual bits still uniform? How much uncertainty about the pair remains?
Yes. Given \(P=0\) the pair is \(00\) or \(11\) with probability \(1/2\) each, so each bit is uniform; given \(P=1\) the candidates are \(01\) and \(10\), and again each bit is uniform. But the pair is confined to one of two strings instead of four. Public reconciliation information can leave every marginal untouched while removing entropy from the joint string, which is why the secrecy definition must include the transcript.
A key is therefore defined by a joint state, not by a list of bits that look random. Section 1.2 shows what quantum mechanics restricts, and Section 1.3 makes the joint-state comparison precise.
Quantum mechanics enters the argument twice: it restricts what Eve can copy, and it forces a detectable price when she obtains information. This section develops both statements one qubit at a time and marks clearly where a security proof is still missing.
Fix the two bases used throughout the course. The Z basis is \(\{|0\rangle,|1\rangle\}\); the X basis is \(\{|+\rangle,|-\rangle\}\), where
\[|\pm\rangle=\frac{|0\rangle\pm|1\rangle}{\sqrt2}.\]The bases are incompatible: a Z eigenstate measured in X gives each outcome with probability \(1/2\), and vice versa. That fact is the resource the protocol will exploit.
Suppose a unitary \(U\) copied two states perfectly into a fixed blank register \(|b\rangle\):
\[U|\psi\rangle|b\rangle=|\psi\rangle|\psi\rangle,\qquad U|\phi\rangle|b\rangle=|\phi\rangle|\phi\rangle.\]Take inner products of the two equations and use that \(U\) preserves inner products:
\[\langle\psi|\phi\rangle=\langle\psi|\phi\rangle^{2}.\]Writing \(s=\langle\psi|\phi\rangle\), the condition \(s=s^2\) forces \(s=0\) or \(s=1\). Two distinct nonorthogonal states cannot both be copied by the same machine. Orthogonal states can: a controlled-NOT with the state as control and a blank \(|0\rangle\) as target copies \(|0\rangle\) and \(|1\rangle\) exactly.
This is a real restriction, but it is not a protocol security proof. Eve need not copy. She can interact weakly with many signals, keep a quantum memory, exploit channel loss, or coordinate a collective attack, and she may accept a nonzero chance that the protocol aborts. No-cloning rules out one strategy; security must bound every strategy the physical model allows.
Apply the copying condition to \(|0\rangle\) and \(|+\rangle\).
The input overlap is \(\langle0|+\rangle=1/\sqrt2\). The two copied outputs \(|0\rangle|0\rangle\) and \(|+\rangle|+\rangle\) would have overlap \(1/2\). A unitary preserves overlaps, so the required equality fails and no perfect copier exists. The gap between \(1/\sqrt2\) and \(1/2\) is the quantitative obstruction.
A classical label and the quantum signal carrying it are different objects, and it pays to keep them apart. If Alice sends the X-basis bit \(+\), the state held by Bob or Eve is
\[\rho_+=\frac12\begin{pmatrix}1&1\\1&1\end{pmatrix},\qquad \rho_-=\frac12\begin{pmatrix}1&-1\\-1&1\end{pmatrix}.\]These are \(|+\rangle\langle+|\) and \(|-\rangle\langle-|\) written in the Z basis. The diagonal entries are the Z-measurement probabilities; the off-diagonal entries are the coherences that an X measurement reads.
Now average over the bit. A uniform mixture cancels the off-diagonal entries:
\[\frac{\rho_++\rho_-}{2}=\frac{I}{2},\]and the same is true of \((|0\rangle\langle0|+|1\rangle\langle1|)/2\). If the bit is uniform and nothing else leaks the basis, the state Eve holds is \(I/2\) whichever basis Alice used. No measurement can tell the two cases apart, because the two descriptions are literally the same operator. This is an identity about states, not a statement about Eve's ignorance of the notation.
Before the basis is announced, Eve faces a different question: she may know that the bit is uniform but not which basis was used. The two candidate states are
\[\rho_0=\frac{|0\rangle\langle0|+|+\rangle\langle+|}{2},\qquad \rho_1=\frac{|1\rangle\langle1|+|-\rangle\langle-|}{2},\]The first averages the Z and X preparations of bit \(0\), the second the preparations of bit \(1\), each weighted equally because Eve does not know the basis. Their difference is \((X+Z)/2\), whose eigenvalues are \(\pm1/\sqrt2\). The optimal binary discrimination probability is given by the Helstrom formula
\[p_{\rm guess}=\frac12+\frac{\|\rho_0-\rho_1\|_1}{4},\]where the trace norm is the sum of the singular values. For this pair the trace norm is \(2/\sqrt2=\sqrt2\), so \(p_{\rm guess}=(1+1/\sqrt2)/2\approx0.8536\). Eve can beat a coin flip by a wide margin if she is willing to consume the signal in that measurement.
That number is not yet a successful attack. Eve must hand Bob a signal, and Alice later announces the basis, so Eve's guess is judged on the whole transcript rather than on one measurement. The calculation measures how much the two bit hypotheses overlap; it does not say how much information survives the rest of the protocol.
Use the same formula for \(\rho_+\) and \(\rho_-\). What is the optimal success probability, and why is it not a contradiction?
Their difference is \(\rho_+-\rho_-=X\), whose eigenvalues are \(\pm1\), so the trace norm is \(2\) and \(p_{\rm guess}=1/2+2/4=1\). The states are orthogonal and can be told apart perfectly. There is no contradiction: here the basis is known to be X, while the earlier question asked Eve to discriminate the two bit hypotheses without knowing the basis. Different ensembles, different answers.
Eve need not guess at all. She can let a unitary entangle each signal with an ancilla she keeps, so that her record is correlated with the bit while the signal continues to Bob. The price of that correlation is the subject of this subsection.
Consider an attack that leaves the Z basis untouched but writes the value into Eve's ancilla:
\[|0\rangle|e\rangle\mapsto|0\rangle|e_0\rangle,\qquad |1\rangle|e\rangle\mapsto|1\rangle|e_1\rangle.\]Linearity fixes the action on superpositions. For \(|+\rangle\) the joint state becomes
\[\frac{|0\rangle|e_0\rangle+|1\rangle|e_1\rangle}{\sqrt2}.\]Tracing out Eve leaves Bob with the reduced state
\[\rho_B=\frac12\begin{pmatrix}1&\langle e_1|e_0\rangle\\ \langle e_0|e_1\rangle&1\end{pmatrix}.\]The off-diagonal coherence has been multiplied by the overlap \(\langle e_1|e_0\rangle\). Bob's X-basis error probability is the probability of the \(|-\rangle\) outcome,
\[P(-)=\frac{1-\operatorname{Re}\langle e_1|e_0\rangle}{2}.\]The two extremes are instructive. If \(e_0=e_1\), the overlap is one, Eve's record is the same for both bits, and Bob sees no error. If \(\langle e_1|e_0\rangle=0\), Eve can read the Z bit perfectly, and Bob's X outcome is uniformly random. Partial overlap interpolates between the two: information and disturbance trade off quantitatively.
This is the mechanism behind the slogan that measurement disturbs a state. Nothing reaches in and "kicks" the qubit. Eve's ancilla becomes correlated with the signal, the correlations are inaccessible to Bob, and the interference he would need to see disappears. It also explains why testing only Z is inadequate: this attack produces no Z errors at all while Eve holds a perfect record. BB84 tests complementary preparations precisely to expose the missing coherence, which is the subject of Section 2.2.
Secrecy needs a definition that survives composition with other protocols. This section states the definition, gives it an operational meaning, and tests it on an example where intuition alone would mislead.
A key protocol makes three separate promises, and each needs its own error parameter. Correctness bounds the probability that Alice and Bob accept while holding different keys. Secrecy says the key they hold is indistinguishable from a uniform key independent of Eve. Authentication bounds the chance that Eve can impersonate a party on the classical channel.
These are separate on purpose. A protocol can be correct and secret but forgeable, or authenticated and secret but occasionally wrong. Availability is separate again: Eve can always block signals and prevent a key from being produced. A secrecy theorem for accepted runs does not contradict that; it says nothing about runs that abort.
Authentication deserves emphasis because it is the resource QKD cannot manufacture from nothing. An authenticated classical channel lets Eve listen and delay but not undetectably alter messages. Without it, she can run one exchange with Alice and another with Bob, as described in Section 1.1.3. In practice authentication uses a short pre-shared secret and a universal hash family: the tag gives a bounded forgery probability per message, and the key cost must be budgeted explicitly.
A protocol has secrecy error \(10^{-9}\), correctness error \(10^{-12}\), and authentication error \(10^{-12}\). Give a composable upper bound on its total failure probability.
Each requirement bounds the probability of a different bad event, so the union bound adds them: \(10^{-9}+10^{-12}+10^{-12}=1.002\times10^{-9}\). The result bounds failure or distinguishability; it does not predict that any particular attack will be observed.
To compare a real protocol with an ideal one, put both in the same mathematical form. Let \(K\) be the \(\ell\)-bit classical output and let \(E\) denote everything Eve holds: her quantum memory, her classical records, and the public transcript. The joint state is classical on Alice and Bob's side and quantum on Eve's:
\[\rho_{KE}=\sum_k p_k\,|k\rangle\langle k|\otimes\rho_E^k.\]The ideal state is a uniform key independent of Eve:
\[\tau_K\otimes\rho_E,\qquad \tau_K=2^{-\ell}\sum_k|k\rangle\langle k|.\]The distance between the two is measured by the trace distance
\[T(\rho,\sigma)=\frac12\|\rho-\sigma\|_1,\]where the trace norm is the sum of the singular values. For states diagonal in the same basis this is exactly the classical total variation distance, \(T=\frac12\sum_x|p_x-q_x|\). The quantum definition has the operational meaning we need: substituting one state for the other changes the probability of any subsequent event by at most \(T\). Equivalently, an optimal test distinguishing the two with equal prior succeeds with probability \(\frac12+\frac{T}{2}\).
Protocols can abort, so the comparison is made on accepted runs and weighted by the probability of accepting:
\[p_{\rm pass}\,T\!\left(\rho_{KE\mid\mathrm{pass}},\;\tau_K\otimes\rho_{E\mid\mathrm{pass}}\right)\le\epsilon_{\rm sec}.\]The weighting matters. Conditioning on a rare acceptance event can make the conditional state far from ideal, while the unconditional claim remains meaningful because that event is unlikely. If acceptance never occurs, the left side is interpreted as zero. Correctness is bounded separately by \(P[K_A\ne K_B\ \text{and pass}]\le\epsilon_{\rm cor}\).
If the output length is announced after the fact, the ideal state must be uniform for each announced length. The examples in this course fix the length in advance, which keeps the accounting simple.
Alice and Bob share a uniform \(\ell\)-bit key, and Eve holds a perfect copy. Show that the trace distance from the ideal independent state is \(1-2^{-\ell}\).
The real distribution is supported on the \(2^\ell\) pairs \((k,k)\), each with probability \(2^{-\ell}\). The ideal distribution spreads probability \(2^{-2\ell}\) over all \(2^{2\ell}\) pairs. Every real pair contributes \(2^{-\ell}-2^{-2\ell}\), and every ideal-only pair contributes \(2^{-2\ell}\). The real pairs therefore contribute \(1-2^{-\ell}\) in total, and the \(2^{2\ell}-2^\ell\) ideal-only pairs contribute the same amount, so
\[T=\tfrac12\left(1-2^{-\ell}+1-2^{-\ell}\right)=1-2^{-\ell}.\]For one bit this is \(1/2\), matching the counterexample in Section 1.3.3. As \(\ell\) grows, an exactly known key becomes almost perfectly distinguishable from an independent one.
Suppose Alice and Bob share a uniform bit and Eve has a perfect copy. Correctness is perfect, and each honest party sees zeros exactly half the time, so a histogram of \(K\) alone looks ideal. The joint distribution tells a different story.
| Pair \((K,E)\) | Real probability | Ideal probability |
|---|---|---|
| (0,0) | 1/2 | 1/4 |
| (0,1) | 0 | 1/4 |
| (1,0) | 0 | 1/4 |
| (1,1) | 1/2 | 1/4 |
Here \(E\) is classical, so the trace distance reduces to half the sum of the absolute differences:
\[T=\frac12\left(\left|\tfrac12-\tfrac14\right|+\left|0-\tfrac14\right|+\left|0-\tfrac14\right|+\left|\tfrac12-\tfrac14\right|\right)=\frac12.\]The operational difference is easy to see. Ask whether \(K=E\). In the real protocol the answer is always yes; in the ideal protocol it is yes with probability \(1/2\). A test that looks only at the key's histogram cannot detect the leak, but a test that looks at the key together with Eve's information can.
The distance also composes. Any later processing—hashing, encryption, an adversary's measurement—cannot increase trace distance, so replacing the real key by an ideal key inside a larger protocol changes its output by at most the secrecy error. Applying several such replacements in sequence adds their errors by the triangle inequality. That is what makes a small \(\epsilon_{\rm sec}\) a usable guarantee rather than a decorative number.
One interpretation of \(\epsilon_{\rm sec}\) should be avoided. It does not mean that Eve knows the entire key with probability \(\epsilon\), or that she knows nothing otherwise. It means the real joint state is close to one in which she knows nothing, and the distance bounds what any distinguisher can notice.
Authentication fits the same replacement argument. A universal-hash tag with a secret hash choice gives a bounded forgery probability per message, but the hash key is consumed, and reusing it degrades the bound. We will budget authentication bits explicitly rather than treat the public channel as free.
The chapter's three ideas now connect: a key is a resource with a precise cost (1.1); quantum mechanics constrains how Eve can acquire it and makes her acquisition visible (1.2); and composable security compares the whole joint state, transcript included, with an ideal key (1.3). Chapter 2 turns these ingredients into the BB84 protocol.
These sources supply the classical results quoted above and the quantum tools used later.
These exercises draw on the whole chapter. Attempt each question before opening a hint, explain your reasoning, then compare it with the worked solution.
How many possible keys encrypt a fixed four-bit message to a specified ciphertext?
Solve C=M XOR K.
Exactly one: K=M XOR C. Uniform selection among all 16 keys makes the ciphertext uniform.
Does a one-time pad authenticate a message?
Flip a ciphertext bit.
No. A flipped ciphertext bit flips the corresponding plaintext bit. Authentication must be supplied separately.
Can |0⟩ and |1⟩ be copied?
Evaluate their overlap.
Yes. They are orthogonal; a CNOT with a blank |0⟩ target copies this basis label.
If a device copies Z states, what happens to |+⟩?
Apply CNOT linearly.
It produces (|00⟩+|11⟩)/√2, an entangled state, rather than |+⟩|+⟩.
Why include the public transcript in Eve’s system?
Consider a publicly announced parity.
It can reveal information about the raw key even though the quantum signals were private.
Can Eve force a secure protocol to abort?
Separate availability from secrecy.
Yes. Blocking all signals prevents key generation without violating the secrecy guarantee for accepted keys.
Prove that a uniform n-bit pad hides any message distribution, then explain why the proof fails when the key is correlated with the message.
Fix a message and a ciphertext, and solve for their unique connecting key.
For each m,c, the unique key is k=m XOR c. Independence gives P(K=k|M=m)=P(K=k)=2^(−n), so P(C=c|M=m)=2^(−n)=P(C=c). Bayes gives P(M=m|C=c)=P(M=m). If K=M, independence fails: C is always zero and the receiver cannot decode without already knowing M through K. Correlation invalidates the substitution P(K=k|M=m)=P(K=k); the resource assumptions must be checked before applying the argument.
A uniform two-bit key K has Eve’s record E=K₁ XOR K₂. Compute its conditional guessing probability, conditional min-entropy, and trace distance from an independent uniform key with the same E marginal.
For each parity, list the two compatible and two incompatible key strings.
Given either parity, two keys remain equally likely, so pguess=1/2 and Hmin(K|E)=1 bit. The real joint distribution has four compatible (K,E) pairs with probability 1/4 each; the ideal independent distribution has all eight pairs with probability 1/8. The distance is (1/2)[4|1/4−1/8|+4|0−1/8|]=1/2. Every individual key bit remains uniform, but the full key is not independent of Eve.
For the ancilla attack in Section 1.2, let the real overlap ⟨e₁|e₀⟩ equal 0.6. Derive Bob’s density matrix for input |+⟩ and the X-basis error probability.
Trace out Eve in the four outer-product terms.
Bob’s matrix is (1/2)[[1,0.6],[0.6,1]]. Its expectation in |−⟩ is (1−0.6)/2=0.2, so 20% of X outcomes are wrong. Z eigenstates still pass undisturbed. The nonorthogonal Eve records encode partial information; the coherence factor quantifies the complementary disturbance.
A protocol accepts with probability 0.001, has accepted-state key distance 0.02, unconditional correctness failure 10⁻⁷, and authentication failure 10⁻⁸. Bound its combined deviation using the course conventions.
Weight only the conditional secrecy term by the pass probability.
Secrecy contributes 0.001×0.02=2×10⁻⁵. Adding the already unconditional correctness and authentication terms yields 0.00002011. Multiplying those latter terms by the pass probability again would be unjustified. This does not assert that the accepted key has distance at most 0.00002011; its conditional distance was specified as 0.02.