An entangled pair is created imperfect, spent to extend a link, degraded while it waits, and purified before anything can be extracted from it. Scroll, and watch one pair go through that: the fidelity figure is the whole subject.
Illustrative values from one example hop budget. quantumnet computes these from the parameters
you give it, which is the point of the simulator.
Two adjacent nodes generate a Bell pair. No source is ideal: the photons are not perfectly indistinguishable, the detectors have dark counts, and the pair arrives with fidelity just under one.
Everything that follows multiplies against this number, so the first thing the simulator reports is what the source actually delivers rather than what the datasheet claims.
Fidelity 0.990 · one hop, and nothing spent yet
To reach further, an intermediate node performs a Bell-state measurement on one half of each of two pairs. The two outer halves become entangled, and both input pairs are destroyed in the process.
A swap cannot improve fidelity. Each one multiplies the two contributing pairs, so the cost compounds with every repeater between the endpoints.
Fidelity 0.972 · two pairs consumed to make one longer link
Entanglement has to be held while the rest of the route is scheduled. In a memory buffer the state relaxes on T1 and loses phase on T2, and the second is usually the one that ends the route.
This is where a schedule matters more than a shorter path. The time spent standing still can cost more fidelity than an extra hop.
Fidelity 0.918 · below the key threshold
BBPSSW rounds take many weakly entangled pairs and, by measuring some of them, keep the ones that agree. The surviving pair is cleaner; the rest are gone.
Purification is the only step that raises fidelity, and it does so by spending pairs. Whether it is worth the expenditure is a routing decision the simulator makes for you.
Fidelity 0.963 · recovered, at the cost of 256 pairs
The topology layer asks which path clears the fidelity threshold once every swap and every hold on it is accounted for. A route that arrives too degraded to extract a key from is not a route.
# route entanglement across a live mesh export
py -m quantumnet ghost-net --topology mesh.json
{"route": [0, 4, 9, 11], "fidelity": 0.963, "distilled": true, "hops": 3}
Fidelity 0.963 · three hops, distillation applied
A real BB84 exchange runs at the route's noise level. Above the quantum bit error threshold the exchange is aborted and the fidelity was spent for nothing; below it, key material comes out.
# derive key material at the route's fidelity py -m quantumnet qkd-derive --fidelity 0.963 --out key.bin # every protocol, in sequence py -m quantumnet all
Fidelity 0.963 · QBER under 4%, 32 bytes of key
git clone https://github.com/KELLERBABG/QEL
cd QEL
py -m pip install -e ".[dev]"
py -m pytest -q # about 80 seconds, 122 tests