quantum-safe-py 0.3.0__tar.gz → 0.3.2__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 (156) hide show
  1. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.gitignore +5 -0
  2. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/CHANGELOG.md +126 -0
  3. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/CITATION.cff +5 -6
  4. quantum_safe_py-0.3.2/NOTICE +12 -0
  5. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/PKG-INFO +163 -30
  6. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/README.md +160 -28
  7. quantum_safe_py-0.3.2/ROADMAP.md +68 -0
  8. quantum_safe_py-0.3.2/SECURITY.md +75 -0
  9. quantum_safe_py-0.3.2/THIRD_PARTY_LICENSES.md +33 -0
  10. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/compliance.rst +30 -2
  11. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/migrate.rst +3 -0
  12. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/protocols.rst +4 -0
  13. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/changelog.rst +134 -0
  14. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/benchmarks.rst +31 -0
  15. quantum_safe_py-0.3.2/docs/guides/choosing.rst +226 -0
  16. quantum_safe_py-0.3.2/docs/guides/compliance.rst +189 -0
  17. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/concepts.rst +27 -7
  18. quantum_safe_py-0.3.2/docs/guides/cookbook.rst +289 -0
  19. quantum_safe_py-0.3.2/docs/guides/interop.rst +170 -0
  20. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/kem.rst +32 -2
  21. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/migration.rst +32 -8
  22. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/protocols.rst +51 -0
  23. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/quickstart.rst +1 -1
  24. quantum_safe_py-0.3.2/docs/guides/security.rst +137 -0
  25. quantum_safe_py-0.3.2/docs/guides/signatures.rst +272 -0
  26. quantum_safe_py-0.3.2/docs/guides/upgrading.rst +245 -0
  27. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/index.rst +9 -1
  28. quantum_safe_py-0.3.2/licenses/liboqs-LICENSE.txt +25 -0
  29. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/pyproject.toml +13 -2
  30. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/__init__.py +1 -1
  31. quantum_safe_py-0.3.2/src/quantum_safe/_internal/serialization.py +73 -0
  32. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/_version.py +2 -2
  33. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/backends/base.py +39 -0
  34. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/backends/liboqs.py +59 -11
  35. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/backends/rustcrypto.py +5 -5
  36. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/compliance/cnsa2.py +197 -55
  37. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/kem/algorithms.py +1 -1
  38. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/kem/hybrid.py +16 -7
  39. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/__init__.py +2 -1
  40. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/scanner.py +2 -2
  41. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/state.py +175 -30
  42. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/upgrader.py +24 -14
  43. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/protocols/__init__.py +13 -5
  44. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/protocols/envelope.py +166 -41
  45. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/protocols/jwt.py +29 -10
  46. quantum_safe_py-0.3.2/src/quantum_safe/protocols/standard_jwt.py +276 -0
  47. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/protocols/x509.py +15 -6
  48. quantum_safe_py-0.3.2/src/quantum_safe/signatures/_v2.py +231 -0
  49. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/signatures/algorithms.py +5 -5
  50. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/signatures/core.py +187 -25
  51. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/signatures/hybrid.py +68 -9
  52. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/types/kem.py +26 -9
  53. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/types/keys.py +72 -25
  54. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/types/signatures.py +84 -23
  55. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/bench_leakage.py +307 -7
  56. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/integration/test_end_to_end.py +5 -3
  57. quantum_safe_py-0.3.2/tests/interop/test_ts_interop.py +232 -0
  58. quantum_safe_py-0.3.2/tests/interop/test_ts_v2_interop.py +100 -0
  59. quantum_safe_py-0.3.2/tests/interop/vectors/ts_js_vectors.json +110 -0
  60. quantum_safe_py-0.3.2/tests/interop/vectors/ts_v2_vectors.json +150 -0
  61. quantum_safe_py-0.3.2/tests/interop/vectors/ts_vectors.json +393 -0
  62. quantum_safe_py-0.3.2/tests/security/__init__.py +0 -0
  63. quantum_safe_py-0.3.2/tests/security/test_s1_prefix_pinning.py +180 -0
  64. quantum_safe_py-0.3.2/tests/security/test_s2_expected_context.py +116 -0
  65. quantum_safe_py-0.3.2/tests/security/test_s3_hybrid_payload.py +113 -0
  66. quantum_safe_py-0.3.2/tests/security/test_s4_key_loaders.py +135 -0
  67. quantum_safe_py-0.3.2/tests/security/test_s5_typed_errors.py +167 -0
  68. quantum_safe_py-0.3.2/tests/security/test_s6_expected_aad.py +75 -0
  69. quantum_safe_py-0.3.2/tests/unit/__init__.py +0 -0
  70. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_cnsa2_compliance.py +113 -8
  71. quantum_safe_py-0.3.2/tests/unit/test_docs_examples.py +64 -0
  72. quantum_safe_py-0.3.2/tests/unit/test_envelope_v2.py +128 -0
  73. quantum_safe_py-0.3.2/tests/unit/test_kem_combiner_construction.py +37 -0
  74. quantum_safe_py-0.3.2/tests/unit/test_leakage_controls.py +110 -0
  75. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_migrate.py +41 -1
  76. quantum_safe_py-0.3.2/tests/unit/test_migrate_cas.py +176 -0
  77. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_protocols.py +3 -1
  78. quantum_safe_py-0.3.2/tests/unit/test_registry_sizes.py +98 -0
  79. quantum_safe_py-0.3.2/tests/unit/test_serialization_required.py +44 -0
  80. quantum_safe_py-0.3.2/tests/unit/test_sig_v2.py +222 -0
  81. quantum_safe_py-0.3.2/tests/unit/test_sign_raw_fips204.py +106 -0
  82. quantum_safe_py-0.3.2/tests/unit/test_signature_construction.py +40 -0
  83. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_signatures.py +26 -20
  84. quantum_safe_py-0.3.2/tests/unit/test_standard_jwt.py +203 -0
  85. quantum_safe_py-0.3.0/SECURITY.md +0 -55
  86. quantum_safe_py-0.3.0/docs/guides/signatures.rst +0 -165
  87. quantum_safe_py-0.3.0/src/quantum_safe/_internal/serialization.py +0 -102
  88. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.gitattributes +0 -0
  89. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  90. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  91. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.github/pull_request_template.md +0 -0
  92. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.github/workflows/build-wheels.yml +0 -0
  93. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.github/workflows/ci.yml +0 -0
  94. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/.readthedocs.yaml +0 -0
  95. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/CONTRIBUTING.md +0 -0
  96. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/Dockerfile +0 -0
  97. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/LICENSE +0 -0
  98. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/RUNBOOK.md +0 -0
  99. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docker-compose.yml +0 -0
  100. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/Makefile +0 -0
  101. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/_static/.gitkeep +0 -0
  102. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/audit.rst +0 -0
  103. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/backends.rst +0 -0
  104. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/exceptions.rst +0 -0
  105. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/kem.rst +0 -0
  106. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/signatures.rst +0 -0
  107. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/api/types.rst +0 -0
  108. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/conf.py +0 -0
  109. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/audit.rst +0 -0
  110. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/cli.rst +0 -0
  111. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/guides/installation.rst +0 -0
  112. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/make.bat +0 -0
  113. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/docs/production_readiness_rubric.md +0 -0
  114. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/hatch_build.py +0 -0
  115. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/results/BENCHMARKS.md +0 -0
  116. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/_internal/__init__.py +0 -0
  117. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/__init__.py +0 -0
  118. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/auditor.py +0 -0
  119. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/cbom.py +0 -0
  120. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/cli.py +0 -0
  121. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/compliance.py +0 -0
  122. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/policy.py +0 -0
  123. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/audit/sbom.py +0 -0
  124. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/backends/__init__.py +0 -0
  125. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/compliance/__init__.py +0 -0
  126. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/exceptions.py +0 -0
  127. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/kem/__init__.py +0 -0
  128. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/kem/core.py +0 -0
  129. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/cli.py +0 -0
  130. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/migrate/shims.py +0 -0
  131. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/protocols/tls.py +0 -0
  132. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/signatures/__init__.py +0 -0
  133. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/signatures/stateful.py +0 -0
  134. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/src/quantum_safe/types/__init__.py +0 -0
  135. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/__init__.py +0 -0
  136. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/__init__.py +0 -0
  137. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/_oqs_path.py +0 -0
  138. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/bench_kem.py +0 -0
  139. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/bench_signatures.py +0 -0
  140. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/bench_stats.py +0 -0
  141. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/bench/run_stats_demo.py +0 -0
  142. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/conformance/.gitignore +0 -0
  143. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/conformance/__init__.py +0 -0
  144. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/conformance/acvp_kat.py +0 -0
  145. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/conformance/test_acvp_conformance.py +0 -0
  146. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/conftest.py +0 -0
  147. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/integration/__init__.py +0 -0
  148. {quantum_safe_py-0.3.0/tests/unit → quantum_safe_py-0.3.2/tests/interop}/__init__.py +0 -0
  149. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_audit.py +0 -0
  150. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_bench_stats.py +0 -0
  151. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_cbom.py +0 -0
  152. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_cli.py +0 -0
  153. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_exceptions.py +0 -0
  154. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_kem.py +0 -0
  155. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_stateful_lms.py +0 -0
  156. {quantum_safe_py-0.3.0 → quantum_safe_py-0.3.2}/tests/unit/test_types.py +0 -0
