Algorithm guide · protocol
BB84 key exchange
Prepare, measure in a random basis, sift, and watch an eavesdropper show up in the error rate.
Circuit size: 1 signal qubit per transmission
Z and X bases · Measurement disturbance · Basis sifting
Review quantum fundamentals →Notation used in this lesson
- |ψ⟩ and ⟨ψ|
- A state vector (ket) and its conjugate transpose (bra). ⟨a|b⟩ is their inner product.
- α, β and i
- α and β are complex amplitudes; i²=−1. A probability is the squared magnitude |α|².
- XOR, · and ⊗
- XOR adds bits modulo two. In s·x, multiply corresponding bits and XOR them. ⊗ combines registers or operations on different wires.
- U†, Σ and Tr
- U† is the adjoint (inverse for a unitary). Σ sums terms. Tr is the matrix trace, the sum of diagonal entries.
- Probability, shots and angles
- Ideal probabilities describe the model; measured shot frequencies fluctuate. Angles inside trigonometric expressions are in radians unless explicitly labeled turns.
1. The problem
Distribute candidate secret bits by preparing random qubit states and measuring in independently chosen bases. Detect disturbance through a disclosed comparison sample, rather than by assuming every transmission should agree.
2. How it works
If Bob chooses Alice’s preparation basis, his bit is correct ideally. If he chooses the other basis, it is random and that position is discarded. An intercept-resend Eve who guesses bases introduces errors even among retained matching-basis positions.
Alice prepares
Choose a random bit and Z or X basis: 0/1 or +/−.
Optional Eve
Measure in Eve’s guessed basis and resend her measured eigenstate.
Bob measures
Choose an independent basis and record the result.
Sift and test
Publicly compare bases, retain matching ones, reveal a sample to estimate errors and remove those disclosed bits.
3. The mathematics, one idea at a time
Same-basis states are orthogonal; different-basis overlaps have squared magnitude 1/2.
This 25% is an ideal ensemble expectation, not an exact error count in every finite session.
Work this through by hand
4. One signal qubit: Alice sends 0 in Z
One qubit is the minimum per transmission. The session offers 32,128 or 512 transmissions; begin with 32 and Eve off.
The worked circuit is Alice bit 0, Alice basis Z, Bob basis Z and no Eve. For session exploration, inspect a selected transmission to load its precise circuit.
| Stage | Calculation or state | What it means |
|---|---|---|
| Prepare | |0⟩ | No X or H is required for Alice’s 0/Z state. |
| Bob measures Z | P(Bob=0)=1 | A matching-basis noiseless transmission agrees. |
| Contrast | Bob measuring X gives 0 or 1 with probability 1/2 | That basis-mismatched position is discarded during sifting. |
Expected outcomes for this example
These are ideal predictions for the stated configuration, not a result already measured by your browser. Rows describing alternative modes or combined events are labeled explicitly.
| Outcome or event | Ideal probability | Interpretation |
|---|---|---|
| 0 | 100% ideal for this no-Eve Z/Z transmission | Bob’s recorded bit. |
5. Load the worked example in Composer
The worked example can use smaller or simpler inputs than the gallery defaults. The button below loads the exact circuit used in this lesson.
Selected variant: BB84 transmission 1 · Alice 0/Z · Bob Z · Eve off
- Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
- Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
- Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
- Inspect the live preview. For a recorded experiment, open Execute, set the available backend options and shots, and Run. Sign in when prompted to retain it in My Jobs.
- Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.
6. Read the output correctly
The single-transmission c0 records Bob. With Eve present, the circuit adds Eve’s record; use the displayed mapping.
The session log distinguishes basis mismatches, public test disclosures and remaining candidates. Full sifted mismatch rate is a teaching diagnostic; public-sample QBER is the observable estimate used for testing.
A Composer rerun samples fresh outcomes. Loading a historical transmission reproduces its setup, not necessarily its previous random bit.
Authentication, reconciliation and privacy amplification are not implemented as a full secure-key pipeline.
A bit label is a register value; its bar height is a probability or count. For S shots and observed count k, the sampled frequency is k/S. A typical sampling scale for probability p is √[p(1−p)/S]; this is not a strict error bound. Finite samples do not have to match the ideal percentages exactly.
7. Common mistakes & limits
- Mismatched-basis errors are expected and are not the QBER denominator after sifting.
- A finite sample with zero observed errors does not prove Eve was absent or that the candidate key is secure.
8. Check your understanding
Why must disclosed comparison bits be removed?
Reveal the reasoning
They have been revealed on the public classical channel and are no longer secret candidates.
9. Further study
The lesson’s register mappings, supported inputs and loadable example follow Quantket’s implemented circuit. A reference may use different wire names, bit order or resource conventions.
Gallery reference: defaults, definitions & implementation notes
Available example inputs
Choose a named circuit variant in Algorithms. Each variant fixes its preparation, operations and measurement mapping; the worked variant above is one of them.
- BB84 transmission 1 · Alice 0/Z · Bob Z · Eve off
The BB84 session has separate round controls and summary statistics. Open Configure in Algorithms for those controls.
Read your saved result
Check the submitted circuit, measured register and execution settings in Run details. Exact results give computed probabilities; sampled results show frequencies from the recorded shots. Edited circuits and noise can change the expected outcome. The algorithm label records the circuit's origin; it does not certify an edited circuit or a measured result.