Quantum Key Distribution (QKD) uses the principles of quantum mechanics to enable two parties to produce a shared secret key guaranteed to be secure by the laws of physics — not computational difficulty.

The No-Eavesdropping Theorem

QKD security rests on two quantum principles:

  1. No-cloning theorem: An eavesdropper cannot copy unknown quantum states
  2. Measurement disturbance: Measuring a quantum state inevitably disturbs it

Any attempt to intercept quantum-encoded key bits introduces detectable errors.

The BB84 Protocol

Proposed by Charles Bennett and Gilles Brassard in 1984, BB84 works as follows:

Alice sends qubits to Bob, randomly choosing between two bases:

  • Rectilinear basis ($+$): $|0\rangle$, $|1\rangle$
  • Diagonal basis ($\times$): $|+\rangle = \frac{|0\rangle + |1\rangle}{\sqrt{2}}$, $|-\rangle = \frac{|0\rangle - |1\rangle}{\sqrt{2}}$

Bob measures each qubit, randomly choosing a basis. They publicly compare bases (not results). When bases match, their bits are guaranteed to agree — this becomes the secret key.

If Eve intercepts, she must guess the basis. Wrong guesses introduce a 25% error rate, which Alice and Bob detect.

The E91 Protocol

Artur Ekert’s 1991 protocol uses entangled pairs:

  1. A source creates Bell pairs $|\Phi^+\rangle = \frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$
  2. Alice and Bob each receive one qubit from each pair
  3. They measure in randomly chosen bases
  4. Security is verified by checking Bell inequality violations

The beauty: if a Bell inequality is violated, the key is secure. If it’s not violated, Eve is present.

Information-Theoretic Security

The key rate for BB84 with error rate $e$ is:

$$R = 1 - 2H(e)$$

where $H(e) = -e\log_2(e) - (1-e)\log_2(1-e)$ is the binary entropy. If $e > 11\%$, no secure key can be extracted.

Real-World QKD

QKD is already deployed:

  • Fiber networks: Toshiba, ID Quantique operate commercial QKD systems over 100+ km fiber
  • Satellite QKD: China’s Micius satellite demonstrated intercontinental QKD in 2017
  • Quantum internet: The EU’s EuroQCI initiative is building a continent-wide quantum network
import numpy as np

def simulate_bb84(n_bits=1000, eve_present=False):
    """Simulate the BB84 QKD protocol."""
    # Alice prepares random bits and bases
    alice_bits = np.random.randint(0, 2, n_bits)
    alice_bases = np.random.randint(0, 2, n_bits)  # 0=Z, 1=X

    # Eve intercepts (if present)
    if eve_present:
        eve_bases = np.random.randint(0, 2, n_bits)
        # Eve measures and resends
        intercepted = np.where(
            eve_bases == alice_bases,
            alice_bits,
            np.random.randint(0, 2, n_bits),
        )
    else:
        intercepted = alice_bits

    # Bob measures
    bob_bases = np.random.randint(0, 2, n_bits)
    bob_bits = np.where(
        bob_bases == alice_bases,
        intercepted,
        np.random.randint(0, 2, n_bits),
    )

    # Sifting: keep only matching bases
    matching = alice_bases == bob_bases
    sifted_alice = alice_bits[matching]
    sifted_bob = bob_bits[matching]

    # Error rate
    errors = np.sum(sifted_alice != sifted_bob)
    error_rate = errors / len(sifted_alice) if len(sifted_alice) > 0 else 0

    return {
        'sifted_key_length': len(sifted_alice),
        'error_rate': error_rate,
        'secure': error_rate < 0.11,
    }

# No eavesdropper
result = simulate_bb84(eve_present=False)
print(f"No Eve: error rate = {result['error_rate']:.3f}, secure = {result['secure']}")

# With eavesdropper
result = simulate_bb84(eve_present=True)
print(f"With Eve: error rate = {result['error_rate']:.3f}, secure = {result['secure']}")

Post-Quantum Cryptography vs. QKD

While post-quantum cryptography (PQC) uses mathematical problems believed to be hard for quantum computers, QKD offers information-theoretic security — it doesn’t rely on computational assumptions at all. Both approaches will likely coexist in a quantum-secure future.