@@ -127,3 +127,8 @@ liboqs/
127
127
  # ---------------------------------------------------------------------------
128
128
  site/
129
129
  docs/_build/
130
+
131
+ # local environments and scan output (must never reach an sdist)
132
+ .ci_test_venv/
133
+ audit.json
134
+ audit.sarif
@@ -4,6 +4,132 @@ All notable changes to quantum-safe are documented here.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.3.2] - 2026-10-05
8
+
9
+ ### Fixed
10
+
11
+ - **`Sign.verify_raw()` now verifies standard FIPS 204 ML-DSA signatures.** It verified `len(context) || context || message` under an empty FIPS 204 context, so it rejected every signature made by another implementation, empty context included, although it was documented for exactly that. It now passes the message and the context to ML-DSA.Verify natively. **Behaviour change:** it no longer verifies the raw part of a `Sign.sign()` signature (that signs a different byte string); use `verify()` for those. Reported in GitHub issues #1 and #2.
12
+
13
+ ### Added
14
+
15
+ - `Sign.sign_raw()`: standard FIPS 204 `ML-DSA.Sign` with a native context and FIPS 204's own hedged randomness; returns the bare signature. Tested in both directions against liboqs's FIPS 204 interface for ML-DSA-44/65/87 with empty, short and 255-byte contexts.
16
+
17
+ ### Packaging
18
+
19
+ - The wheels now carry the liboqs licence text (`quantum_safe/_licenses/liboqs-LICENSE.txt`) and `THIRD_PARTY_LICENSES.md`. The compiled liboqs they bundle is MIT-licensed and the licence requires its notice to travel with it; 0.3.1 and earlier did not include it. `licenses/liboqs-LICENSE.txt` is a verbatim copy of upstream's `LICENSE.txt`.
20
+
21
+ ### Documentation
22
+
23
+ - The `Sign` documentation says plainly that `sign()`, its hedging prefix and its context prefix are the library's own construction, not the FIPS 204 interface, and points to `sign_raw` / `verify_raw` for interoperability.
24
+
25
+ ## [0.3.1] - 2026-10-05
26
+
27
+ ### Security
28
+
29
+ - **High: signature prefix forgery, present in every release up to and including 0.3.0** (CWE-347). In hedged mode (the default) the signed bytes are `prefix || message` and the blob stored `len(prefix) || prefix || signature`, but the length byte is not signed and the verifier trusted it. Whoever supplied a signed message could move bytes between message and prefix, so a signature on `M` also verified on a suffix of `M`, without the key (`PAY alice 5 USD
30
+ PAY mallory 1000000 USD
31
+ ` verified as `PAY mallory 1000000 USD
32
+ `). Fixed: the verifier requires the prefix length of its own hedging mode. See `docs/guides/security.rst` and `tests/security/`. **Upgrade; 0.1.0, 0.2.1 and 0.3.0 on PyPI are affected.** The `-v2` format has no prefix at all.
33
+ - Five further issues of lower severity (S2 to S6: context taken from the message, loose hybrid payloads, loose key loaders, untyped parse errors, AAD not checked by the opener) are listed under Fixed and Added below.
34
+
35
+ ### ⚠ Changed behaviour
36
+
37
+ - **Signatures made with `hedged=False` now need a verifier built with
38
+ `hedged=False`.** This applies to `Sign`, `HybridSign`, `JWTVerifier` and
39
+ `HybridCertificateBuilder.verify_cosig` (the last two gain a `hedged`
40
+ argument, default `True`, for tokens and co-signatures made with a
41
+ `hedged=False` signer). Hedged signatures, the
42
+ default, are unaffected. Nothing is re-encoded: every signature 0.3.0
43
+ wrote still verifies on a verifier in the matching mode.
44
+ - **CNSA 2.0: `cnsa2.report()` and `qs-audit cnsa2` now report X25519,
45
+ P-256 and Ed25519 hybrids as `PARTIAL`, not compliant.** NSA's CNSA 2.0 FAQ
46
+ (Dec 2024, Ver. 2.1) says hybrid products are not required and that a
47
+ hybrid should not be used on NSS mission systems except for exceptions NSA
48
+ specifically recommends (it names IKEv2). Every hybrid, including one with
49
+ a P-384 classical half, is therefore `PARTIAL`. Standalone ML-KEM-1024 / ML-DSA-87 are the
50
+ compliant choice; use the new `cnsa2.pqc_kem()` / `cnsa2.pqc_sign()`.
51
+ `cnsa2.enforce()` is unchanged for these hybrids by default (it guards the
52
+ post-quantum parameter set, as in quantum-safe-ts); pass `strict=True` to
53
+ refuse anything `report()` does not call compliant.
54
+
55
+ ### Fixed
56
+
57
+ - The registry listed `BIKE-L1`'s secret key as 3114 bytes; liboqs produces 5223. Found by the registry-size test on a liboqs build that enables BIKE.
58
+ - Signature verification now requires the signature prefix length to match
59
+ the verifier's hedging mode (`hedged=True`, the default: 32 bytes;
60
+ `hedged=False`: 0). Previously the length was read from the signature
61
+ blob, where it is not covered by the signature. Use one hedging mode per
62
+ key.
63
+ - Hybrid signature payloads must contain exactly the four documented
64
+ entries, with the documented types, no duplicate keys and no trailing
65
+ bytes, and their algorithm names must match the verifier's components.
66
+ Previously extra entries were ignored, so different byte strings verified
67
+ as the same signature.
68
+ - Key loaders require the key-type tag (`ktype`) and that it matches the
69
+ loader (`"pub"` for `PublicKey`, `"sec"` for `SecretKey`, in CBOR, PEM and
70
+ bundles), require `kty: "AKP"` for JWKs, and require the version to be an
71
+ integer (`v: true` is no longer read as version 1). Every key this library
72
+ has written carries these fields.
73
+ - Malformed keys (CBOR, PEM, JWK, bundles), signed messages and sealed
74
+ messages raise `KeyParseError` instead of `AttributeError`, `TypeError`,
75
+ `KeyError` or `IndexError`. Field types are checked rather than coerced:
76
+ previously an integer `msg` or `kct` was silently read as that many zero
77
+ bytes, and `SignedMessage` and `SealedMessage` accepted a non-integer
78
+ version.
79
+ - ML-DSA sizes reported by the algorithm registry and both backends were
80
+ round-3 Dilithium sizes, not FIPS 204's: secret keys are 2560 / 4032 / 4896
81
+ bytes (ML-DSA-44 / 65 / 87) and signatures 2420 / 3309 / 4627 bytes. Keys
82
+ and signatures themselves were always correct (they come from liboqs);
83
+ only the reported numbers were wrong.
84
+ - CNSA 2.0 checks validate the whole algorithm name: a hybrid with an
85
+ unrecognised classical half (e.g. `RSA-1024+ML-DSA-87`) is no longer
86
+ reported compliant. `P-384` is removed from `CNSA2_HYBRID_CLASSICAL`
87
+ because `HybridKEM` does not implement it. `cnsa2.describe()` no longer
88
+ says LMS is unimplemented.
89
+ - `Upgrader` no longer reports `backward_compat=True`. The upgraded key is
90
+ `u16(len(classical)) || classical || pqc`, which classical-only software
91
+ cannot parse; the original key is retained inside it, and classical-only
92
+ clients keep using the original key. Documentation that said old X25519
93
+ senders could still encrypt to the upgraded key is corrected.
94
+
95
+ ### Added
96
+
97
+ - **Compare-and-set migration store.** `MigrationStateManager` accepts a store with `compare_and_set(key, expected, value) -> bool` and then commits each transition through one atomic operation on the `<id>_history` entry, so it is safe across processes and hosts with no external lock: exactly one concurrent writer wins and the others get the stale-state `ValueError`. The layout is unchanged (`_current` and `_history`); in this mode the history is authoritative and `_current` is a derived copy, so a crash between the two leaves `_current` one record behind and the manager reads the history. New `MemoryMigrationStore` (a dict with an atomic `compare_and_set`) and `MigrationStateManager.cross_process_safe`. In a test with 16 managers racing on one store, every one of 300 races produced more than one winner on a plain dict and none did with compare-and-set. A plain dict still works as before, with in-process locking only.
98
+ - **Leakage harness controls** (`tests/bench/bench_leakage.py`): a *positive control* (a real decapsulation plus a deliberate secret-dependent delay at several magnitudes, on a random-vs-random baseline, with a 0 µs zero point that must not be flagged) that reports the smallest leak the harness detects, and two *public-data calibrations* that hold the secret fixed or involve no secret at all (same key with fixed vs fresh ciphertext; encapsulation with a fixed vs fresh public key). On the development host at 20,000 iterations, a mean difference of about 1 µs (a 2 µs delay on half the keys, ~7% of the operation) is detected; and the encapsulation calibration, which involves no secret, reproduces the fixed-vs-random decapsulation signal (|t| 15-23 against 21-43), so that signal is not secret dependence. The harness output no longer asserts a mechanism for the signal.
99
+ - **`StandardJwt` (RFC 9964):** ML-DSA JWTs that any compliant JOSE library can verify: `{"alg": "ML-DSA-65", "typ": "JWT"}` header, raw FIPS 204 signature over `header.payload` with an empty context, `AKP` public JWK; strict verification (algorithm must match the key, `crit` refused, canonical base64url signature). Pure ML-DSA only. Verified against quantum-safe-ts's `StandardJwt` in both directions for ML-DSA-44/65/87. Private AKP JWKs (RFC 9964's `priv` is a seed) are not supported because liboqs cannot derive a key pair from a seed. Existing `JWTSigner` tokens are unchanged and still verify only with quantum-safe.
100
+ - **Signature format `-v2`** (`Sign("ML-DSA-65-v2")`, `HybridSign("Ed25519", "ML-DSA-65-v2")`): no prefix or prefix length; the ML-DSA half is plain FIPS 204 with the native context `quantum-safe-sig-v2` over `M2 = len(algo)||algo||len(ctx)||ctx||message`; the classical half signs a labelled `M2` (Ed25519, or raw low-S ECDSA P-256); a hybrid blob is exactly `classical(64) || ML-DSA`. The durable fix for the prefix construction behind the S1 forgery. Byte-compatible with quantum-safe-ts: all eight v2 identifiers verified in both directions. Not the default in this release; versions before this one cannot read it. Adds `sign_native_context` / `verify_native_context` to the backend interface (liboqs implements them).
101
+ - **Envelope v2, the CNSA 2.0 profile:** `Envelope.seal()` of a pure `ML-KEM-1024` public key (no `kem=`) produces a version-2 envelope whose AES-256-GCM key is derived with HKDF-SHA-384 (info `qs-envelope-enc-v2-cnsa2`); hybrid keys still produce version-1 envelopes (HKDF-SHA-256), unchanged. Same bytes as quantum-safe-ts's envelope v2, checked in both directions. `Envelope.open()` now requires the envelope version to match its algorithm (a relabelled version is refused with `UnsupportedAlgorithm`). `SharedSecret.derive_key()` gains `hash_algorithm` (`SHA-256` default, `SHA-384`, `SHA-512`).
102
+ - `Envelope.open(..., expected_aad=...)`: the opener states the AAD it expects and the message's AAD must equal it, otherwise `InvalidTag` is raised. Anyone holding a recipient's public key can seal a message with any AAD and the AAD travels inside the message, so a message sealed for one user opened in another's context. Omitting it while the message carries AAD emits a `DeprecationWarning`; it will be required (default `b""`) in the next minor release. Mirrors `expectedAad` in quantum-safe-ts.
103
+ - A missing `cbor2` now raises `ImportError` at import instead of silently switching to a JSON+base64 format that no CBOR reader (including another installation of this library and quantum-safe-ts) can read. The fallback is removed.
104
+ - `cnsa2.pqc_kem()` and `cnsa2.pqc_sign()`: standalone ML-KEM-1024 and
105
+ ML-DSA-87, the CNSA 2.0-compliant configurations.
106
+ - `cnsa2.report()` gains a key-derivation row (`check_key_derivation`, `include_key_derivation=`): this library's hybrid combiner and v1 envelopes derive keys with HKDF-SHA-256, below the SHA-384/512 CNSA 2.0 requires; a pure ML-KEM-1024 envelope (v2) uses HKDF-SHA-384. Matches quantum-safe-ts. `enforce()` is unaffected.
107
+ - `cnsa2.enforce(..., strict=True)`: also refuse configurations that
108
+ `report()` calls `PARTIAL`, for use as a CI gate.
109
+ - `Sign.verify(..., context=...)` and `HybridSign.verify(..., context=...)`:
110
+ the verifier states the context it expects, and a message carrying any
111
+ other context is rejected (constant-time comparison). The context stored
112
+ in a `SignedMessage` is supplied by whoever supplies the message, so
113
+ without this a signature made for one purpose verified for another.
114
+ `JWTVerifier` and `HybridCertificateBuilder.verify_cosig` now pass their
115
+ own context instead of reading it from the token or bundle.
116
+
117
+ ### Documentation and packaging
118
+
119
+ - Six new guides (upgrading, choosing, cookbook, interoperability, CNSA 2.0 and standards, security model); every Python block in them is executed by `tests/unit/test_docs_examples.py`. README: what's new, a documentation map, corrected thread-safety, hedging and timing text.
120
+ - `NOTICE` and `THIRD_PARTY_LICENSES.md` (the wheels bundle liboqs); `SECURITY.md` updated (supported versions, private reporting, both audits, no independent review).
121
+ - `CITATION.cff` points at arXiv:2605.17061.
122
+ - The README and benchmark text no longer present the 0.3.0 ML-KEM-768 decapsulation latency and CoV figures as normal-path measurements: the old harness shared one liboqs object, so decapsulation exercised the implicit-rejection path. The harness is fixed; the figures are being re-measured.
123
+
124
+ ### Changed
125
+
126
+ - Without a compare-and-set store, `MigrationStateManager.transition()` now writes `<id>_history` before `<id>_current` (it was the reverse), so a crash between the two leaves `_current` behind the audit log instead of the log behind the state. No format change.
127
+
128
+ ### Deprecated
129
+
130
+ - Calling `verify()` without `context=` emits a `DeprecationWarning`. It
131
+ will be required (default `b""`) in the next minor release.
132
+
7
133
  ## [0.3.0] - 2026-09-28
