🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
đŸ’ŧ Servicesâ„šī¸ Aboutâœ‰ī¸ ContactView Pricing Plansfrom $10

Quantum Cryptography

Quantum ComputingQuantum CryptographyđŸŸĸ Free Lesson

Quantum Key Distribution

Quantum key distribution (QKD) uses quantum mechanics to establish a shared secret key between two parties with information-theoretic security. Unlike classical cryptography, security is guaranteed by the laws of physics, not computational assumptions.

The key insight is that measuring a quantum state disturbs it — an eavesdropper introduces detectable errors.

Two details decide whether the promise holds in practice. First, QKD distributes a key; it does not carry the message, and it still needs an authenticity guarantee on the public classical channel, because an active attacker who can rewrite that channel (the man-in-the-middle) defeats a perfectly good quantum link. Information-theoretic authentication costs a short pre-shared key that is consumed as it is used, so most deployments treat QKD as a key-refresh layer under a conventional authenticated protocol. Second, security proofs are composable: the statement is that the key is indistinguishable from random even when used alongside everything else the parties run, which is why the finite-key terms and abort thresholds matter rather than being academic footnotes.

BB84 Protocol

The BB84 protocol (Bennett & Brassard, 1984) uses two conjugate bases:

Alice's encoding:

  • Bit 0: (Z-basis) or (X-basis)
  • Bit 1: (Z-basis) or (X-basis)

Protocol steps:

  1. Alice sends qubits in random bases
  2. Bob measures in random bases
  3. They publicly compare bases (not results)
  4. Keep only matching-basis rounds -> sifted key
  5. Estimate error rate from public subset
  6. If error rate < threshold, perform error correction and privacy amplification

Security: If Eve intercepts, she introduces error rate >= 25% for random intercept-resend.

That 25% is a derivation, not an assertion. Eve picks her measurement basis at random, so she matches Alice on half the intercepted rounds and resends exactly what she read — those rounds are clean. On the other half she prepares an eigenstate of the wrong basis, and Bob, who measures in Alice's basis, then gets a fair coin flip: errors on half of those. The product is one quarter of intercepted rounds. Scaling it up, an attacker who intercepts 40% of photons pushes the observed error rate to about 10%, which sits just under the usual 11% threshold — the reason deployments use decoy-state intensity checks, monitor count rates, and abort on any upward drift rather than trusting a single aggregate number.

E91 Protocol

The E91 protocol (Ekert, 1991) uses entanglement and Bell's inequality for security:

  1. Source produces Bell pairs and sends one qubit to each party
  2. Alice and Bob measure in random bases
  3. Correlated measurements (same basis) form the raw key
  4. Uncorrelated measurements test Bell's inequality

Security is verified by violating the CHSH inequality:

Any eavesdropping reduces the violation below the quantum maximum .

The three reference values are worth memorising: 2 for any local hidden variable strategy, for ideal quantum mechanics, and roughly 2.3–2.5 for a working optical setup with detector noise. E91 also lets the source be untrusted — a genuinely adversarial source cannot fake a violation while also delivering key bits that pass the Bell test — which is the property that device-independent protocols later built on. The cost is that Bell-test rounds are spent on security rather than on key material, so E91 typically produces less raw key per pair than BB84 for the same photon budget.

Post-Quantum Cryptography

Post-quantum cryptography (PQC) refers to classical algorithms believed to be secure against quantum attacks. NIST has standardized several PQC algorithms:

AlgorithmTypeSecurity Basis
ML-KEM (CRYSTALS-Kyber)Key encapsulationModule LWE
ML-DSA (CRYSTALS-Dilithium)Digital signatureModule LWE
SLH-DSA (SPHINCS+)Digital signatureHash functions
FN-DSA (FALCON)Digital signatureNTRU lattices

These rely on the hardness of lattice problems, hash functions, or coding theory.

The quantum cost of breaking today's schemes gives the migration its urgency. Factoring a 2048-bit RSA modulus with a optimized version of Shor's algorithm has been estimated at roughly 20 million noisy physical qubits running for about eight hours — far beyond current devices, but inside the planning horizon of anyone holding data that must stay secret for twenty years. Grover's algorithm is milder and better understood: it turns an -bit exhaustive search into work, so AES-128 falls to 64-bit security and AES-256 lands at 128. That is the entire reason standards now say to move to 256-bit symmetric keys and to lattice or hash signatures, without waiting for a qubit count.

