qkd
A QKD protocol simulator with the hardware in the loop, over a native Rust core.
Documentation: https://plutoniumm.github.io/qkd/
Excess noise ξ is an output: qkd.budget assembles it from hardware parameters.
On a Gaussian-modulation q.Link, pilot-assisted DSP runs over simulated symbols,
and its residual phase error is a ξ term. Once frames are estimated, the key rate
comes from Alice and Bob's estimates, not from the simulated channel.
Install
pip install qkd
- Python 3.11 or later.
numpyis a runtime dependency. - Wheels: macOS arm64 and x86_64, Linux
manylinux_2_28aarch64 and x86_64, Windows x86_64. Other platforms install from the sdist, which needs a Rust toolchain. - From source: Getting Started.
Example
Neither T nor ξ is stated. The pilot DSP runs over 200 000 simulated symbols;
its residual phase error is the only ξ row.
import qkd as q
link = q.Link(
modulation=q.GaussianModulation(v_a=4.0),
channel=q.Fiber(length=15.0, alpha=0.2),
alice=q.Alice(
laser=q.Laser(linewidth=10e3),
pilots=q.Pilots(power_db=12.0, freq=180e6),
symbol_rate=100e6,
),
bob=q.Bob(
detector=q.Heterodyne(eta=0.6, v_el=0.1, trusted=True),
lo=q.LocalLO(linewidth=10e3),
),
dsp=q.DSP(phase=q.PilotPhase(), block=32),
security=q.FiniteSize(beta=0.95, n=1e9),
)
res = link.run(symbols=200_000, seed=7)
res.dsp.v_err # 0.0075742 rad^2, what the pilot estimator left
res.budget.total # 0.0304118 SNU at the channel input, derived from it
res.est.xi # 0.0142987 what Alice and Bob estimate from the samples
res.key_rate # 0.0285553 bit/symbol
One block per protocol family and per layer: Usage by example.
Coverage
- Continuous variable: Gaussian modulation (homodyne, heterodyne), M-PSK discrete modulation, CV-MDI.
- Discrete variable: BB84 with weak coherent pulses and decoy states, six-state, SARG04, B92, DPS, RRDPS, COW, COW′, MDI-BB84, mode pairing, BBM92, E91, loss-tolerant source flaws.
- Beside the protocols: trusted-node networks (
q.Network), Gaussian and truncated-Fock states (qkd.gaussian,qkd.fock), implementation attacks (qkd.attacks), reconciliation and privacy amplification (qkd.reconcile), composable ε accounting (qkd.security). - Entry point and security analysis per family: Protocol coverage.
- Excluded by decision: twin-field, phase-matching and sending-or-not-sending; satellite and free-space channels; qudit protocols.
Before quoting a number
qkd.gaussianandqkd.fockuse ħ = 1, vacuum variance 1/2.qkd.budget,q.Linkandq.Swapuse shot-noise units, vacuum variance 1. Conventionsthermal_lossand a nonzeroq.Channel(xi=…)requireref="input"orref="output".ξat Bob isTtimesξat the channel input.q.Homodyneandq.Heterodynedefault totrusted=True:etaandv_elare Bob's, not Eve's. Security- A mismatched
q.Linktree constructs, then raises on the firstrun(),measure(),claim()orexplain(), naming the restriction. Refusals - Most
q.Linkfamilies are asymptotic. Finite-key routes per family: Security. - Agreement with a paper is graded on two axes: reproducing what it computed, and reproducing what it measured at a stated number of fitted parameters. Validation
- The pilot DSP chain simulates heterodyne detection only.
- Every
q.Linkrun is CPU.backend_info()reports the backend that resolved, not the one a run used. GPU kernels
License
MIT
Release files for qkd 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qkd-0.2.0.tar.gz | 428.6 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| qkd-0.2.0-cp311-abi3-win_amd64.whl | CPython 3.11 | abi3 | Windows x86-64 | Details |
| qkd-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ x86-64 | Details |
| qkd-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl | CPython 3.11 | abi3 | Linux glibc 2.28+ ARM64 | Details |
| qkd-0.2.0-cp311-abi3-macosx_11_0_x86_64.whl | CPython 3.11 | abi3 | macOS 11.0+ x86-64 | Details |
| qkd-0.2.0-cp311-abi3-macosx_11_0_arm64.whl | CPython 3.11 | abi3 | macOS 11.0+ ARM64 | Details |
Total release size: 14.3 MB
Release files / qkd-0.2.0.tar.gz
| Download URL | qkd-0.2.0.tar.gz |
|---|---|
| Size | 428.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
deec64ae90fce96b81eda4a17c02cc2ca3fb4c7a85371b0d9ccae1d1db8cba07
|
|
BLAKE2b-256 checksum How to use checksums |
708127ba99220c448aa1eb9e88e562fd0fd555de5293d060372afc363f21e45b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qkd-0.2.0-cp311-abi3-win_amd64.whl
| Download URL | qkd-0.2.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
de5a72042d4fb635133b5f58628d850cf4fcb501f1775fcc59c314d462b3a2dc
|
|
BLAKE2b-256 checksum How to use checksums |
ae1fdf941a3b6b51c635af31ee8f94358f4ecb0d41d790fdfea21a72e402101c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qkd-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | qkd-0.2.0-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
205db0cfb2708d496c9e5d1f20b10ea2bca9485ca76cad5b52aee1024f307be3
|
|
BLAKE2b-256 checksum How to use checksums |
8f7a662baef60235c52181a876481f663802caaebca792c2e11ecfacc1bcca91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qkd-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | qkd-0.2.0-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
3e9c40b655e13afc33bc41336a111bc99f9fd6d4ad1295d4dedd73ada2b8f239
|
|
BLAKE2b-256 checksum How to use checksums |
27a1553e1b4679629b6a48cc0b3d2c445dcab25b13b779eccbd28257133077c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qkd-0.2.0-cp311-abi3-macosx_11_0_x86_64.whl
| Download URL | qkd-0.2.0-cp311-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 2.7 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf8168a7b138cbb765bd82a38746a38ecbf22be2a207fa95c5219f88160dc530
|
|
BLAKE2b-256 checksum How to use checksums |
fea9b54b6232a0df233236a3236978af31fc8186678dd83927acc4cbb9c9d325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / qkd-0.2.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | qkd-0.2.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
34ccdfd8c1587cfb89fff9c37d7c5bd802cd47effa2f3cee8984ddc9e1aa0490
|
|
BLAKE2b-256 checksum How to use checksums |
77d1268429844b5600c2f5903e9b5d4fa2195badcff47a435539adcbd130d30b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|