8
134
 
9
135
  ### ⚠ Breaking
@@ -9,9 +9,9 @@ abstract: >
9
9
  authors:
10
10
  - family-names: Shaw
11
11
  given-names: Animesh
12
- email: animeshshaw@pm.me
13
- version: "0.3.0"
14
- date-released: "2026-09-28"
12
+ email: animesh15b@iimk.edu.in
13
+ version: "0.3.2"
14
+ date-released: "2026-10-05"
15
15
  url: "https://pypi.org/project/quantum-safe-py/"
16
16
  repository-code: "https://github.com/AnimeshShaw/quantum-safe-py"
17
17
  license: Apache-2.0
@@ -34,6 +34,5 @@ preferred-citation:
34
34
  - family-names: Shaw
35
35
  given-names: Animesh
36
36
  year: 2026
37
- url: "https://arxiv.org/abs/ARXIV_ID_PLACEHOLDER"
38
- journal: "arXiv preprint arXiv:ARXIV_ID_PLACEHOLDER"
39
- # TODO: replace ARXIV_ID_PLACEHOLDER with the assigned arXiv ID (e.g. 2505.12345)
37
+ url: "https://arxiv.org/abs/2605.17061"
38
+ journal: "arXiv preprint arXiv:2605.17061"
@@ -0,0 +1,12 @@
1
+ quantum-safe-py
2
+ Copyright 2026 Animesh Shaw
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ Binary wheels published on PyPI bundle a compiled copy of liboqs (Open Quantum Safe
7
+ project), which is distributed under its own licence terms. See THIRD_PARTY_LICENSES.md
8
+ for the components, their licences and where to read the upstream texts.
9
+
10
+ This software is not validated under the NIST CAVP or CMVP programmes and carries no
11
+ FIPS 140 certificate. References to FIPS 203, 204 and 205 and to CNSA 2.0 describe the
12
+ algorithms and parameter sets implemented, not a certification.
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: quantum-safe-py
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Production-grade post-quantum cryptography with hybrid KEM, migration tooling, and protocol helpers
5
5
  Project-URL: Homepage, https://github.com/AnimeshShaw/quantum-safe