Quantum Random Number Generation

QRNG produces certifiably random numbers using quantum measurement:

where is the minimum entropy of the quantum source.

Vacuum fluctuation QRNG: measure vacuum noise with homodyne detection Device-independent QRNG: certify randomness from Bell violations

QRNGs are commercially available and used in QKD systems for key generation.

The distinction that matters for auditors is between a physical source and a certified one. A vacuum-fluctuation device is fast — megabits per second — but its security rests on a hardware model of the detector, so the extractor's seed is only as trustworthy as that model. A device-independent QRNG throws the model away and estimates min-entropy directly from a Bell violation, at rates many orders of magnitude lower. Certification standards such as NIST SP 800-90B treat this as a quantification problem: measure the noise, extract conservative min-entropy, and run a seeded extractor, because a raw quantum source feeding a deterministic algorithm without reseeding is a random number generator that eventually repeats.

Quantum-Safe Migration

Organizations must prepare for the quantum threat:

  1. Inventory: catalog all cryptographic assets
  2. Assess: determine quantum vulnerability
  3. Prioritize: critical data with long sensitivity lifetime
  4. Migrate: transition to PQC algorithms
  5. Hybrid: use both classical and PQC during transition

The harvest now, decrypt later threat means encrypted data intercepted today may be decrypted by future quantum computers.

Prioritisation follows data lifetime rather than system criticality. A telemetry feed that stops mattering in a week can be migrated last; certificate chains, firmware signing roots, archival health and financial records, and any link whose confidentiality must survive a decade all sit at the front of the queue, because an attacker can store those ciphertexts now and decrypt them later. Hybrid key exchange — negotiating X25519 together with ML-KEM and mixing both into the shared secret — gives a fallback if a lattice assumption breaks during the transition, and it is the mode most major TLS stacks already ship. What should not be done is waiting for a cryptographically relevant quantum computer to appear: certificate lifetimes, hardware security modules and code-signing roots all take years to rotate.

QKD or PQC: a Decision Table

Both tools answer different questions, and the choice is rarely either/or:

RequirementQKDPQC
Long-term confidentiality of stored ciphertextNo — it protects only the session key in transitYes — this is exactly the harvest-now threat
Distance without trusted relaysLimited to hundreds of km, or twin-field variantsGlobal over any existing IP network
Hardware costDedicated fibre, detectors, lab-grade alignmentSoftware libraries, no new hardware
ThroughputKilobits to megabits per secondLimited mainly by CPU and signature size
Side-channel exposureOptical and detector side channelsLattice implementations have timing and power leakage risks
Standards statusNational and industry schemes, niche deploymentsNIST FIPS 203, 204 and 205 finalised in 2024

The practical rule: PQC is the migration path for everything running over the public internet, and QKD is a specialist tool for point-to-point links where an information-theoretic guarantee justifies the infrastructure — government backbones, financial settlement rings, fibre between two data centres. Organizations that deploy both still need the inventory, because key distribution does nothing for data that was signed with an algorithm an attacker can break.

Python: BB84 Simulation

python
import numpy as np

def bb84_simulation(n=1000, eve_prob=0.0, seed=42):
    # Simulate BB84 and measure the error rate Eve leaves behind.
    rng = np.random.default_rng(seed)
    alice_bits = rng.integers(0, 2, n)
    alice_bases = rng.integers(0, 2, n)
    bob_bases = rng.integers(0, 2, n)
    eve_bases = rng.integers(0, 2, n)
    eve_hit = rng.random(n) < eve_prob

    bob_bits = np.empty(n, dtype=int)
    for i in range(n):
        intercepted = eve_hit[i] and eve_bases[i] != alice_bases[i]
        if intercepted:
            # Eve measured the wrong basis, so what she resends is random.
            bob_bits[i] = rng.integers(0, 2)
        elif bob_bases[i] == alice_bases[i]:
            bob_bits[i] = alice_bits[i]
        else:
            bob_bits[i] = rng.integers(0, 2)

    sifted = alice_bases == bob_bases
    alice_key = alice_bits[sifted]
    bob_key = bob_bits[sifted]
    qber = np.sum(alice_key != bob_key) / max(1, len(alice_key))
    return qber, int(sifted.sum())

for p in (0.0, 0.4, 0.8, 1.0):
    qber, key_len = bb84_simulation(n=20000, eve_prob=p)
    verdict = "accept" if qber < 0.11 else "abort"
    print(f"intercept {p:.1f}: QBER={qber:.4f}  sifted={key_len}  {verdict}")

