QKD-BB84 Post Processing Protocol
1. Introduction
This document describes the classical post-processing pipeline that runs after the BB84 quantum exchange: the Cascade error-reconciliation protocol, the Error Verification stage, and Privacy Amplification (PA-SHA256). It follows the same documentation structure used for the BB84 protocol guide – protocol overview, step-by-step procedure, worked parameter tables, and the full message sequence – so the two documents can be read side by side.
For reference, the BB84 setup that feeds into this pipeline is shown below – the network layout (Map View) and the optical block diagram (Component View) used in the BB84 module.
(a) Map View |
(b) Component View |
Note: no interface screenshots were provided for the Cascade module itself, so the panel/field-level UI description used in the BB84 guide is not reproduced here. This document covers the protocol logic, parameters, and message flow only. If a Cascade-module UI (fields, tabs, RUN button, etc.) exists in the simulator, share screenshots and this document can be extended to match it in the same way the BB84 guide was.
2. How This Differs from BB84
BB84 |
Cascade / Error Verification / PA |
|
|---|---|---|
Purpose |
Quantum key generation: transmit and measure single photons to produce a raw, sifted key and an initial QBER estimate. |
Classical post-processing of that sifted key: correct residual bit errors, verify the correction, and compress the key to remove any information an eavesdropper may hold. |
Channel used |
Quantum channel (photon transmission) + classical channel (basis reconciliation). |
Classical channel only – no photons are exchanged; only checksums, indices, tags, and seeds. |
Input |
Randomly chosen bits/bases, laser and detector parameters. |
The sifted key and QBER value already produced by BB84 (frame length = BB84 key length). |
Core mechanism |
Basis matching + statistical QBER estimation to detect eavesdropping. |
Iterative block-checksum comparison (Cascade) to locate and fix errors, followed by tag comparison (Error Verification) and hashing (Privacy Amplification) to remove Eve’s residual information. |
Output |
A sifted key with an estimated QBER; accepted or discarded based on a threshold. |
A shorter, error-corrected and privacy-amplified final secret key, ready for use. |
Detects eavesdropping via |
QBER exceeding the threshold. |
Does not itself detect eavesdropping – it assumes BB84 already validated the channel, and instead cleans up the key BB84 produced. |
In short: BB84 decides whether a usable key exists; Cascade and its downstream stages turn that raw key into a final, secure one.
3. Cascade Protocol Overview
Cascade is an interactive, multi-pass error-correction protocol. Alice and Bob repeatedly partition their (supposedly identical) sifted key into blocks, compare block checksums, and use binary search to locate and correct any bit where their keys disagree – without revealing the bit values themselves, only parity/checksum information.
3.1 Procedure
Alice sends QBER and frame length to Bob. (Frame length is equivalent to the key length produced by BB84.)
Both sides calculate the block size for the first iteration:
block size (b) = 0.73 / QBER
Both sides generate, in sequence, an index -> block ID table, a block ID -> index table, and a checksum table, so every bit is addressed consistently.
Alice sends her checksums to Bob.
Bob compares his checksums against Alice’s:
Case 1 – Mismatch: Bob tells Alice which checksum(s) didn’t match. Both sides then run an interactive binary search within the affected block to locate and correct the wrong bit.
Case 2 – Match: Both sides proceed directly to the next iteration.
Before each subsequent iteration, both sides shuffle the block-ID-to-index mapping (and the corresponding bits) using the same seed, so blocks are re-partitioned differently each pass.
The block size for each subsequent iteration is recalculated as:
block size = b x 2^(pass id - 1)
Shuffling and bit correction happen between iterations, and addressing (index-to-block-ID, block-ID-to-index, checksum) is recomputed on the frame length (i.e., the current key) at the start of each pass.
3.2 Worked Example
The following illustrates three Cascade passes over the same 16-bit sifted key, with block size doubling each iteration as blocks are shuffled and re-partitioned.
Bit string used in all three iterations:
Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Bit |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
Iteration 1 – block size = 2
Bits |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Index -> Block ID |
0 |
0 |
1 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
6 |
7 |
7 |
Block ID -> Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Initial Checksum Table |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
1 |
Iteration 2 – block size = 4
Bits |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Index -> Block ID |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
2 |
2 |
2 |
2 |
3 |
3 |
3 |
3 |
Block ID -> Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Initial Checksum Table |
1 |
1 |
0 |
0 |
Iteration 3 – block size = 8
Bits |
1 |
1 |
1 |
0 |
0 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
0 |
1 |
0 |
1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Index -> Block ID |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
Block ID -> Index |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
Initial Checksum Table |
0 |
0 |
Shuffling and correction happen between the iterations shown above; the checksum table entries shown are the “initial” (per-block, pre-correction) values for that pass.
4. Message Sequence
The full pipeline runs as four back-to-back message exchanges: BB84 -> Cascade -> Error Verification -> Privacy Amplification.
4.1 BB84 (Quantum Exchange)
Direction |
Message |
Payload |
|---|---|---|
Alice -> Bob |
BEGIN PHOTON PULSE |
Frequency of the laser, light time, start time of laser emission, wavelength of photon |
Alice -> Bob |
PHOTONS |
Wavelength, encryption type (polarization), quantum state (coefficient + basis) |
Bob -> Alice |
RECEIVED QUBITS (scheduled EPP) |
Message only |
Alice -> Bob |
BASIS LIST |
Basis list |
Bob -> Alice |
MATCHING INDICES |
Matching indices, Bob’s QBER-sample bits, index of those bits, Qbitz – sent only when the number of matching indices equals the extra key size |
Bob qbits – list of random bits sent for QBER calculation.
Index of the qbits – the corresponding indices of those bits.
Qbitz – the number of bits to be sent for QBER estimation.
At this point, both parties remove the bits used for the QBER sample from their key, keeping them as a separate reference set. Alice then calculates QBER, Throughput, and Latency.
4.2 Cascade
Direction |
Message |
Payload |
|---|---|---|
Alice -> Bob |
START CASCADE |
QBER, frame length (= BB84 key length) |
At (last message send time + CC_delay), both sides begin calculating checksums.
Direction |
Message |
Payload |
|---|---|---|
Alice -> Bob |
|
Checksum table, key number |
Bob compares Alice’s checksums against his own.
If matched:
Direction |
Message |
Payload |
|---|---|---|
Bob -> Alice |
KEY IS VALID |
Key number, Bob’s QBER-sample bits, index of those bits, Qbitz,
|
If not matched – interactive binary search:
Direction |
Message |
Payload |
|---|---|---|
Bob -> Alice |
SEND FOR BINARY |
Key number, pass ID, block ID, start, end = (start + end) / 2 |
Bob -> Alice |
SEND FOR BINARY |
Key number, pass ID, block ID, start = (start + end) / 2, end |
Alice -> Bob |
RECEIVE FOR BINARY |
Key number, pass ID, block ID, start, end = (start + end) / 2, checksum |
Alice -> Bob |
RECEIVE FOR BINARY |
Key number, pass ID, block ID, start = (start + end) / 2, end, checksum |
Bob checks whether Alice’s checksum matches his own for each half:
If matched:
Direction
Message
Payload
Bob -> Alice
KEY IS VALID
Bob’s QBER-sample bits, index of those bits, Qbitz,
int(bob qbits), positionIf not matched:
If
end - start = 1: flip the bit (flipping performed in decimal).Otherwise: repeat SEND FOR BINARY with the halved range, continuing until
end - start = 1.
Once all checksums have been matched and every error corrected, both
parties remove the flipped-bit positions (pos) from their key. Alice
recalculates QBER – these particular bits are not removed from the key
at this stage, since they are retained as a confirmation check.
4.3 Error Verification
Error Verification begins at Alice’s side once the Cascade exchange completes:
The key is divided into 16 chunks.
Each chunk is split into two subparts, which are XORed together.
The XOR result is again split in two and XORed, and this halving-and-XOR process repeats until the resulting length reaches 128 bits.
Poly1305 is applied to this 128-bit value, producing a tag for each chunk.
(Note: in the current implementation, Poly1305 is applied directly to each chunk rather than to the XOR-reduced value, since XOR reduction carries a slight residual possibility of error.)
Direction |
Message |
Payload |
|---|---|---|
Alice -> Bob |
ERROR VERIFICATION |
Key number, tags |
On receipt, Bob runs the same Error Verification process on his own key and compares his tags against Alice’s.
Direction |
Message |
Payload |
|---|---|---|
Bob -> Alice |
ERROR CORRECTION (all tags matched) |
Key number, chunks not matched (= 0), seed value for SHA |
Bob -> Alice |
ERROR CORRECTION (mismatch found) |
Key number, chunks not matched, seed value for SHA |
Bob removes any chunk whose tag didn’t match before sending his message; Alice removes the corresponding chunk(s) after receiving Bob’s message – keeping both keys aligned.
4.4 Privacy Amplification – PA-SHA256
Privacy Amplification compresses the verified key to eliminate any partial information Eve may have gained, using the seed exchanged in the Error Correction message.
Let k be the size of the key input to PA.
If k < 256:
k' = k + seed length(128 bits, derived fromseed_bob).Apply SHA-256 if the leading bit
k'(0) = 1, or SHA3-256 ifk'(0) = 0, tok'.
If k > 256:
Divide
kinto 256-bit blocks.Apply SHA separately to each block.
Concatenate the SHA outputs of all blocks into
k''.Truncate
k''to the required final key size (e.g., for a 520-bit target, take the first 520 bits ofk'').
The output of this step is the final, secret, usable key.
5. End-to-End Pipeline Summary
BB84 (quantum exchange, sifting, QBER sample removed)
|
v
Cascade (iterative block-checksum error correction, binary search, bit flips)
|
v
Error Verification (16-chunk XOR reduction -> Poly1305 tags -> chunk comparison)
|
v
Privacy Amplification (PA-SHA256 / SHA3-256 compression)
|
v
Final secure key
6. Suggested Metrics to Record per Run
Quantity |
Description |
|---|---|
Frame length (BB84 key length) |
Input length to Cascade, equal to the sifted key from BB84. |
Initial QBER |
QBER value passed into Cascade at START CASCADE. |
Block size per pass |
|
Number of Cascade passes |
How many iterations ran before all checksums matched. |
Bits corrected (flipped) |
Count of positions corrected via binary search across all passes. |
Chunks failing Error Verification |
Number of the 16 chunks removed due to Poly1305 tag mismatch. |
Key length after Error Verification |
Key length once mismatched chunks are dropped. |
Final key length after PA |
Length of the key after SHA-256/SHA3-256 compression and truncation. |

