Level 7 · Capstone Topics
Quantum Cryptography
About 5,050 words · roughly 23 minute read · sources checked December 2, 2026
Cryptography protects messages by making them unreadable to anyone without a key. The hard part has always been getting the key to the right person without anyone else copying it. Quantum key distribution, or QKD, offers a different kind of answer: it lets two people create a shared secret key in a way that any eavesdropper must disturb, and the disturbance can be detected.
This lesson explains how that works. We work through the BB84 protocol with a numerical example, simulate an eavesdropper and see where the 25% error rate comes from, compute how much secret key survives for a given error, and meet the entanglement-based E91 protocol. We then look at what limits real systems, and at how QKD relates to post-quantum cryptography, which solves the same long-term problem with very different tools.
You need the entanglement and measurement lessons. The networking lesson gives the photon-loss numbers that limit QKD, and the teleportation lesson shows another use of entanglement.
What you will learn
- Why the one-time pad is perfectly secret and what problem it leaves open.
- How BB84 works, including bases, sifting and a worked example.
- Why an eavesdropper who measures and resends causes a 25% error rate.
- How many test bits are needed to catch an eavesdropper.
- How error correction and privacy amplification turn a noisy shared string into a secret key, and how fast the key rate falls with the error.
- How the E91 protocol uses a Bell inequality instead of a disturbance test.
- Why distance is the main practical limit, and how QKD differs from post-quantum cryptography.
Helpful first: Entanglement, Quantum Networking Fundamentals, Quantum Teleportation.
The problem quantum cryptography solves
A message can be made perfectly secret with a one-time pad: write the message as bits, take a random key of the same length, and combine them bit by bit with XOR. Without the key, every possible message is equally likely, so the ciphertext reveals nothing. This is a mathematical fact and does not depend on how powerful the attacker’s computer is.
The catch has two parts. The key must be as long as the message. And it must be used only once. So the real problem is distributing long random keys to people far apart, without an eavesdropper getting a copy. Classical solutions rely on assumptions: that a courier can be trusted, or that a mathematical problem is hard.
Public-key systems such as RSA take the second route. They rely on the difficulty of problems like factoring, which Shor’s algorithm would solve efficiently on a large fault-tolerant quantum computer, as the Shor lessons computed. That is the long-term threat to today’s key exchange. QKD takes a different route: it relies on physical law instead of a computational assumption.
What QKD does and does not do
QKD creates a shared secret key. It does not encrypt messages itself: the key is then used, for example, in a one-time pad or with a standard cipher. And it needs an authenticated classical channel, which we return to below.
BB84: the protocol
The first QKD protocol is named after its authors, Bennett and Brassard, and the year 1984. Their paper’s abstract describes the core idea: sending digital information with single quantum systems such as polarised photons exploits the uncertainty principle, so that eavesdropping is essentially impossible without a high chance of detectable disturbance, and two users can distribute random key material even if they begin with no shared secret.
The ingredients are two measurement bases for a qubit. The Z basis uses |0⟩ and |1⟩. The X basis uses |+⟩ and |−⟩. A state from one basis, measured in the other, gives a random result, as the superposition lesson showed. That fact is the whole security mechanism.
- Alice generates a random bit and a random basis (Z or X) for each qubit. She prepares the qubit in the state that encodes her bit in her basis: in Z, 0 is |0⟩ and 1 is |1⟩; in X, 0 is |+⟩ and 1 is |−⟩. She sends the qubit to Bob.
- Bob chooses a random basis for each arriving qubit and measures.
- Over an ordinary public channel, Alice and Bob announce their bases (not their bits). They keep only the positions where the bases matched. This is called sifting.
- In the kept positions, with no noise and no eavesdropper, Bob’s result equals Alice’s bit. These bits form the raw key.
- They compare a random sample of the raw key in public. If the error rate is too high, they abort. Otherwise they process the rest into a secret key.
Worked example
A worked run with twelve qubits
- I generated twelve random bits and bases for Alice and Bob in a simulation (fixed random seed). Positions 3, 4, 5, 8, 11 and 12 had matching bases, which is 6 out of 12, about the expected half.
- In those positions, Alice’s bits were 1, 0, 1, 0, 0, 1 and Bob’s results were the same, so the raw key is 101001.
- In the other six positions, Bob measured in the wrong basis, so his results were random: Alice’s bit and Bob’s result agreed in some by chance and not in others. Those positions are discarded, since neither side can tell from the bases alone which ones agree.
- Alice and Bob never revealed the bits of the raw key, only the bases. So an eavesdropper who heard the whole public discussion knows which positions were kept but not what the bits were.
Notice one design choice. The bases are announced after the qubits have been measured. An eavesdropper therefore must choose a basis without knowing Alice’s, and cannot go back and fix it.
Why an eavesdropper is detected
Suppose Eve intercepts each qubit, measures it in a randomly chosen basis, and sends a new qubit to Bob prepared in the state she found. This intercept-and-resend attack is the simplest. Here is what happens, position by position.
- With probability 1/2, Eve guesses Alice’s basis correctly. She learns the bit exactly and resends the right state. Bob sees nothing unusual.
- With probability 1/2, Eve guesses wrong. Her result is random, and she resends a state in the wrong basis. If Bob then measures in Alice’s basis (a kept position), he gets a random result, which disagrees with Alice’s bit half the time.
Worked example
Where 25% comes from
- Consider only kept positions, where Bob’s basis matches Alice’s.
- Eve’s basis is wrong with probability 1/2. When it is wrong, Bob’s result is wrong with probability 1/2. So the error probability is 1/2 × 1/2 = 1/4.
- I simulated 200,000 qubits. With no eavesdropper, about 50% of positions were kept and the error rate in them was 0.000. With intercept-and-resend, about 50% were kept and the error rate was 0.248, which is 25% within the sampling error.
- With 2% random noise on the channel and no eavesdropper, the simulated error rate was 0.0198, as expected.
- So an error rate of 25% points to an eavesdropper of this kind, while a small error rate is consistent with ordinary noise.
How many test bits catch Eve?
Alice and Bob compare k randomly chosen bits of the raw key. Each tested bit has a 25% chance to show an error if Eve intercepts every qubit. So the chance that all k tested bits agree even though Eve is listening is 0.75ᵏ.
| Test bits k | Chance Eve passes undetected (0.75ᵏ) |
|---|---|
| 10 | 0.056 |
| 50 | 5.7 × 10⁻⁷ |
| 100 | 3.2 × 10⁻¹³ |
Detection of full intercept-and-resend. Computed as 0.75 raised to the power k.
A hundred test bits make this particular attack all but certain to be seen. Smarter attacks intercept only some qubits or use more careful measurements, and a full security proof must handle every attack allowed by quantum mechanics. That is what Shor and Preskill’s proof does: their abstract says it proves the security of BB84 by relating it to an entanglement-purification protocol using CSS codes.
From a noisy shared string to a secret key
Real channels are noisy, so Alice’s and Bob’s raw keys differ in a few places, and some of what Eve knows may be unknown to them. Two classical steps handle this. Error correction removes the differences by exchanging parity information over the public channel. Privacy amplification then shortens the string, by hashing, to squeeze out whatever partial information Eve might have.
The asymptotic fraction of the sifted key that remains secret, for BB84 with ideal single-photon sources, is 1 − 2h(Q), where Q is the error rate and h(Q) = −Q log₂ Q − (1 − Q) log₂(1 − Q) is the binary entropy. One h(Q) pays for error correction and the other for privacy amplification. This formula comes from the security analysis and I verified its numerical values.
| Error rate Q | h(Q) | Secret fraction 1 − 2h(Q) |
|---|---|---|
| 0% | 0 | 1 |
| 1% | 0.081 | 0.84 |
| 2% | 0.141 | 0.72 |
| 5% | 0.286 | 0.43 |
| 8% | 0.402 | 0.20 |
| 10% | 0.469 | 0.06 |
| 11% | 0.500 | 0.0002 |
| 12% | 0.529 | negative: no secret key |
Computed from the binary entropy. The fraction reaches zero at about 11%, the value usually quoted as the BB84 error threshold.
Worked example
How much key from 10,000 qubits?
- Alice sends 10,000 qubits. About half, 5,000, survive sifting.
- They sacrifice 500 of them to estimate the error rate, leaving 4,500. Suppose the estimate is 2%.
- The secret fraction is 1 − 2h(0.02) = 0.717, so the final key is about 4,500 × 0.717 = 3,227 bits.
- This is the asymptotic formula for ideal sources and very long strings. For short strings, real protocols lose more to finite-size effects, so the actual key is shorter. I did not compute that here.
- Overall, 10,000 qubits yield roughly 3,200 secret bits, about a third. That is typical of the scale of the losses.
The threshold of about 11%
The Shor–Preskill abstract I opened does not state a numerical threshold. The figure of about 11% is the one usually cited for BB84 and agrees with where 1 − 2h(Q) reaches zero, as the table shows, but treat it as my recollection of the paper.
What the key is for: the one-time pad
QKD produces a key. The classic way to use a key of random bits is the one-time pad: write the message as bits, and XOR it (add modulo 2) with a key of the same length. XOR-ing with the same key again returns the message. Shannon showed that a one-time pad is perfectly secret if the key is truly random, as long as the message, and never reused. I state this classical result as background.
Worked example
An 8-bit message
- Message: 01001000 (the ASCII code for the letter H). Key: 10110101.
- Ciphertext = message XOR key = 11111101.
- Bob computes ciphertext XOR key = 01001000, the original message.
- Someone who sees only 11111101 learns nothing, because any 8-bit message could have produced it with some key.
- The costs are what make one-time pads rare: the key must be as long as the data, and it can be used once. QKD’s role is to deliver such keys. In practice, QKD keys are often used with shorter-key ciphers instead, and that is a design choice outside this lesson.
This also explains why key rate matters. Sending a 1 MB file with a one-time pad consumes 8 million secret bits. At the idealised 100 km rate from the distance section, that takes under a second. At 500 km it would take 1.6 million seconds, about 19 days or more, since secret bits are fewer than sifted bits.
After sifting: error correction and privacy amplification
Sifted keys are not yet ready to use. Alice’s and Bob’s strings differ in a fraction Q of positions, and an eavesdropper may know some bits. Two classical steps fix both problems.
Error correction
Alice and Bob exchange parity information over the public channel until their strings agree. Every parity bit they announce leaks information to Eve, so this step should reveal as little as possible. The theoretical minimum is h(Q) bits per sifted bit. Practical protocols leak somewhat more, often modelled as f × h(Q) with f about 1.1 to 1.2. I give f as a typical background value and did not open a source for it.
Privacy amplification
Alice and Bob then apply a randomly chosen hash function that compresses the corrected string into a shorter one. If Eve knows some bits of the long string, the short string is nearly independent of what she knows. How much to compress is set by the estimated error rate Q: the more errors, the more information Eve might hold, and the shorter the final key.
Worked example
Key length for 5,000 sifted bits at Q = 2%
- h(0.02) = 0.141. With ideal error correction, the secret fraction is 1 − 2h = 0.717, so 5,000 × 0.717 = 3,586 bits.
- With f = 1.16, the error-correction leak is 1.16 × 0.141 = 0.164 per bit. The fraction becomes 1 − 0.141 − 0.164 = 0.695, so 5,000 × 0.695 = 3,472 bits.
- The difference is about 3%. Better error-correction codes get closer to the ideal.
| Q | h(Q) | 1 − 2h(Q) (ideal) | 1 − h(Q) − 1.16·h(Q) |
|---|---|---|---|
| 1% | 0.081 | 0.838 | 0.826 |
| 2% | 0.141 | 0.717 | 0.695 |
| 5% | 0.286 | 0.427 | 0.381 |
Secret fraction with ideal and with f = 1.16 error correction. Computed with numpy.
Simulating BB84
This short script simulates BB84 with random bases, an optional intercept-and-resend Eve who guesses a basis for every qubit, and optional channel noise. It is classical bookkeeping of the quantum rules: a measurement in the wrong basis gives a random bit. I ran it with seed 7 and 200,000 qubits.
def run(n, eve, noise):
a = rng.integers(0, 2, n) # Alice bits
ba = rng.integers(0, 2, n) # Alice bases
bb = rng.integers(0, 2, n) # Bob bases
bit, bas = a.copy(), ba.copy()
if eve:
be = rng.integers(0, 2, n)
bit = np.where(be == bas, bit, rng.integers(0, 2, n))
bas = be # Eve resends in her basis
out = np.where(bb == bas, bit, rng.integers(0, 2, n))
out = np.where(rng.random(n) < noise, 1 - out, out)
keep = ba == bb # sifting
return keep.sum(), (a[keep] != out[keep]).mean()| Eve | Channel noise | Sifted bits (of 200,000) | Error rate Q |
|---|---|---|---|
| No | 0% | 99,803 | 0.0000 |
| Yes | 0% | 99,793 | 0.2496 |
| No | 2% | 100,262 | 0.0207 |
| Yes | 2% | 100,021 | 0.2622 |
Simulation output. About half the qubits survive sifting. Eve alone adds about 25%.
The last row shows that noise and eavesdropping combine. In the model, a flip after Eve’s 25% error changes the result as: 0.25 × 0.98 + 0.75 × 0.02 = 0.26, close to the simulated 0.262. Since Alice and Bob cannot tell noise from Eve, they must assume that all errors might be due to an eavesdropper, which is why the secret fraction falls with every extra percent of error.
Why the sifted count is not exactly 100,000
Each qubit survives with probability 1/2, so the count varies like a coin-flip total. For 200,000 qubits the typical spread is √(200,000)/2 ≈ 224 bits, and the four runs above differ from 100,000 by 197, 207, 262 and 21 bits, all within about one spread.
E91: security from a Bell test
In 1991 Artur Ekert proposed a different protocol. The abstract of his paper says it applies the generalised Bell’s theorem to key distribution and builds on Bohm’s version of the Einstein–Podolsky–Rosen experiment, using Bell’s theorem to detect eavesdropping. Instead of Alice sending qubits to Bob, a source sends one half of an entangled pair to each of them.
- Alice and Bob each measure their half of many pairs, choosing among several measurement directions at random.
- They publicly compare which directions they used. For the pairs where they chose the same direction, their results are perfectly correlated, and these form the key.
- For the pairs where they chose different directions, they compute the CHSH quantity S from the entanglement lesson. If S is close to its quantum maximum 2√2 = 2.83, the pairs are almost perfectly entangled, and no third party can hold much information about the results.
- If S is near the classical limit 2, the source is compromised, or the channel is too noisy, and they abort.
Worked example
How noise lowers S
- Model each pair as a Werner state with weight w of a perfect Bell state. The best CHSH value is then S = 2√2 × w.
- For w = 1: 2.83. For w = 0.9: 2.55. For w = 0.8: 2.26. S falls to the classical limit 2 at w = 1/√2 = 0.707.
- So the Bell test can certify entanglement only for w above 0.707. This threshold is higher than the w = 1/3 at which the state stops being entangled, because violating the CHSH inequality is a stronger condition than being entangled.
- The satellite Bell test in the networking lesson measured S = 2.37 ± 0.09. If it were a Werner state, that would correspond to w = 2.37/2.83 = 0.84, comfortably above 0.707.
E91 has an appealing feature: the Bell test certifies security without needing to trust that the devices prepare the exact states described. This idea, called device-independent security, is a research direction that builds on Ekert’s approach. I mention it as background and did not review its current state.
Distance: the practical limit
The main obstacle to long-distance QKD is the same one the networking lesson analysed: photons are lost in fibre, and the quantum signal cannot be amplified. At 0.16 dB/km, the fraction of photons arriving is 0.025 at 100 km, 10⁻⁸ at 500 km and 6 × 10⁻²⁰ at 1,200 km.
Worked example
An idealised key rate
- Assume, only as a best-case illustration, a perfect single-photon source sending 10⁹ qubits per second, perfect detectors and no other loss. The sifted rate is the arrival fraction times 10⁹ times 1/2 for sifting.
- At 100 km: 10⁹ × 0.025 × 0.5 = 1.3 × 10⁷ bits per second. With a 2% error rate, multiplying by the secret fraction 0.717 gives about 9 × 10⁶ secret bits per second.
- At 500 km: 10⁹ × 10⁻⁸ × 0.5 = 5 bits per second sifted, before any other loss.
- At 1,000 km: the arrival fraction is 10⁻¹⁶, so the sifted rate is 5 × 10⁻⁸ per second, one bit every 2 × 10⁷ seconds, about 230 days.
- Real detectors also have dark counts, random clicks that happen without a photon. At very low signal rates these create errors faster than the signal does, so the practical range is shorter than these idealised numbers suggest. I give that as background.
| Distance | Photon arrival fraction | Idealised sifted rate |
|---|---|---|
| 100 km | 0.025 | 1.3 × 10⁷ bits/s |
| 500 km | 1 × 10⁻⁸ | 5 bits/s |
| 1,000 km | 1 × 10⁻¹⁶ | 5 × 10⁻⁸ bits/s |
Best-case sifted rate for a 10⁹ per second source at 0.16 dB/km. Exponential loss dominates.
Longer links therefore use workarounds. Trusted relay nodes receive and re-send keys in chains, which works but requires trusting every node. Satellites, as in the 1,203 km entanglement experiment, avoid fibre loss. True quantum repeaters would remove the exponential penalty and keep security end to end, which is why the networking lesson’s repeater model matters for cryptography.
From theory to real systems
A security proof applies to a model of the devices. Real devices differ from the model, and the differences are where practical attacks live.
- Imperfect sources. Many systems use attenuated laser pulses, which sometimes contain two or more photons. An attacker can take one extra photon without disturbing the other. Decoy-state methods were developed to handle this. This is background knowledge, and I did not look up the details.
- Imperfect detectors. Detectors can be tricked by bright light into behaving classically. Such attacks on commercial devices have been demonstrated, again as background knowledge. Defences include monitoring and the device-independent approach.
- Authentication. The classical channel must be authenticated, or an attacker could sit between Alice and Bob and pretend to each to be the other. Authentication needs a short shared secret to start with, which QKD then expands. So QKD grows a secret key. It does not create one from nothing.
- Finite size. Proofs often assume infinitely many signals. Real runs are finite, which reduces the secret fraction below 1 − 2h(Q).
Where trust is placed
QKD moves the trust from a mathematical assumption to the physical devices. A system is only as secure as its implementation matches its model, which is why standards and testing are active areas.
QKD and post-quantum cryptography
There is a second answer to the threat from quantum computers: replace the vulnerable mathematics with problems that quantum computers are not known to solve quickly. This is post-quantum cryptography, or PQC. NIST announced its first three finalised standards on August 13, 2024: FIPS 203 (ML-KEM, based on CRYSTALS-Kyber) for general encryption and key exchange, FIPS 204 (ML-DSA, based on CRYSTALS-Dilithium) for digital signatures, and FIPS 205 (SLH-DSA, based on SPHINCS+) as a second, differently built signature scheme. NIST advised administrators to start integrating them immediately.
| QKD | Post-quantum cryptography | |
|---|---|---|
| What provides security | Laws of physics, plus trust in devices | Hardness assumptions about certain mathematical problems |
| Runs on | Special optical hardware and fibre or free-space links | Ordinary computers and networks, as software |
| Range and cost | Limited by photon loss; needs dedicated links | No distance limit; deployable by software update |
| What it gives | A shared secret key | Key exchange and signatures |
| Signatures | Not provided by QKD itself | Provided (ML-DSA, SLH-DSA) |
| Main risk | Implementation flaws, authentication needs | A future break of the underlying math (the standards include a backup signature scheme for this reason) |
| Standards | Evolving | FIPS 203, 204, 205 (August 2024) |
A comparison. The PQC entries come from NIST’s announcement; the QKD entries and the risk column are my summary.
For most organisations, PQC is the practical migration path, since it runs on existing hardware. QKD is a complementary technology for specific high-value links, and the two can be combined. That is my reading; check the guidance from your own security authority. A further reason for urgency, widely discussed and not verified by me here, is the harvest-now-decrypt-later concern: encrypted data recorded today could be decrypted by a future quantum computer, so data that must stay secret for decades needs protection sooner.
Beyond key distribution
The original BB84 paper’s abstract also describes a coin-tossing protocol that resists traditional cheating, and notes that it can be subverted using the Einstein–Podolsky–Rosen paradox. Later work showed that a perfectly secure quantum bit commitment, a related building block, is impossible in the standard setting. I give that as background and did not open a source for it. The lesson is that quantum mechanics helps with some cryptographic tasks, key distribution above all, and not with others.
How many test bits catch an eavesdropper?
In BB84, Eve who measures each qubit in a random basis and resends it causes a 25% error rate in the bits where Alice and Bob used the same basis. For each test bit, the chance that Eve goes unnoticed is therefore 3/4. After n independent test bits, the chance that she has not been detected is (3/4)ⁿ, and the chance that she has been detected is 1 − (3/4)ⁿ. These are my own arithmetic from that model.
| Test bits n | Chance Eve is caught |
|---|---|
| 1 | 0.2500 |
| 5 | 0.7627 |
| 10 | 0.9437 |
| 20 | 0.9968 |
| 50 | 0.9999994 |
| 100 | 1 − 3.2 × 10⁻¹³ |
Detection probability for a full intercept-and-resend attack, from 1 − (3/4)ⁿ. My own calculation.
To push the chance of missing her below one in a million you need n such that (3/4)ⁿ < 10⁻⁶, which gives n > ln(10⁻⁶)/ln(0.75) = 48.02, so 49 test bits. That is a small number, which is why the test overhead in BB84 is modest. Real systems also have natural noise from the channel and detectors, so they cannot tell Eve's errors from ordinary errors with a single threshold. They set a threshold above the natural error rate and discard the key if it is exceeded. The model above is the idealised, noise-free case.
What the number does not say
Catching Eve with certainty tells you about this attack, in this model. It is not a proof that a real device is secure. Real implementations have flaws, such as imperfect single-photon sources and detector side channels, which are discussed in the real-world section of the lesson.
The one-time pad, worked with real bits
The one-time pad is the cipher that QKD is designed to feed. It is simple enough to do by hand. Take the 8-bit message 01001000 (the letter H in ASCII) and the key 10110101. Encryption is XOR, bit by bit:
message : 0 1 0 0 1 0 0 0 key : 1 0 1 1 0 1 0 1 cipher : 1 1 1 1 1 1 0 1
To decrypt, XOR the cipher with the same key. 11111101 XOR 10110101 = 01001000, the original message. The security comes from three conditions: the key is random, as long as the message and never reused. If you reuse a key for two messages, XORing the two ciphers cancels the key and leaves the XOR of the two messages, which leaks information. That is why a key distribution method must deliver fresh key material for every message.
How much key a message needs
The key must be as long as the message. A 1-megabyte file needs 8 million key bits. If a QKD link produces a sifted and corrected key at, say, 1,000 secret bits per second (an illustrative figure, not a measured one), the file needs 8,000 seconds, about 2.2 hours, of key. For ordinary encrypted traffic, systems usually use QKD key to seed a shorter-key cipher such as AES instead of a one-time pad, which trades some of the information-theoretic security for practicality. I describe this as the common design and did not open a source on a specific deployment.
Because of the length requirement, the secret key rate is a key figure of merit for any QKD system. The rate section of the lesson shows how loss reduces it, and the next table puts numbers on the key budget.
| Message | Size | Key bits needed | Time at 1,000 secret bits/s |
|---|---|---|---|
| A text message | 200 bytes | 1,600 | 1.6 s |
| A photo | 2 MB | 16,000,000 | 4.4 h |
| An hour of audio | 30 MB | 240,000,000 | 2.8 days |
Key needed for a one-time pad at an illustrative secret key rate. My own arithmetic; the rate is a round number chosen for illustration.
What quantum computers do to symmetric keys
QKD is one response to the quantum threat. The other response is to understand what quantum computers can and cannot do to existing ciphers. For symmetric ciphers such as AES, the relevant algorithm is Grover's search, which finds a key among 2^k candidates in about (π/4)·2^(k/2) steps. This is the same quadratic speed-up as in the Grover lesson, so doubling the key length restores the margin. The table is my own arithmetic from that formula, with an illustrative speed of one microsecond per Grover iteration.
| Key bits k | Grover iterations | Years at 1 µs per iteration |
|---|---|---|
| 56 | 2.1 × 10⁸ | 6.7 × 10⁻⁶ (about 3.5 minutes) |
| 64 | 3.4 × 10⁹ | 1.1 × 10⁻⁴ (about 56 minutes) |
| 80 | 8.6 × 10¹¹ | 0.027 (about 10 days) |
| 128 | 1.4 × 10¹⁹ | 4.6 × 10⁵ |
| 192 | 6.2 × 10²⁸ | 2.0 × 10¹⁵ |
| 256 | 2.7 × 10³⁸ | 8.5 × 10²⁴ |
Idealised Grover key search at one microsecond per iteration, my own arithmetic. Real error-corrected iterations would be far slower, and Grover does not parallelise as well as classical brute force.
For 128-bit keys, the idealised cost is about 460,000 years even at a microsecond per iteration, and real error-corrected machines would be many times slower. For 256-bit keys it is hopeless. This is why the usual advice is that symmetric cryptography needs larger keys, not replacement. The picture for public-key schemes such as RSA is entirely different because Shor's algorithm breaks them in polynomial time, which is why the post-quantum section of the lesson matters.
Two different threats
Shor's algorithm attacks public-key schemes and forces new algorithms. Grover's algorithm attacks symmetric keys and is answered by longer keys. Keeping the two separate avoids most of the confusion in news stories.
Common misconceptions
| Claim | Reality |
|---|---|
| QKD encrypts your messages | It produces a shared secret key. A cipher uses it. |
| QKD is unbreakable | The protocol has proofs under assumptions. Real devices have been attacked through implementation flaws. |
| Eavesdropping is impossible | It is possible but detectable, because it disturbs the states. |
| Entanglement lets you send keys instantly | The raw key comes from measurements, and bases are compared over a classical channel. |
| Quantum computers make all encryption obsolete | They threaten certain public-key systems. Symmetric ciphers are affected less, and post-quantum standards exist. |
| QKD replaces post-quantum cryptography | They are different tools with different trade-offs. |
| The 25% error rate is the threshold | 25% is the error from full intercept-and-resend. Security is lost at about 11% for BB84 in the standard analysis. |
Misconceptions about quantum cryptography.
Extra practice: key bits and detection
Check your understanding of the numbers in this lesson. All answers were computed in Python.
Check yourself
C1. How many test bits are needed to catch a full intercept-and-resend attack with probability at least 99.9%?
We need (3/4)ⁿ ≤ 0.001, so n ≥ ln(0.001)/ln(0.75) = 24.01, which means 25 test bits.
C2. Alice and Bob test 10 bits and find no errors. How likely is it that a full intercept-and-resend attack went unnoticed?
(3/4)¹⁰ = 0.0563, about 5.6%. Ten clean test bits are good evidence but not decisive, which is why real protocols use many more.
C3. A one-time-pad message has 4,000 bits. How many key bits are needed, and what happens if the key is used for a second message?
4,000 key bits, one per message bit. Reusing the key lets an attacker XOR the two ciphertexts, which cancels the key and leaves the XOR of the two messages, leaking information about both.
C4. A Grover search against a 64-bit key needs about how many iterations?
(π/4) × 2³² = 3.37 × 10⁹ iterations. At one microsecond each that is about 56 minutes in the idealised model, which is why 64-bit keys are not safe against a large quantum machine.
Practice problems
Check yourself
In BB84 with random bases, what fraction of qubits survive sifting?
About 1/2.
What error rate does a full intercept-and-resend attack cause in the sifted key?
25%.
How many test bits make the chance of missing that attack below 10⁻⁶?
0.75ᵏ < 10⁻⁶ gives k > 48, so about 49 or more.
Compute the secret fraction 1 − 2h(Q) for Q = 5%.
h(0.05) = 0.286, so 1 − 0.572 = 0.43.
Alice sends 20,000 qubits, 1,000 are sacrificed for testing after sifting, and Q = 2%. How long is the final key?
Sifted 10,000, minus 1,000 = 9,000, times 0.717 = about 6,450 bits.
Why are the bases announced after Bob has measured?
So an eavesdropper cannot know the basis at the time she measures and must guess.
For E91, what is the best CHSH value with a Werner state of weight 0.8?
2√2 × 0.8 = 2.26.
At what Werner weight does the E91 Bell test stop certifying entanglement?
w = 1/√2 = 0.707.
Name two reasons QKD range is limited.
Photon loss, which grows exponentially with distance, and detector dark counts at low signal rates.
Name one way that post-quantum cryptography differs from QKD.
It runs as software on ordinary computers and offers signatures, while QKD needs special hardware and provides a key.
References and further reading
I opened the abstract of the Bennett–Brassard paper (arXiv 2003.06557), the abstract of Shor and Preskill’s security proof (quant-ph/0003004), the abstract page for Ekert’s 1991 paper (Physical Review Letters 67, 661), and NIST’s August 2024 announcement of the first three post-quantum standards. The Shor–Preskill abstract does not state an error threshold, so the value of about 11% used here is my recollection of the paper’s result and I also verified that the formula 1 − 2h(Q) reaches zero there. The BB84 and eavesdropper results, the sifting example and the key-rate arithmetic are my own simulations and calculations. Attacks on real devices, weak-pulse and decoy-state methods, authentication requirements and the harvest-now-decrypt-later concern are background knowledge that I did not look up in this session.
- Quantum cryptography: Public key distribution and coin tossing (arXiv 2003.06557, C. H. Bennett and G. Brassard) Abstract opened. Single quantum systems, detectable disturbance, key distribution from no shared secret, coin tossing.
- Simple proof of security of the BB84 quantum key distribution protocol (arXiv quant-ph/0003004, P. W. Shor and J. Preskill) Abstract opened. Proof via entanglement purification with CSS codes. The abstract states no error threshold.
- Quantum cryptography based on Bell’s theorem (Physical Review Letters 67, 661 (1991), A. K. Ekert) Abstract page opened. Key distribution using the generalised Bell’s theorem to detect eavesdropping.
- NIST releases first 3 finalized post-quantum encryption standards (NIST, August 13, 2024) Opened. FIPS 203 (ML-KEM), 204 (ML-DSA), 205 (SLH-DSA) and the advice to begin adopting them.
Key terms in the dictionary