The error column tracks one quarter of the interception probability: 0.000 with no attacker, about 0.100 when 40% of rounds are intercepted, and about 0.250 at full interception — the analytic 25% target reproduced from the sampling. The last two lines show why 11% is a threshold rather than a suggestion: once the observed error crosses it, the run is aborted and the parties start over with fresh parameters instead of spending error-correction bandwidth on a key that cannot be trusted.

Python: Post-Quantum Sizing

Estimating what the migration costs in bytes on the wire, plus the symmetric-key effect of Grover's search:

python
# (public_key_bytes, signature_or_ciphertext_bytes)
SCHEMES = {
    "RSA-2048 sig":       (256, 256),
    "ECDSA P-256 sig":    (64, 64),
    "ML-DSA-44 sig":      (1312, 2420),
    "ML-DSA-65 sig":      (1952, 3309),
    "SLH-DSA-128s sig":   (32, 7856),
    "ML-KEM-768 ct":      (1184, 1088),
}

def grover_security(key_bits):
    # Grover turns exhaustive search into a square-root cost.
    return key_bits // 2

for name, (pub, extra) in SCHEMES.items():
    overhead = extra / 256
    print(f"{name:20s} pub={pub:5d} B  {extra:5d} B  x{overhead:5.1f} vs RSA-2048")

print()
for cipher, bits in (("AES-128", 128), ("AES-192", 192), ("AES-256", 256),
                     ("ChaCha20", 256), ("3DES", 168)):
    qsec = grover_security(bits)
    verdict = "meets 128-bit target" if qsec >= 128 else ("minimum acceptable" if qsec >= 64 else "retire")
    print(f"{cipher:10s} classical={bits:3d}  quantum={qsec:3d}  {verdict}")

Two planning numbers fall straight out of the printout: an ML-DSA-65 signature is about thirteen times the size of an RSA-2048 signature, so handshake round-trip budgets and MTU assumptions need rechecking, while AES-128 drops to 64-bit security under Grover and fails every baseline policy that AES-256 clears. Signature size is the migration cost most teams discover late; key strength is the one that silently erodes.

Choosing What to Deploy

A short decision sequence for a security team: inventory every certificate, signing key, key-encapsulation and encrypted archive; tag each with how long its confidentiality or authenticity must survive; anything past five years moves to hybrid PQC now; long-lived signatures rotate to ML-DSA or SLH-DSA on the next release cycle; symmetric sessions move to 256-bit keys. QKD joins only where a fibre path exists between two controlled sites and the threat model justifies dedicated hardware. Everything else is an engineering problem — test vectors, interoperability, and rollout speed — not a physics problem.

Common Mistakes

Believing QKD removes the need for authentication

Fix: The public classical channel still needs authentication; information-theoretic auth consumes a pre-shared key, so plan QKD as a key-refresh layer under an authenticated protocol

Waiting for a cryptographically relevant quantum computer before migrating

Fix: Start with lifetime-based prioritisation and hybrid key exchange — certificate chains, HSMs and signing roots take years to rotate, and the ciphertext is already being stored

Assuming AES-128 stays 128-bit secure

Fix: Grover's algorithm halves exhaustive-search security, so standardise on 256-bit symmetric keys to preserve a 128-bit post-quantum margin

Treating signature size as an implementation detail

Fix: ML-DSA-65 signatures run about 3.3 kB against 256 bytes for RSA-2048 — verify handshake budgets, MTU and token formats before rollout

Key Takeaways

  • BB84's intercept-resend defence is arithmetic: Eve matches the basis half the time and errs on half the rest, so 40% interception lands at roughly 10% observed error and full interception at 25%, against a typical 11% abort threshold
  • Post-quantum migration is driven by data lifetime, not by device counts — factoring RSA-2048 is estimated at about 20 million noisy qubits for hours, which is enough to break anything stored longer than that
  • Grover reduces symmetric security by half, so AES-128 falls to 64-bit strength and AES-256 holds the 128-bit target, while lattice signatures trade compactness for roughly thirteen times the bytes of RSA-2048
  • QKD and PQC solve different problems: QKD refreshes keys on a physical link, PQC protects stored ciphertext and runs over the existing internet, so a real plan uses both only where the infrastructure and threat model call for it
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-15

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Quantum Computing Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement