qkdsec 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. qkdsec-0.2.0/.github/workflows/ci.yml +63 -0
  2. qkdsec-0.2.0/.github/workflows/publish.yml +70 -0
  3. qkdsec-0.2.0/.gitignore +38 -0
  4. qkdsec-0.2.0/.readthedocs.yaml +24 -0
  5. qkdsec-0.2.0/LICENSE +201 -0
  6. qkdsec-0.2.0/PKG-INFO +215 -0
  7. qkdsec-0.2.0/README.md +141 -0
  8. qkdsec-0.2.0/docs/api/client.rst +42 -0
  9. qkdsec-0.2.0/docs/api/doctor.rst +34 -0
  10. qkdsec-0.2.0/docs/api/proofs.rst +5 -0
  11. qkdsec-0.2.0/docs/api/sim.rst +12 -0
  12. qkdsec-0.2.0/docs/conf.py +104 -0
  13. qkdsec-0.2.0/docs/guides/async.md +135 -0
  14. qkdsec-0.2.0/docs/guides/doctor.md +123 -0
  15. qkdsec-0.2.0/docs/guides/spec-coverage.md +118 -0
  16. qkdsec-0.2.0/docs/index.md +68 -0
  17. qkdsec-0.2.0/docs/quickstart.md +78 -0
  18. qkdsec-0.2.0/pyproject.toml +103 -0
  19. qkdsec-0.2.0/setup.cfg +4 -0
  20. qkdsec-0.2.0/src/qkdsec/__init__.py +14 -0
  21. qkdsec-0.2.0/src/qkdsec/_cli.py +287 -0
  22. qkdsec-0.2.0/src/qkdsec/client/__init__.py +35 -0
  23. qkdsec-0.2.0/src/qkdsec/client/_types.py +86 -0
  24. qkdsec-0.2.0/src/qkdsec/client/aio.py +236 -0
  25. qkdsec-0.2.0/src/qkdsec/client/errors.py +28 -0
  26. qkdsec-0.2.0/src/qkdsec/client/etsi014.py +327 -0
  27. qkdsec-0.2.0/src/qkdsec/doctor/__init__.py +41 -0
  28. qkdsec-0.2.0/src/qkdsec/doctor/probes.py +642 -0
  29. qkdsec-0.2.0/src/qkdsec/doctor/report.py +244 -0
  30. qkdsec-0.2.0/src/qkdsec/proofs/__init__.py +43 -0
  31. qkdsec-0.2.0/src/qkdsec/proofs/_api.py +25 -0
  32. qkdsec-0.2.0/src/qkdsec/proofs/_types.py +15 -0
  33. qkdsec-0.2.0/src/qkdsec/proofs/channels/__init__.py +6 -0
  34. qkdsec-0.2.0/src/qkdsec/proofs/channels/base.py +17 -0
  35. qkdsec-0.2.0/src/qkdsec/proofs/channels/decoy.py +42 -0
  36. qkdsec-0.2.0/src/qkdsec/proofs/channels/depolarizing.py +12 -0
  37. qkdsec-0.2.0/src/qkdsec/proofs/channels/loss.py +16 -0
  38. qkdsec-0.2.0/src/qkdsec/proofs/decoy_state.py +51 -0
  39. qkdsec-0.2.0/src/qkdsec/proofs/finite_size.py +13 -0
  40. qkdsec-0.2.0/src/qkdsec/proofs/protocols/__init__.py +4 -0
  41. qkdsec-0.2.0/src/qkdsec/proofs/protocols/base.py +20 -0
  42. qkdsec-0.2.0/src/qkdsec/proofs/protocols/bb84.py +32 -0
  43. qkdsec-0.2.0/src/qkdsec/proofs/sdp.py +54 -0
  44. qkdsec-0.2.0/src/qkdsec/sim/__init__.py +18 -0
  45. qkdsec-0.2.0/src/qkdsec/sim/_classical.py +59 -0
  46. qkdsec-0.2.0/src/qkdsec/sim/_qiskit.py +154 -0
  47. qkdsec-0.2.0/src/qkdsec/sim/bb84.py +219 -0
  48. qkdsec-0.2.0/src/qkdsec.egg-info/PKG-INFO +215 -0
  49. qkdsec-0.2.0/src/qkdsec.egg-info/SOURCES.txt +63 -0
  50. qkdsec-0.2.0/src/qkdsec.egg-info/dependency_links.txt +1 -0
  51. qkdsec-0.2.0/src/qkdsec.egg-info/entry_points.txt +2 -0
  52. qkdsec-0.2.0/src/qkdsec.egg-info/requires.txt +60 -0
  53. qkdsec-0.2.0/src/qkdsec.egg-info/top_level.txt +1 -0
  54. qkdsec-0.2.0/tests/client/test_async_etsi014.py +201 -0
  55. qkdsec-0.2.0/tests/client/test_etsi014.py +177 -0
  56. qkdsec-0.2.0/tests/client/test_spec_coverage.py +211 -0
  57. qkdsec-0.2.0/tests/doctor/__init__.py +0 -0
  58. qkdsec-0.2.0/tests/doctor/test_cli.py +178 -0
  59. qkdsec-0.2.0/tests/doctor/test_probes.py +372 -0
  60. qkdsec-0.2.0/tests/doctor/test_report.py +76 -0
  61. qkdsec-0.2.0/tests/proofs/test_bb84_no_loss.py +28 -0
  62. qkdsec-0.2.0/tests/proofs/test_bb84_with_loss.py +48 -0
  63. qkdsec-0.2.0/tests/proofs/test_decoy_state.py +108 -0
  64. qkdsec-0.2.0/tests/proofs/test_finite_size.py +22 -0
  65. qkdsec-0.2.0/tests/sim/test_bb84_classical.py +43 -0
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Tests on Python ${{ matrix.python-version }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.10", "3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+ cache: pip
26
+
27
+ - name: Install package with all extras
28
+ run: |
29
+ python -m pip install --upgrade pip
30
+ pip install -e ".[all,test]"
31
+
32
+ - name: Run tests
33
+ run: pytest -v
34
+
35
+ build:
36
+ name: Build distributions
37
+ runs-on: ubuntu-latest
38
+ needs: test
39
+
40
+ steps:
41
+ - uses: actions/checkout@v4
42
+
43
+ - name: Set up Python
44
+ uses: actions/setup-python@v5
45
+ with:
46
+ python-version: "3.12"
47
+
48
+ - name: Install build tools
49
+ run: |
50
+ python -m pip install --upgrade pip
51
+ pip install build twine
52
+
53
+ - name: Build sdist and wheel
54
+ run: python -m build
55
+
56
+ - name: Check distributions
57
+ run: twine check dist/*
58
+
59
+ - name: Upload artifacts
60
+ uses: actions/upload-artifact@v4
61
+ with:
62
+ name: dist
63
+ path: dist/
@@ -0,0 +1,70 @@
1
+ name: Publish to PyPI
2
+
3
+ # Publishes on tag push (e.g., v0.1.0). Uses PyPI Trusted Publishing (OIDC) —
4
+ # no API tokens stored. Before first use, configure the trusted publisher at:
5
+ # https://pypi.org/manage/account/publishing/
6
+ # with: project=qkdsec, owner=John-Jepsen, repo=qkdsec, workflow=publish.yml.
7
+
8
+ on:
9
+ push:
10
+ tags:
11
+ - "v*"
12
+
13
+ jobs:
14
+ build:
15
+ name: Build distributions
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.12"
25
+
26
+ - name: Install build tools
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install build twine
30
+
31
+ - name: Build sdist and wheel
32
+ run: python -m build
33
+
34
+ - name: Verify distributions
35
+ run: twine check dist/*
36
+
37
+ - name: Verify tag matches package version
38
+ run: |
39
+ TAG="${GITHUB_REF#refs/tags/v}"
40
+ PKG_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
41
+ if [ "$TAG" != "$PKG_VERSION" ]; then
42
+ echo "Tag $TAG does not match package version $PKG_VERSION"
43
+ exit 1
44
+ fi
45
+
46
+ - name: Upload artifacts
47
+ uses: actions/upload-artifact@v4
48
+ with:
49
+ name: dist
50
+ path: dist/
51
+
52
+ publish:
53
+ name: Publish to PyPI
54
+ runs-on: ubuntu-latest
55
+ needs: build
56
+ environment:
57
+ name: pypi
58
+ url: https://pypi.org/p/qkdsec
59
+ permissions:
60
+ id-token: write # Required for PyPI trusted publishing (OIDC)
61
+
62
+ steps:
63
+ - name: Download artifacts
64
+ uses: actions/download-artifact@v4
65
+ with:
66
+ name: dist
67
+ path: dist/
68
+
69
+ - name: Publish to PyPI
70
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,38 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ build/
9
+ dist/
10
+ *.egg-info/
11
+ *.egg
12
+ wheels/
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ venv/
17
+ env/
18
+
19
+ # Testing
20
+ .pytest_cache/
21
+ .coverage
22
+ htmlcov/
23
+ .tox/
24
+
25
+ # Editors
26
+ .idea/
27
+ .vscode/
28
+ *.swp
29
+ *~
30
+
31
+ # OS
32
+ .DS_Store
33
+ Thumbs.db
34
+
35
+ # Sphinx
36
+ docs/_build/
37
+ docs/_static/
38
+ docs/_templates/
@@ -0,0 +1,24 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: ubuntu-24.04
5
+ tools:
6
+ python: "3.12"
7
+
8
+ sphinx:
9
+ configuration: docs/conf.py
10
+ fail_on_warning: false
11
+
12
+ python:
13
+ install:
14
+ - method: pip
15
+ path: .
16
+ extra_requirements:
17
+ - docs
18
+ - async
19
+ - proofs
20
+ - sim
21
+
22
+ formats:
23
+ - htmlzip
24
+ - pdf
qkdsec-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer or hard drive failure, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend, and
172
+ hold each Contributor harmless for any liability incurred by, or
173
+ claims asserted against, such Contributor by reason of your accepting
174
+ any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 John Jepsen
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
qkdsec-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,215 @@
1
+ Metadata-Version: 2.4
2
+ Name: qkdsec
3
+ Version: 0.2.0
4
+ Summary: A developer toolkit for Quantum Key Distribution: numerical security proofs, BB84 simulation, and a full ETSI GS QKD 014 client with built-in conformance probe
5
+ Author-email: John Jepsen <jjepsen15@protonmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/John-Jepsen/qkdsec
8
+ Project-URL: Repository, https://github.com/John-Jepsen/qkdsec
9
+ Project-URL: Issues, https://github.com/John-Jepsen/qkdsec/issues
10
+ Keywords: qkd,quantum,cryptography,bb84,etsi,security
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Security :: Cryptography
20
+ Classifier: Topic :: Scientific/Engineering :: Physics
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: requests>=2.28
25
+ Provides-Extra: proofs
26
+ Requires-Dist: cvxpy>=1.5; extra == "proofs"
27
+ Requires-Dist: numpy>=1.24; extra == "proofs"
28
+ Requires-Dist: scipy>=1.10; extra == "proofs"
29
+ Provides-Extra: proofs-mosek
30
+ Requires-Dist: mosek>=10; extra == "proofs-mosek"
31
+ Provides-Extra: proofs-diff
32
+ Requires-Dist: cvxpylayers>=0.1.6; extra == "proofs-diff"
33
+ Requires-Dist: torch>=2; extra == "proofs-diff"
34
+ Provides-Extra: sim
35
+ Requires-Dist: qiskit>=2.0; extra == "sim"
36
+ Requires-Dist: qiskit-aer>=0.17; extra == "sim"
37
+ Provides-Extra: async
38
+ Requires-Dist: httpx>=0.27; extra == "async"
39
+ Provides-Extra: cli
40
+ Requires-Dist: typer>=0.12; extra == "cli"
41
+ Requires-Dist: rich>=13; extra == "cli"
42
+ Provides-Extra: doctor
43
+ Requires-Dist: httpx>=0.27; extra == "doctor"
44
+ Requires-Dist: typer>=0.12; extra == "doctor"
45
+ Requires-Dist: rich>=13; extra == "doctor"
46
+ Provides-Extra: docs
47
+ Requires-Dist: sphinx>=7; extra == "docs"
48
+ Requires-Dist: furo>=2024.5; extra == "docs"
49
+ Requires-Dist: myst-parser>=3; extra == "docs"
50
+ Requires-Dist: sphinx-autodoc-typehints>=2; extra == "docs"
51
+ Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
52
+ Provides-Extra: all
53
+ Requires-Dist: cvxpy>=1.5; extra == "all"
54
+ Requires-Dist: numpy>=1.24; extra == "all"
55
+ Requires-Dist: scipy>=1.10; extra == "all"
56
+ Requires-Dist: qiskit>=2.0; extra == "all"
57
+ Requires-Dist: qiskit-aer>=0.17; extra == "all"
58
+ Requires-Dist: httpx>=0.27; extra == "all"
59
+ Requires-Dist: typer>=0.12; extra == "all"
60
+ Requires-Dist: rich>=13; extra == "all"
61
+ Provides-Extra: test
62
+ Requires-Dist: pytest>=7; extra == "test"
63
+ Requires-Dist: pytest-asyncio>=0.23; extra == "test"
64
+ Requires-Dist: responses>=0.24; extra == "test"
65
+ Requires-Dist: respx>=0.21; extra == "test"
66
+ Provides-Extra: dev
67
+ Requires-Dist: pytest>=7; extra == "dev"
68
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
69
+ Requires-Dist: responses>=0.24; extra == "dev"
70
+ Requires-Dist: respx>=0.21; extra == "dev"
71
+ Requires-Dist: build>=1.0; extra == "dev"
72
+ Requires-Dist: twine>=5.0; extra == "dev"
73
+ Dynamic: license-file
74
+
75
+ # qkdsec
76
+
77
+ [![PyPI](https://img.shields.io/pypi/v/qkdsec.svg)](https://pypi.org/project/qkdsec/)
78
+ [![Python](https://img.shields.io/pypi/pyversions/qkdsec.svg)](https://pypi.org/project/qkdsec/)
79
+ [![CI](https://github.com/John-Jepsen/qkdsec/actions/workflows/ci.yml/badge.svg)](https://github.com/John-Jepsen/qkdsec/actions/workflows/ci.yml)
80
+ [![Docs](https://readthedocs.org/projects/qkdsec/badge/?version=latest)](https://qkdsec.readthedocs.io/)
81
+ [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
82
+
83
+ A developer toolkit for Quantum Key Distribution: numerical security proofs, BB84 simulation, and an ETSI GS QKD 014 client with a built-in KME conformance probe.
84
+
85
+ `qkdsec` is one library with three subpackages, each addressing a different need:
86
+
87
+ - **`qkdsec.proofs`** — Provable secret-key-rate lower bounds for QKD protocols under given channel models.
88
+ - **`qkdsec.sim`** — Working BB84 simulator (Qiskit and classical backends).
89
+ - **`qkdsec.client`** — Full ETSI GS QKD 014 v1.1.1 client (sync **and** async), plus a `qkdsec doctor` conformance probe that audits any KME.
90
+
91
+ ## What sets it apart
92
+
93
+ - **`qkdsec doctor`** — point it at any KME and get a colored conformance report against ETSI GS QKD 014 v1.1.1. Catches spec violations before they bite production. JSON output for CI; HTML output for sharing.
94
+ - **Full spec coverage** — multicast key delivery (`additional_slave_SAE_IDs`), mandatory/optional vendor extensions, and container-level metadata. Most KME clients only implement the happy path.
95
+ - **Sync and async** — `ETSI014Client` for scripts and `AsyncETSI014Client` for FastAPI / asyncio services. Same surface, share parsers.
96
+ - **Lightweight default** — `pip install qkdsec` brings only `requests`. Heavy deps (CVXPY, Qiskit, httpx, typer) are behind extras.
97
+
98
+ ## Install
99
+
100
+ ```bash
101
+ # ETSI 014 client only (sync, lightweight)
102
+ pip install qkdsec
103
+
104
+ # + async client
105
+ pip install "qkdsec[async]"
106
+
107
+ # + qkdsec CLI and doctor (recommended for ops)
108
+ pip install "qkdsec[doctor]"
109
+
110
+ # + numerical security proofs
111
+ pip install "qkdsec[proofs]"
112
+
113
+ # + BB84 simulator (Qiskit backend)
114
+ pip install "qkdsec[sim]"
115
+
116
+ # Everything
117
+ pip install "qkdsec[all]"
118
+ ```
119
+
120
+ ## Quick start
121
+
122
+ ### Audit a KME in 30 seconds
123
+
124
+ ```bash
125
+ qkdsec doctor https://kme.example.com \
126
+ --slave-sae-id sae-bob \
127
+ --cert alice.crt --key alice.key
128
+ ```
129
+
130
+ ```
131
+ qkdsec doctor — https://kme.example.com
132
+ slave SAE: sae-bob
133
+
134
+ PASS reachability [§5.2] 45 ms
135
+ PASS status_fields [§5.2.2] 12 ms
136
+ PASS enc_keys_get [§5.3] 108 ms
137
+ PASS enc_keys_post [§5.3] 94 ms
138
+ PASS enc_keys_caps [§5.3] 31 ms
139
+ WARN extensions_accepted [§5.3.2] 28 ms
140
+ KME returned HTTP 400 with extension_optional present.
141
+ PASS dec_keys_roundtrip [§5.4] 142 ms
142
+ PASS error_contract_404 [§5.4] 19 ms
143
+ PASS error_contract_400 [§5.3] 18 ms
144
+ PASS latency 14 ms
145
+
146
+ Summary: 9 pass, 1 warn, 0 fail, 0 skip
147
+ Verdict: CONFORMANT (511 ms total)
148
+ ```
149
+
150
+ Exit code 0 if conformant, 1 if not — drop in CI directly.
151
+
152
+ ### Fetch a key (sync)
153
+
154
+ ```python
155
+ from qkdsec.client import ETSI014Client
156
+
157
+ with ETSI014Client(
158
+ "https://kme.example.com",
159
+ client_cert=("alice.crt", "alice.key"),
160
+ ) as kme:
161
+ keys = kme.get_enc_keys("sae-bob", number=1, size=256)
162
+ print(keys[0].key.hex())
163
+ ```
164
+
165
+ ### Fetch a key (async)
166
+
167
+ ```python
168
+ from qkdsec.client.aio import AsyncETSI014Client
169
+
170
+ async with AsyncETSI014Client(
171
+ "https://kme.example.com",
172
+ client_cert=("alice.crt", "alice.key"),
173
+ ) as kme:
174
+ keys = await kme.get_enc_keys("sae-bob", number=1, size=256)
175
+ ```
176
+
177
+ ### Compute a provable key rate
178
+
179
+ ```python
180
+ from qkdsec.proofs import key_rate, BB84, DepolarizingChannel
181
+
182
+ result = key_rate(BB84(), DepolarizingChannel(qber=0.03))
183
+ print(f"Lower bound: {result.r_lower:.4f} bits/pulse")
184
+ ```
185
+
186
+ ### Simulate a BB84 exchange
187
+
188
+ ```python
189
+ from qkdsec.sim import BB84Protocol
190
+
191
+ result = BB84Protocol(error_rate=0.01).run(n_bits=4096)
192
+ if result.secure:
193
+ print(result.final_key.hex())
194
+ ```
195
+
196
+ ## Standards
197
+
198
+ - **ETSI GS QKD 014 v1.1.1** — REST API for key delivery (full coverage)
199
+ - **BB84** (Bennett & Brassard, 1984)
200
+ - **Shor–Preskill** asymptotic key rate
201
+ - **Tomamichel et al.** finite-key correction
202
+ - **Two-decoy state** estimation
203
+
204
+ ## Documentation
205
+
206
+ Full docs at [qkdsec.readthedocs.io](https://qkdsec.readthedocs.io/) — quickstart, doctor guide, async guide, spec coverage walk-through, and API reference.
207
+
208
+ ## Scope and non-goals
209
+
210
+ - **What this is:** a developer-facing library for the three roles above.
211
+ - **What this is not:** a complete QKD network, a hybrid QKD+PQC system, or a vendor-specific SDK. QKD itself requires quantum hardware (single-photon sources and detectors over an optical channel). This library helps you build *around* that hardware.
212
+
213
+ ## License
214
+
215
+ Apache-2.0