Skip to documentation
← Algorithm guides

Algorithm guide · protocol

E91 (Ekert) key exchange

Generate candidate keys from singlet pairs and test measured correlations with a Bell inequality; compare an intercept-resend attack.

Circuit size: 2 qubits per pair

Before you begin

Singlet anticorrelation · CHSH correlations · Sampling and disclosed data

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

Use entangled pairs to form candidate shared key bits and estimate Bell correlations on separately disclosed settings. Explore the effect of an intercept-resend eavesdropper without treating a teaching session as a finished secure key protocol.

2. How it works

A singlet gives opposite bits when both parties measure along the same axis. Bob can invert his bit to agree with Alice. Other axis pairs test correlations that ideal shared entanglement can produce and simple local models cannot.

  1. Distribute fresh singlets

    Prepare one (|01⟩−|10⟩)/√2 per pair.

  2. Choose axes independently

    Alice uses 0°,45°,90° and Bob 45°,90°,135° in the XZ plane.

  3. Classify records

    Equal-axis settings supply key candidates; four disjoint setting cells supply Bell estimates. Other settings are discarded.

  4. Disclose and compare

    Reveal a sample of key positions to estimate QBER, remove disclosed positions, and invert Bob’s candidate bits.

3. The mathematics, one idea at a time

E(α,β)=−cos(α−β)

For a singlet, E is the average product of the two ±1 measurement outcomes. Equal axes give E=−1.

S=E(A1,B1)−E(A1,B3)+E(A3,B1)+E(A3,B3)

For the implemented axes, ideal S=−2√2 and |S|=2√2. Each E must be estimated from its own setting stratum.

QBER = mismatches in disclosed sample / disclosed sample size

Bob’s key bit is 1 XOR his raw measurement bit. An empty sample has no defined QBER.

Work this through by hand

4. One equal-axis pair before a session

Two physical qubits per pair. One pair teaches the key correlation; the session UI requires at least 128 pairs for sampled statistics.

The worked circuit uses Alice A2=45°, Bob B1=45° and Eve off. In the session dialog, start with 128 pairs and inspect individual rounds.

StageCalculation or stateWhat it means
Equal axesα−β=0 ⇒ E=−1Raw bits must disagree.
Possible raw resultsBob|Alice=01 or 10Both have probability 1/2.
Invert BobBob_key=1 XOR Bob_rawThe resulting candidate bit equals Alice’s bit.

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 eventIdeal probabilityInterpretation
0150% idealBob 0, Alice 1; inverted Bob bit is 1.
1050% idealBob 1, Alice 0; inverted Bob bit is 0.

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: E91 pair 1 · A2 B1 · Eve off

  1. Save any current circuit you want to keep, then open the worked example. Loading it does not execute a paid hardware job.
  2. Trace the preparation, main operations and measurements against the worked table. Check the gate editor for controls, targets and angles.
  3. Start with an ideal noiseless simulator compatible with the circuit. Mid-circuit measurement, reset and feed-forward require support from the chosen backend.
  4. 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.
  5. Read the output as described below before changing one setting and repeating. The guide describes the original example; edits can change the answer.
The button opens one teaching transmission or pair, not a complete key session. Use Configure in Algorithms to run the multi-round session, then inspect a round to open its exact setup.

6. Read the output correctly

With Eve off, c1c0 reads Bob|Alice. With Eve on the mapping expands to Bob|Alice|Eve; inspect the round’s labels.

A single pair has no Bell statistic. In a session read all four correlation cells, signed S, |S|, disclosed-sample QBER and remaining candidate strings separately.

Missing Bell strata produce unavailable estimates; a short session’s random |S| is not a security certificate. Authentication, error reconciliation and privacy amplification are outside this demo.

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

  • Do not reuse disclosed test bits in the remaining candidate key.
  • An apparent finite-sample Bell violation is not a complete security proof or a loophole-free device-independent test.

8. Check your understanding

For equal-axis raw bits Alice=0,Bob=1, what are the candidate bits?

Reveal the reasoning

Alice keeps 0; Bob inverts 1 to 0. They agree.

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.

  • E91 pair 1 · A1 B1 · Eve off
  • E91 pair 1 · A1 B2 · Eve off
  • E91 pair 1 · A1 B3 · Eve off
  • E91 pair 1 · A2 B1 · Eve off
  • E91 pair 1 · A2 B2 · Eve off
  • E91 pair 1 · A2 B3 · Eve off
  • E91 pair 1 · A3 B1 · Eve off
  • E91 pair 1 · A3 B2 · Eve off
  • E91 pair 1 · A3 B3 · Eve off

The E91 session has separate round controls and summary statistics. Open Configure in Algorithms for those controls.

Implementation notes

A two-qubit teaching session with independent measurement settings, disjoint Bell disclosures and candidate key positions. Finite-sample Bell violation is not a complete security certificate.

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.