6
6
  Project-URL: Documentation, https://quantum-safe-py.readthedocs.io/en/latest/
7
7
  Project-URL: Bug Tracker, https://github.com/AnimeshShaw/quantum-safe/issues
8
- Author-email: Animesh Shaw <animeshshaw@pm.me>
8
+ Author-email: Animesh Shaw <animesh15b@iimk.edu.in>
9
9
  License: Apache-2.0
10
10
  License-File: LICENSE
11
+ License-File: NOTICE
11
12
  Keywords: cryptography,dilithium,hybrid,kyber,ml-dsa,ml-kem,post-quantum,pqc,tls
12
13
  Classifier: Development Status :: 3 - Alpha
13
14
  Classifier: Intended Audience :: Developers
@@ -51,10 +52,13 @@ Production-grade post-quantum cryptography for Python. Hybrid KEM, hybrid signat
51
52
 
52
53
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
53
54
  [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](LICENSE)
54
- [![FIPS 203/204/205](https://img.shields.io/badge/NIST-FIPS_203%2F204%2F205-purple.svg)](https://csrc.nist.gov/pubs/fips)
55
+ [![Algorithms: FIPS 203/204/205](https://img.shields.io/badge/algorithms-FIPS_203%2F204%2F205-purple.svg)](https://csrc.nist.gov/pubs/fips)
56
+ [![Not FIPS 140-3 validated](https://img.shields.io/badge/FIPS_140--3-not_validated-lightgrey.svg)](SECURITY.md)
57
+ [![Status: alpha](https://img.shields.io/badge/status-alpha-orange.svg)](ROADMAP.md)
55
58
  [![CI](https://github.com/AnimeshShaw/quantum-safe-py/actions/workflows/ci.yml/badge.svg)](https://github.com/AnimeshShaw/quantum-safe-py/actions/workflows/ci.yml)
56
59
  [![Documentation](https://img.shields.io/readthedocs/quantum-safe-py.svg)](https://quantum-safe-py.readthedocs.io/en/latest/)
57
60
  [![PyPI](https://img.shields.io/pypi/v/quantum-safe-py.svg)](https://pypi.org/project/quantum-safe-py/)
61
+ [![Roadmap](https://img.shields.io/badge/roadmap-0.4.0-blue.svg)](ROADMAP.md)
58
62
  [![arXiv](https://img.shields.io/badge/arXiv-preprint-b31b1b.svg)](https://arxiv.org/abs/2605.17061)
59
63
 
60
64
  ---
@@ -100,11 +104,76 @@ assert shared_secret == ss2
100
104
  signer = HybridSign()
101
105
  kp = signer.generate_keypair()
102
106
  sm = signer.sign(b"important document", kp.secret, context=b"myapp-v1")
103
- signer.verify(sm, kp.public) # raises VerificationError if invalid
107
+ signer.verify(sm, kp.public, context=b"myapp-v1") # raises VerificationError if invalid
104
108
  ```
105
109
 
106
110
  ---
107
111
 
112
+ ## What's new
113
+
114
+ ### 0.3.2
115
+
116
+ - `Sign.sign_raw()` and a standard `Sign.verify_raw()`: plain FIPS 204 ML-DSA with a native
117
+ context, for exchanging signatures with other ML-DSA implementations. Before this,
118
+ `verify_raw()` rejected every standard signature. See [Signatures](docs/guides/signatures.rst).
119
+ - The wheels now carry the liboqs licence text.
120
+
121
+ What is planned next (0.4.0 and beyond) is in the [roadmap](ROADMAP.md).
122
+
123
+ ### 0.3.1
124
+
125
+ 0.3.1 is a security and quality release. **Nothing 0.3.0 wrote stops working**;
126
+ the library now refuses input it should never have accepted and asks verifiers
127
+ to state what they expect. Start with the
128
+ [upgrade guide](docs/guides/upgrading.rst).
129
+
130
+ **Security fixes**
131
+ - **Signature prefix forgery (High; every release up to 0.3.0).** The unsigned
132
+ prefix-length byte let bytes be moved between a signed message and its prefix.
133
+ Verifiers now require the prefix length of their own hedging mode. Advisory:
134
+ [GHSA-wqv6-gm9x-69x8](https://github.com/AnimeshShaw/quantum-safe-py/security/advisories/GHSA-wqv6-gm9x-69x8).
135
+ If you run 0.3.0 or earlier, upgrade.
136
+ - `verify(..., context=...)` and `Envelope.open(..., expected_aad=...)`: the
137
+ verifier states the context or AAD it expects.
138
+ - Strict key and message loaders with one typed error (`KeyParseError`); exact
139
+ hybrid signature payloads.
140
+
141
+ **New**
142
+ - **`-v2` signatures** (`Sign("ML-DSA-65-v2")`, `HybridSign("Ed25519",
143
+ "ML-DSA-65-v2")`): no prefix, FIPS 204 native context, byte-compatible
144
+ with quantum-safe-ts (for plain FIPS 204 interop use `sign_raw`).
145
+ - **Envelope v2**: sealing to a pure `ML-KEM-1024` key derives with HKDF-SHA-384
146
+ (the CNSA 2.0 profile).
147
+ - **`StandardJwt`** (RFC 9964): tokens any JOSE library can verify.
148
+ - **Compare-and-set migration store**: safe across processes, no external lock.
149
+ - A leakage harness with a **positive control** and public-data calibrations.
150
+ - CNSA 2.0 report: every hybrid is `PARTIAL` (NSA's FAQ does not call a hybrid
151
+ compliant); a key-derivation row; `cnsa2.pqc_kem()` / `cnsa2.pqc_sign()`.
152
+
153
+ ---
154
+
155
+ ## Documentation
156
+
157
+ Full documentation: <https://quantum-safe-py.readthedocs.io/en/latest/>.
158
+
159
+ | If you want to... | Read |
160
+ |---|---|
161
+ | Try it in five minutes | [Quick start](docs/guides/quickstart.rst) |
162
+ | Pick the right algorithm, format and token | [Choosing what to use](docs/guides/choosing.rst) |
163
+ | Copy a working recipe (encrypt a file, sign a release, rotate keys...) | [Cookbook](docs/guides/cookbook.rst) |
164
+ | Understand keys, contexts, hedging, formats | [Concepts](docs/guides/concepts.rst) |
165
+ | Upgrade from 0.3.0 | [Upgrading to 0.3.1](docs/guides/upgrading.rst) |
166
+ | Exchange data with Node.js, browsers or other ecosystems | [Interoperability](docs/guides/interop.rst) |
167
+ | Check CNSA 2.0 parameters | [CNSA 2.0 and standards](docs/guides/compliance.rst) |
168
+ | Understand the threat model, report a vulnerability | [Security model](docs/guides/security.rst) |
169
+ | Migrate a fleet of keys | [Migration](docs/guides/migration.rst) |
170
+ | See what is planned | [Roadmap](ROADMAP.md) |
171
+
172
+ The TypeScript counterpart, byte-compatible with this library, is
173
+ [quantum-safe-ts](https://github.com/AnimeshShaw/quantum-safe-ts).
174
+
175
+ ---
176
+
108
177
  ## Installation
109
178
 
110
179
  ### Core (classical crypto only, no PQC backend required)
@@ -162,6 +231,8 @@ recommends hybrid classical + PQC. This library makes hybrid the default so you
162
231
  have to explicitly opt out, not in.
163
232
 
164
233
  ```python
234
+ from quantum_safe import HybridKEM, KEM
235
+
165
236
  # Default: X25519 + ML-KEM-768 (hybrid)
166
237
  kem = HybridKEM()
167
238
 
@@ -177,10 +248,14 @@ kem = HybridKEM(classical="X25519", pqc="ML-KEM-1024")
177
248
  Raw bytes are never returned from key operations. Every output is a distinct type:
178
249
 
179
250
  ```python
180
- kp: KeyPair # contains .public (PublicKey) and .secret (SecretKey)
181
- ct: HybridCipherText # ciphertext — pass to decapsulate()
182
- ss: SharedSecret # 32 bytes — call ss.derive_key() to get AES keys
183
- sm: SignedMessage # message + signature + metadata — self-contained
251
+ from quantum_safe import HybridKEM, HybridSign
252
+
253
+ kem, signer = HybridKEM(), HybridSign()
254
+ kp = kem.generate_keypair() # KeyPair: .public (PublicKey) and .secret (SecretKey)
255
+ ct, ss = kem.encapsulate(kp.public) # HybridCipherText, then SharedSecret (call ss.derive_key())
256
+ sig_kp = signer.generate_keypair()
257
+ sm = signer.sign(b"message", sig_kp.secret, context=b"readme") # SignedMessage: message, signature, metadata
258
+ print(type(kp).__name__, type(ct).__name__, type(ss).__name__, type(sm).__name__)
184
259
  ```
185
260
 
186
261
  This prevents the class of bug where you accidentally pass a `SharedSecret`
@@ -192,6 +267,10 @@ Every key carries its algorithm name, migration state, and supports multiple
192
267
  serialization formats:
193
268
 
194
269
  ```python
270
+ from quantum_safe import HybridKEM
271
+ from quantum_safe.types import PublicKey
272
+
273
+ kp = HybridKEM().generate_keypair()
195
274
  pub = kp.public
196
275
  print(pub.algorithm) # "X25519+ML-KEM-768"
197
276
  print(pub.migration_state) # MigrationState.HYBRID_TRANSITION
@@ -214,7 +293,7 @@ pub4 = PublicKey.from_jwk(jwk)
214
293
 
215
294
  ```python
216
295
  from quantum_safe import HybridKEM
217
- from quantum_safe.protocols import Envelope
296
+ from quantum_safe.protocols import Envelope, SealedMessage
218
297
 
219
298
  # Option 1: Low-level (you manage the shared secret)
220
299
  kem = HybridKEM()
@@ -236,7 +315,11 @@ wire = sealed.to_bytes() # or .to_hex()
236
315
  sealed = SealedMessage.from_bytes(wire) # or .from_hex()
237
316
 
238
317
  # With authenticated metadata (visible but authenticated)
239
- sealed = Envelope.seal(b"payload", pub, aad=b"recipient-id:user-42")
318
+ sealed = Envelope.seal(b"payload", kp.public, aad=b"recipient-id:user-42")
319
+
320
+ # On open, state the AAD you expect: a message sealed for another context
321
+ # (user, record) will not open here. Envelopes do not authenticate the sender.
322
+ plain = Envelope.open(sealed, kp.secret, expected_aad=b"recipient-id:user-42")
240
323
  ```
241
324
 
242
325
  ---
@@ -251,7 +334,7 @@ from quantum_safe.types import SignedMessage
251
334
  signer = HybridSign()
252
335
  kp = signer.generate_keypair()
253
336
  sm = signer.sign(b"document", kp.secret, context=b"myapp-v2-docs")
254
- signer.verify(sm, kp.public) # raises VerificationError if invalid
337
+ signer.verify(sm, kp.public, context=b"myapp-v2-docs") # raises VerificationError if invalid
255
338
 
256
339
  # Hedged mode is on by default — two signings of the same message differ
257
340
  sm1 = signer.sign(b"same", kp.secret)
@@ -278,8 +361,11 @@ See Key Encapsulation section above.
278
361
  ### JWT (PQC-aware)
279
362
 
280
363
  ```python
364
+ from quantum_safe import HybridSign
281
365
  from quantum_safe.protocols.jwt import JWTSigner, JWTVerifier
282
366
 
367
+ keypair = HybridSign().generate_keypair()
368
+
283
369
  # Sign
284
370
  signer = JWTSigner(keypair, issuer="auth.myapp.com")
285
371
  token = signer.sign({"sub": "user123", "role": "admin"})
@@ -329,6 +415,8 @@ cert_pem, cosig_bundle = builder.build()
329
415
  ### Scan a codebase for classical crypto
330
416
 
331
417
  ```python
418
+ import sys
419
+
332
420
  from quantum_safe.migrate import Scanner
333
421
 
334
422
  report = Scanner.scan_directory("./src")
@@ -347,16 +435,25 @@ if report.has_blocking_findings:
347
435
  ### Upgrade an existing key to hybrid
348
436
 
349
437
  ```python
438
+ from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey
439
+ from cryptography.hazmat.primitives.serialization import Encoding, NoEncryption, PrivateFormat, PublicFormat
440
+
350
441
  from quantum_safe.migrate import Upgrader
351
442
 
443
+ # Stand-in for your existing key; in real use, load the raw bytes you already have.
444
+ existing = X25519PrivateKey.generate()
445
+ x25519_private_bytes = existing.private_bytes(Encoding.Raw, PrivateFormat.Raw, NoEncryption())
446
+ x25519_public_bytes = existing.public_key().public_bytes(Encoding.Raw, PublicFormat.Raw)
447
+
352
448
  result = Upgrader.upgrade_kem_key(
353
449
  classical_secret_bytes=x25519_private_bytes, # your existing X25519 key
354
450
  classical_public_bytes=x25519_public_bytes,
355
451
  classical_algorithm="X25519",
356
452
  target_pqc="ML-KEM-768",
357
453
  )
358
- # result.new_keypair contains X25519 + ML-KEM-768
359
- # Old senders using X25519-only can still encrypt to the new public key
454
+ # result.new_keypair contains X25519 + ML-KEM-768. The original X25519 key is
455
+ # retained inside it, but the hybrid key format is not readable by X25519-only
456
+ # senders: keep publishing the original key to them during the transition.
360
457
  print(result.notes)
361
458
  ```
362
459
 
@@ -387,6 +484,8 @@ print(mgr.migration_progress())
387
484
  ### CI audit gate
388
485
 
389
486
  ```python
487
+ import sys
488
+
390
489
  from quantum_safe.audit import Auditor, AuditPolicy
391
490
 
392
491
  # Returns 0 (pass) or 1 (fail) — use directly in CI
@@ -459,8 +558,16 @@ print(report.render())
459
558
  # [FAIL] Signatures ... requires ML-DSA-87
460
559
  # OVERALL: NOT compliant
461
560
 
462
- kem = cnsa2.hybrid_kem() # X25519 + ML-KEM-1024, compliant
463
- signer = cnsa2.hybrid_sign() # Ed25519 + ML-DSA-87, compliant
561
+ kem = cnsa2.pqc_kem() # ML-KEM-1024, compliant
562
+ signer = cnsa2.pqc_sign() # ML-DSA-87, compliant
563
+
564
+ # Hybrids carry the required PQC parameter set but are reported PARTIAL:
565
+ # Hybrids carry the required PQC parameter set but are PARTIAL: NSA's CNSA 2.0
566
+ # FAQ says hybrids are not required and should not be used on NSS mission
567
+ # systems except for exceptions NSA specifically recommends (IKEv2 is the one
568
+ # it names).
569
+ kem = cnsa2.hybrid_kem() # X25519 + ML-KEM-1024, PARTIAL
570
+ signer = cnsa2.hybrid_sign() # Ed25519 + ML-DSA-87, PARTIAL
464
571
  ```
465
572
 
466
573
  Or from the CLI: `qs-audit cnsa2` (defaults to checking this library's own
@@ -472,7 +579,10 @@ defaults — which fail, on purpose, so you see it immediately).
472
579
  published test vectors — ML-KEM keyGen (75/75, exact `ek`+`dk`), ML-KEM
473
580
  encapsulation (75/75), ML-KEM decapsulation (30/30, including
474
581
  implicit-rejection cases), ML-DSA sigVer (45/45, both acceptance and
475
- rejection). No other Python PQC library publishes this.
582
+ rejection). Testing against ACVP vectors is not unique to this library
583
+ (noble-post-quantum, for one, does too; see
584
+ [the production-readiness rubric](docs/production_readiness_rubric.md)); what
585
+ is reported here is the result for this library's own backend.
476
586
 
477
587
  **This is conformance evidence, not a CAVP or CMVP validation** — validation
478
588
  is performed by an accredited laboratory and produces a certificate; nothing
@@ -558,15 +668,22 @@ the result, preventing timing oracles that would reveal which component failed.
558
668
  The underlying liboqs implementations are designed for constant-time operation.
559
669
 
560
670
  Two distinct measurements back this, and it matters which one you're reading:
561
- CoV (Coefficient of Variation, ~3.9% for ML-KEM-768 decapsulation in ENV-2,
562
- within the AES-256-GCM noise floor) is computed with the secret held fixed, so
563
- it shows timing *stability under repetition* — not secret independence.
564
- A separate fixed-vs-random test with a random-vs-random control (needed to
565
- rule out measurement artifacts — see `docs/guides/benchmarks.rst`) shows no
566
- key-dependent timing in ML-KEM decapsulation, the implicit-rejection path, or
567
- the hybrid combiner, across two environments. Neither is a formal
568
- constant-time proof; `dudect` or `ct-verif` against the compiled backend
569
- would be. See the companion timing-leakage paper for the full methodology.
671
+ CoV (Coefficient of Variation) is computed with the secret held fixed, so it
672
+ shows timing *stability under repetition* — not secret independence.
673
+ A separate fixed-vs-random test needs controls to be interpretable: a
674
+ random-vs-random control, and (new in 0.3.1) a public-data calibration and a
675
+ positive control that reports the smallest deliberate leak the harness
676
+ detects. Without them, a fixed-vs-random signal can be a measurement artifact:
677
+ on the development host, encapsulation, which uses no secret, reproduces the
678
+ fixed-vs-random decapsulation signal. See `docs/guides/benchmarks.rst`.
679
+ The harness screens for gross secret dependence; it is not a formal
680
+ constant-time proof (`dudect` or `ct-verif` against the compiled backend
681
+ would be), and everything is measured through the Python binding.
682
+
683
+ > The ML-KEM-768 decapsulation CoV and latency figures published for 0.3.0
684
+ > were measured with a harness defect that made decapsulation exercise the
685
+ > implicit-rejection path (see `CHANGELOG.md`). The harness is fixed and the
686
+ > figures are being re-measured; do not rely on the old decapsulation row.
570
687
 
571
688
  ### Serialization safety
572
689
 
@@ -577,11 +694,14 @@ rejected immediately to prevent version-rollback attacks.
577
694
 
578
695
  ### Thread safety
579
696
 
580
- `MigrationStateManager.transition()` holds a per-key `threading.Lock` across
581
- the read-check-write critical section. For multi-process deployments (e.g.
582
- multiple Gunicorn workers sharing a Redis store) you must additionally acquire
583
- an external distributed lock (Redis `SETNX`, database row-level lock) on the
584
- `key_id` before calling `transition()`.
697
+ `MigrationStateManager` is safe across processes and hosts when its store has
698
+ a `compare_and_set(key, expected, value) -> bool` method (`MemoryMigrationStore`
699
+ is the in-process reference; `manager.cross_process_safe` tells you which mode
700
+ you are in): exactly one concurrent writer wins, with no external lock. With a
701
+ plain dict it holds a per-key `threading.Lock`, which covers threads in **one
702
+ process only**; with several workers sharing a store (e.g. Gunicorn and Redis)
703
+ you must hold an external distributed lock on the `key_id` around
704
+ `transition()`. See `docs/guides/migration.rst`.
585
705
 
586
706
  ### Hedged signing
587
707
 
@@ -590,6 +710,19 @@ is prepended before signing. This prevents fault-injection attacks that have
590
710
  been demonstrated on lattice signatures in lab conditions. Opt out with
591
711
  `hedged=False` only if you have a specific need for deterministic signatures.
592
712
 
713
+ **A verifier accepts only signatures made in its own hedging mode** (the prefix
714
+ length is not covered by the signature, so it is not read from it). Build the
715
+ verifier with the signer's `hedged` value and use one mode per key. The `-v2`
716
+ signature format has no prefix and no hedging mode.
717
+
718
+ ### Verify with the context you expect
719
+
720
+ `verify(sm, public_key, context=...)` and `Envelope.open(sealed, secret_key,
721
+ expected_aad=...)` state what the verifier expects. The context and AAD carried
722
+ inside a message come from whoever supplied it, so without these a signature
723
+ made for one purpose verifies for another and a ciphertext sealed for one
724
+ record opens for another. Omitting them is deprecated in 0.3.1.
725
+
593
726
  ### Hybrid mode rationale
594
727
 
595
728
  ML-KEM was standardized in 2024. Hybrid mode (X25519 + ML-KEM-768) means: