Skip to content

About

CNSA 2.0 Hybrid PQC (SecP384r1MLKEM1024 + ML-DSA-87) + ETSI GS QKD 014 Transport, Active Downgrade Firewall, CBOM Gate, Wycheproof/NIST KATs, TEC 91011:2026 dudect & Tamarin Prover Formal Model

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

QuantumGuard (quantumguard-cnsa2 v0.2.0)

PyPI version CI & Tamarin Verification CNSA 2.0 CBOM Gate Python 3.11+ License: MIT Standards: CNSA 2.0 / FIPS 203 & 204

CNSA 2.0 Hybrid Post-Quantum Transport (SecP384r1MLKEM1024 + ML-DSA-87) + ETSI GS QKD 014 Key Engine, Active Downgrade Firewall, Side-Channel & Tamarin Formal Verification Suite

QuantumGuard v0.2.0 Architecture

quantumguard-cnsa2 (imported in Python as quantumguard, CLI entrypoint quantumguard) is an open-source, pip-installable cryptographic transport and verification toolkit backed by OpenSSL 4.0 / cryptography>=50.0.0. It combines wire-level CNSA 2.0 hybrid post-quantum key exchange, pluggable ETSI GS QKD 014 key delivery (live REST HTTP KME or pooled finite-key LEO Decoy-BB84 simulation), an active downgrade & asymmetric-abort firewall (NSA PP-26-4956), CycloneDX v1.6 Cryptographic Bill of Materials (CBOM) CI gating (NSA CNSA 2.0, US EO 14412, India CERT-In / DST CII), and three non-AI ground-truth assurance pillars (Project Wycheproof + NIST ACVP FIPS 203/204 KATs, India TEC 91011:2026 / dudect Welch's t-test timing detector, and a Tamarin Prover symbolic handshake model).


Why QuantumGuard? (Threat Model & Design Overview)

Risk Addressed QuantumGuard Control Module
Harvest-Now-Decrypt-Later (CRQC) Hybrid RFC 10024 SecP384r1MLKEM1024 (1665 B) + ETSI GS QKD 014 mixed via transcript-bound HKDF-SHA384 quantumguard/crypto_core.py
Algorithm Downgrade & Key-Swap Attacks Rejects legacy curves/suites, stripped key shares (< 1665 B), forged ML-DSA-87 signatures, and qkd_key_id swaps/replays (PP-26-4956) quantumguard/guard.py
Pre-Auth Memory DoS & Asymmetric Aborts 64 KiB pre-auth frame ceiling (PRE_AUTH_MAX_FRAME_BYTES) + CLIENT_FINISH / SERVER_COMMIT_ACK commitment barrier before AppData quantumguard/tunnel.py
Timing Side Channels (TEC 91011:2026) Branchless GF(2^128) WegmanCarterMAC, hmac.compare_digest key comparison, constant-time ML-KEM-1024 implicit rejection + statistical dudect verifier quantumguard/sidechannel.py
Classical-EC Compromise in Symbolic Analysis Dolev-Yao Tamarin model proving session_key_secrecy even when classical ECDH P-384 ephemeral scalars leak formal/quantumguard_handshake.spthy
Legacy Cryptography Sprawl in CI/CD AST + multi-language CBOM scanner failing CI (exit 1) on prohibited standalone classical crypto and emitting CycloneDX v1.6 JSON quantumguard/cbom_scanner.py

Architecture

flowchart LR
    Cli["Client / Local TCP Proxy<br/>(quantumguard connect)"] -->|"CLIENT_HELLO<br/>RFC 10024 1665 B + Key_ID + ML-DSA-87"| FW["Active Downgrade Firewall<br/>(guard.py / PP-26-4956)"]
    KMS["ETSI GS QKD 014 Provider<br/>(REST HTTPS or LEO Decoy-BB84)"] -->|"256-bit K_QKD + key_ID"| Cli
    KMS -->|"key_ID lookup (no replay)"| Srv
    FW -->|"Inspect Suite / Nonce / Key_ID / Sig"| Srv["Tunnel Server<br/>(quantumguard serve)"]
    Srv -->|"SERVER_HELLO + HKDF-SHA384<br/>Transcript & Key_ID Bound"| Cli
    Cli -->|"CLIENT_FINISH<br/>ML-DSA-87 + GF(2^128) WC MAC"| Srv
    Srv -->|"SERVER_COMMIT_ACK Barrier"| Cli
    Cli <-->|"AES-256-GCM AEAD + Epoch Ratchet"| Srv
    Repo["Source & Configs<br/>(.py .c .cpp .h .js .ts .yml .conf Dockerfile)"] -->|"AST + Regex Audit"| CBOM["CycloneDX v1.6 CBOM Gate<br/>(quantumguard audit / GitHub Action)"]
Loading

Verified Cryptographic & Protocol Components

  1. Real FIPS 203 / FIPS 204 / RFC 10024 Core (quantumguard/crypto_core.py)

    • ML-KEM-1024: ek = 1568 B, ct = 1568 B, ss = 32 B
    • ML-DSA-87: pk = 2592 B, sig = 4627 B
    • ECDH P-384 uncompressed X9.62 point (97 B, 48 B shared secret) combined into 1665 B SecP384r1MLKEM1024 shares (group_id = 0x11ED)
    • Domain-separated HKDF-SHA384 binding K_QKD || K_MLKEM1024 || K_P384 to SHA384(transcript) || suite_id || qkd_key_id (mitigating Dependent-Key attacks)
    • AES-256-GCM record layer with strict monotonic (epoch, seq) replay rejection, HKDF-SHA384 key ratcheting, and GF(2^128) $\varepsilon$-$\text{ASU}_2$ WegmanCarterMAC for handshake commit frames
    • Pluggable ETSI GS QKD 014 KeyProvider: REST/HTTPS Etsi014Client (/enc_keys, /dec_keys) and SimulatedLEOBB84Provider
  2. Active Downgrade & Asymmetric-Abort Firewall (quantumguard/guard.py)

    • Blocks stripped PQ shares (< 1665 B), legacy/forbidden cipher suites (X25519, P-256, RSA-2048, TLS 1.2, X25519MLKEM768 under strict CNSA 2.0), corrupted ML-DSA-87 signatures, qkd_key_id swaps/replays, stale nonces, and premature aborts prior to SERVER_COMMIT_ACK
    • Built-in 6-vector Red-Team fuzz suite (quantumguard attack-test)
  3. Low-Latency Binary Wire Tunnel & TCP Proxy (quantumguard/tunnel.py)

    • TCP_NODELAY=1, compact QG2B binary handshake (18,154 B total wire bytes vs 30,809 B JSON in v0.1.0), PRE_AUTH_MAX_FRAME_BYTES = 65_536 DoS ceiling, cached AESGCM instances, and writelines scatter/gather 128 KiB record streaming (> 200 MB/s local loopback echo)
    • TunnelServer (echo or decrypted TCP --upstream forwarding) and TunnelClient (one-shot echo probe or local port-forwarding proxy bridge via --listen)
  4. Automated CycloneDX v1.6 CBOM Scanner (quantumguard/cbom_scanner.py)

    • AST-based Python analysis (recognizing standalone vs. hybrid ECDH-P384 + ML-KEM-1024) plus context-aware rules for .c, .cpp, .h, .js, .ts, .yml, .yaml, .conf, and Dockerfile
    • Returns exit code 1 on CNSA 2.0 policy violations and 0 when compliant
  5. CLI, FastAPI Security Console & ETSI GS QKD 014 Mock KME (quantumguard/cli.py, dashboard.py, kme_mock.py)

    • Interactive web UI (/) and JSON endpoints (/api/fips-selftest, /api/handshake, /api/attack-test, /api/audit-snippet) with HTTP security headers & 256 KiB payload limits
    • Live ETSI GS QKD 014 v1.1.1 HTTP KME server (quantumguard kme-mock) exposing GET /api/v1/keys/{slave_sae_id}/status, POST /api/v1/keys/{slave_sae_id}/enc_keys, and single-use POST /api/v1/keys/{master_sae_id}/dec_keys (404/410 replay & TTL rejection)
  6. Non-AI Cryptographic Assurance Stack (tests/test_wycheproof_and_kat.py, quantumguard/sidechannel.py, formal/)

    • Project Wycheproof v1 + NIST ACVP KATs (tests/vectors/): SHA-256 verified official JSON suites (316 AES-GCM, 1,047 P-384 ECDH, 83 HKDF-SHA-384, 25/55 FIPS 203 ML-KEM-1024 KeyGen/encapDecap, 25/60 FIPS 204 ML-DSA-87 KeyGen/SigVer) plus FIPS 203 implicit rejection and 1-bit signature flip tests
    • TEC 91011:2026 / dudect Timing Detector (quantumguard sidechannel-check): time.perf_counter_ns() interleaved Class 0/1 Welch's t-test harness with pooled 5%–95% outlier cropping across WegmanCarterMAC.verify, HandshakeFirewall.constant_time_key_id_equal, and ML-KEM-1024 decapsulation (|t| < 4.5 pass threshold) + in-place mutable buffer scrubber zeroize_bytes
    • Tamarin Prover Symbolic Model (formal/quantumguard_handshake.spthy): Dolev-Yao + classical CRQC ECDH P-384 oracle model with 4 formal lemmas (executable, session_key_secrecy, injective mutual_authentication, commit_barrier_consistency), wired into Ubuntu 24.04 GitHub Actions CI
  7. Space QKD & Erasure-Aware QEC Benchmark (benchmarks/satqkd_erasure_bench.py)

    • Finite-key Decoy-BB84 LEO downlink budget (500 km orbit, 15°–85° elevation)
    • Explicitly separates Regime I circuit_level_pauli_stim rotated surface code (d=3, 5) gate-noise sweeps from Regime II code_capacity_memory_hold_erasure (0% vs 90% heralded memory-hold erasure conversion comparing Surface-d5 vs BB-qLDPC-[[144,12,12]] via ldpc.BpOsdDecoder, reporting both block_ler and per_logical_qubit_ler = 1 - (1 - block_ler)**(1/k))

Installation

Requires Python 3.11+ (Python 3.13.3 Windows and 3.13.18 Ubuntu verified). Note that because quantumguard is already occupied on PyPI, the distribution package is named quantumguard-cnsa2, while Python imports (import quantumguard) and the CLI (quantumguard) stay unchanged:

# Install core package from PyPI:
pip install quantumguard-cnsa2

# Or include QEC / Sat-QKD simulator extras (stim, pymatching, ldpc, numpy, scipy):
pip install "quantumguard-cnsa2[bench]"

# Or install from GitHub source with development & QEC benchmark extras:
git clone https://github.com/Runtime-Slayers/QuantumGuard.git
cd QuantumGuard
pip install -e ".[dev,bench]"

# Build distribution wheel + source tarball (dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl):
python -m build

# Or run the FastAPI security console inside Docker (port 7860):
docker build -t quantumguard-cnsa2:0.2.0 .
docker run -p 7860:7860 quantumguard-cnsa2:0.2.0

Quickstart

Use quantumguard (or python -m quantumguard):

1. Run Encrypted Tunnel Proxy

# Terminal 1: Start CNSA 2.0 + ETSI 014 server forwarding decrypted TCP to local service 127.0.0.1:9000
python -m quantumguard serve --listen 127.0.0.1:8443 --upstream 127.0.0.1:9000

# Terminal 2: Open local plain TCP bridge 127.0.0.1:7000 -> encrypted tunnel -> 127.0.0.1:8443
python -m quantumguard connect --peer 127.0.0.1:8443 --listen 127.0.0.1:7000

Or run a one-shot encrypted echo handshake:

python -m quantumguard serve --listen 127.0.0.1:8443
python -m quantumguard connect --peer 127.0.0.1:8443 --message "CNSA 2.0 telemetry test"

2. Run 1,000-Attack Red-Team Downgrade Test

python -m quantumguard attack-test --spawn-local --count 1000

3. Run CycloneDX CBOM Compliance Audit

python -m quantumguard audit . --output cbom.json

4. Launch Mock ETSI GS QKD 014 KME, Timing Side-Channel Check, Socket Bench & Security Console

# Start live ETSI GS QKD 014 v1.1.1 HTTP Mock KME server:
python -m quantumguard kme-mock --host 127.0.0.1 --port 8443

# Run TEC 91011:2026 / dudect timing side-channel verification (2,500 samples/class):
python -m quantumguard sidechannel-check
python -m quantumguard sidechannel-check --json

# Benchmark binary CNSA 2.0 handshakes & 128 KiB AES-256-GCM loopback echo:
python -m quantumguard bench --handshakes 50 --payload-mb 16 --chunk-kb 128

# Launch interactive FastAPI console:
python -m quantumguard demo --host 127.0.0.1 --port 8080

5. Run Wycheproof / NIST KATs, LEO Sat-QKD Benchmark & Tamarin Formal Model

# Wycheproof v1 + NIST ACVP FIPS 203/204 KATs + dudect sensitivity + Tamarin CI structural check:
python -m pytest tests/test_wycheproof_and_kat.py -v

# Full 42-test suite (including Hypothesis & Schemathesis ASGI OpenAPI fuzzing):
python -m pytest -v

# LEO Sat-QKD & Erasure-Aware QEC benchmark:
python benchmarks/satqkd_erasure_bench.py --output benchmarks/results.json
python benchmarks/satqkd_erasure_bench.py --fast

# Tamarin Prover (Linux/Docker/WSL2 — runs automatically on ubuntu-latest CI):
docker run --rm -v "${PWD}/formal:/work" infsec/tamarin-prover:latest --prove /work/quantumguard_handshake.spthy

Measured Verification & Benchmark Results (v0.2.0)

All metrics below were measured locally on Windows 11 (AMD64, Python 3.13.3, cryptography 50.0.0 / OpenSSL 4, stim 1.16.0, pymatching 2.4.0, ldpc 2.4.1):

Transport, Firewall & Assurance Gates (Latest Observed Post-Edit Runs)

Metric Latest Measured Result (v0.2.0)
ML-KEM-1024 Sizes (verify_fips_sizes) ek = 1568 B, ct = 1568 B, ss = 32 B
ML-DSA-87 Sizes (verify_fips_sizes) pk = 2592 B, sig = 4627 B
RFC 10024 SecP384r1MLKEM1024 Wire Share 1665 B (97 B P-384 + 1568 B ML-KEM-1024)
Live Binary Handshake (quantumguard bench, 50 runs) Mean 14.763 ms, p95 26.016 ms, 18,154 B wire total (chunk_kb=128; prior pre-assurance sample: 10.854 ms mean / 16.160 ms p95)
Live AES-256-GCM Echo (16.0 MB, chunk_kb=128) 0.084 s round-trip (189.47 MB/s; prior sample: 0.078 s / 205.80 MB/s)
Red-Team Firewall (attack-test --spawn-local --count 1000) 1000 / 1000 blocked in 8.55 s (0 bypasses across all 6 binary vectors)
CBOM Audit (quantumguard audit .) 20 files: 43 compliant assets, 0 violations (exit 0); RSA-2048 fixture: exit 1
Wycheproof & NIST ACVP KATs (test_wycheproof_and_kat.py) 316 AES-GCM + 1,047 P-384 ECDH + 83 HKDF-SHA-384 + 25/10 FIPS 203 + 25/30 FIPS 204 vectors (100% PASS)
Timing Side-Channel (quantumguard sidechannel-check --json) TEC 91011:2026 / dudect (2,500 samples/class, 5%-95% crop): wegman_carter_mac_verify |t|=1.8944, firewall_qkd_key_id_compare |t|=0.0 (raw=0.1178), mlkem1024_decapsulation |t|=0.3854 -> COMPLIANT (PASS)
Formal Tamarin Model (formal/quantumguard_handshake.spthy) Tamarin 1.12.0 (Maude 3.5.1) PASS (22.02s, Ubuntu 24.04 CI): executable (18 steps), session_key_secrecy (10 steps), mutual_authentication (71 steps), commit_barrier_consistency (10 steps) — CI Run
Static & Dependency Security (bandit, ruff, semgrep, pip-audit) bandit: 0 issues (3,798 LOC, 0 #nosec); ruff: 0 issues; semgrep: 0 findings (156 rules / 21 targets); pip-audit: 0 CVEs across 40 quantumguard closure packages (385 unrelated global env CVEs)
Full Test & Fuzz Suite (pytest -v, Hypothesis + Schemathesis) 42 passed in 80.25s on Ubuntu 24.04 CI (115.17s local Windows; 0 failed, 0 skipped)
Packaging (python -m build / pip wheel) dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl & .tar.gz (quantumguard-cnsa2 on PyPI)

Cryptographic Assurance Ledger & Verbatim Re-Check Outputs

Everything delivered in the QuantumGuard v0.2.0 cryptographic assurance upgrade and the exact observed outputs for independent re-check are preserved below.

1. Project Wycheproof v1 & NIST ACVP FIPS 203/204 Vector Manifest (tests/vectors/SHA256SUMS.txt)

985e5ecc172e181eaf49e89508b9470dcf478002eb7e8559c707eb42dc97dfe7  aes_gcm_test.json
25a9c41573dbea97c5b4be2dd00369fa68dc37ac8f41807d8e16226d188ec6a7  ecdh_secp384r1_test.json
69ff6ea3657bb9c1b8cdffbbb4e7832353d08fd15c0d9997b03f7a6b180e3678  hkdf_sha384_test.json
2ce955e45ed66b87abdab56f25d28e8665035c123a85eb556685411355d189ec  nist_fips203_mlkem1024_encapdecap.json
e47bf2d00d8ca63baf3cac3430e2177454fa53c7511e3afe8a656e209c4cbac7  nist_fips203_mlkem1024_keygen.json
4c92b74f21ef0abfa610766fc7204b6cf56bfbf95026e3650ed140f748456458  nist_fips204_mldsa87_keygen.json
e542a23ce10d1ffa3cdc2fc1e1ee06a2852cb6fdc07e22cc897e9aa40a8c6f01  nist_fips204_mldsa87_sigver.json

Observed Edge-Case & Conformance Findings (test_wycheproof_and_kat.py):

  • Wycheproof AES-GCM (316 / 316): 202 valid exact decryptions, 81 invalid tags/AAD rejected (InvalidTag / ValueError), 33 out-of-range IV lengths (< 8 B or > 128 B, including 0 B) deterministically rejected (ValueError) by OpenSSL SP 800-38D bounds. For all 256-bit key + 96-bit nonce vectors wrapped in AES256GCMChannel, directional AAD (c2s vs s2c) blocked self-reflection and 1-bit ciphertext tamper.
  • Wycheproof ECDH P-384 (1,047 / 1,047): 771 / 771 valid exact shared-secret matches, 46 / 46 invalid rejected, 230 acceptable handled (1 accepted, 229 rejected). Raw X9.62 points (97 B) extracted from invalid SPKIs (InvalidCurveAttack, ModifiedPublicPoint, WeakPublicKey, WrongCurve), infinity (0x00 * 97), and compressed prefix 0x02 all raised ValueError/CryptoEngineError inside responder_encapsulate_hybrid. Note: 6 UnnamedCurve SPKIs (tcId 792, 793, 798, 799, 801, 803) modify ASN.1 curve order/cofactor/prime while keeping an on-curve P-384 (x, y) coordinate; stripping ASN.1 leaves a valid P-384 point, which is why ASN.1/SPKI validation rejects 46 / 46. Separately, FIPS 203 ByteDecode_12 coefficient bounds (< q = 3329) permit 0x00 * 1568 syntactically in MLKEM1024PublicKey.from_public_bytes.
  • Wycheproof HKDF-SHA-384 (83 / 83): 80 valid exact OKMs + 3 SizeTooLarge rejected (ValueError).
  • NIST ACVP FIPS 203 ML-KEM-1024: 25 / 25 deterministic from_seed_bytes(d + z) KeyGen ek byte-exact matches + 10 / 10 encapsulationKeyCheck matches + FIPS 203 §7.3 implicit rejection verified (decapsulate(corrupted_ct) returns deterministic 32 B K_bar != ss, distinct across different corruptions).
  • NIST ACVP FIPS 204 ML-DSA-87: 25 / 25 from_seed_bytes(seed) KeyGen pk byte-exact matches + 15 / 15 external/pure SigVer + 15 / 15 externalMu SigVer + deterministic rejection across 1-bit signature flips in IdentityKeyPair.verify_with_public_bytes.

2. Verbatim quantumguard sidechannel-check --json Output (TEC 91011:2026 / dudect)

{
  "standard": "TEC 91011:2026 (Section 5) / dudect Welch t-test",
  "platform_info": "Windows 11 (AMD64)",
  "python_version": "3.13.3",
  "timer_source": "time.perf_counter_ns()",
  "samples_per_class": 2500,
  "warmup_samples": 500,
  "crop_percentiles": [0.05, 0.95],
  "threshold": 4.5,
  "all_passed": true,
  "results": [
    {
      "name": "wegman_carter_mac_verify",
      "description": "WegmanCarterMAC.verify (fixed 15/16-byte prefix match vs. random mismatched tag)",
      "samples_per_class": 2500,
      "cropped_n0": 2258,
      "cropped_n1": 2265,
      "mean_ns_class0": 146310.23,
      "mean_ns_class1": 145979.47,
      "stdev_ns_class0": 6029.4,
      "stdev_ns_class1": 5707.94,
      "welch_t_abs": 1.8944,
      "welch_t_raw_abs": 0.8952,
      "threshold": 4.5,
      "verdict": "PASS"
    },
    {
      "name": "firewall_qkd_key_id_compare",
      "description": "HandshakeFirewall.constant_time_key_id_equal (tail-only diff vs. random head diff)",
      "samples_per_class": 2500,
      "cropped_n0": 2383,
      "cropped_n1": 2355,
      "mean_ns_class0": 200.0,
      "mean_ns_class1": 200.0,
      "stdev_ns_class0": 0.0,
      "stdev_ns_class1": 0.0,
      "welch_t_abs": 0.0,
      "welch_t_raw_abs": 0.1178,
      "threshold": 4.5,
      "verdict": "PASS"
    },
    {
      "name": "mlkem1024_decapsulation",
      "description": "FIPS 203 ML-KEM-1024 decapsulate (valid ciphertext vs. corrupted implicit-rejection)",
      "samples_per_class": 2500,
      "cropped_n0": 2291,
      "cropped_n1": 2302,
      "mean_ns_class0": 64858.27,
      "mean_ns_class1": 64887.62,
      "stdev_ns_class0": 2582.86,
      "stdev_ns_class1": 2577.32,
      "welch_t_abs": 0.3854,
      "welch_t_raw_abs": 0.2325,
      "threshold": 4.5,
      "verdict": "PASS"
    }
  ]
}
  • Calibration & Measurement Caveats:
    • Synthetic leaky branch control in test_zeroize_bytes_and_dudect_sensitivity (~50 us asymmetric busy-spin) deterministically fails with |t| >= 4.5 (WARN/INVESTIGATE), proving leak sensitivity.
    • Windows time.perf_counter_ns() exhibits ~100 ns QueryPerformanceCounter quantization, so sub-microsecond paths like firewall_qkd_key_id_compare round to 200.0 ns (cropped stdev 0.0, raw uncropped |t| = 0.1178).
    • Python Buffer Zeroization Scope (zeroize_bytes): zeroize_bytes wipes mutable bytearray and writable memoryview buffers in place (e.g., ikm_buf inside derive_hybrid_session_keys); however, CPython bytes objects returned by OpenSSL/C bindings remain immutable until reference-count reclamation / GC.

3. Verbatim Transport, Red-Team & Static Security Outputs

# python -m quantumguard bench
FIPS 203/204 Self-Test PASS: ML-KEM-1024 (ek=1568 B, ct=1568 B, ss=32 B) |
ML-DSA-87 (pk=2592 B, sig=4627 B) | RFC 10024 Share=1665 B
{
  "handshakes": 50,
  "handshake_mean_ms": 14.763,
  "handshake_p95_ms": 26.016,
  "handshake_wire_bytes": 18154,
  "chunk_kb": 128,
  "echo_payload_mb": 16.0,
  "echo_roundtrip_sec": 0.084,
  "throughput_mb_per_sec": 189.47
}

# python -m quantumguard attack-test --spawn-local --count 1000
stripped_pq_downgrade: 167/167 blocked (0 bypassed)
classical_suite_downgrade: 167/167 blocked (0 bypassed)
corrupted_mldsa87_sig: 167/167 blocked (0 bypassed)
qkd_key_id_swap: 167/167 blocked (0 bypassed)
nonce_replay: 166/166 blocked (0 bypassed)
asymmetric_abort_truncation: 166/166 blocked (0 bypassed)
Summary: 1000/1000 blocked in 8.55s | Bypasses: 0

# python -m pytest -v
42 passed in 80.25s (Ubuntu 24.04 CI) | 42 passed in 115.17s (Windows 11)

# python -m bandit -r quantumguard -v
No issues identified. Code scanned: 3798 lines across 10 files (0 #nosec)

# python -m ruff check quantumguard --select S,B,E,F --ignore E501
All checks passed!

# semgrep scan --config p/python --config p/owasp-top-ten quantumguard --json --output audit_semgrep.json
Ran 156 rules on 21 files: 0 findings. (semgrep results: 0 errors: 0)

# python -m quantumguard audit .
Scanned 20 files | Assets: 43 | Violations: 0 (Exit 0)

# python -m build (or python -m pip wheel --no-deps --no-build-isolation . -w dist/)
dist/quantumguard_cnsa2-0.2.0-py3-none-any.whl & dist/quantumguard_cnsa2-0.2.0.tar.gz

4. Tamarin Prover Formal Model & Environment Transparency (formal/quantumguard_handshake.spthy)

  • Formalized Theory & Lemmas:
    • executable — Honest 4-step trace witness (ServerCommitted < ClientCommitAckVerified < ClientSendAppData) with zero key leaks.
    • session_key_secrecy — Adversary cannot derive k_c2s or k_s2c even when Reveal_Classical_ECDH_Client / Reveal_Classical_ECDH_Server compromises classical P-384 ephemeral scalars (assuming honest ML-DSA-87 identities and uncompromised QKD / ML-KEM-1024).
    • mutual_authentication — Injective agreement between Client and Server on (transcript, qkd_key_id, k_c2s, k_s2c) backed by single-use linear QKD_Client_Token / QKD_Server_Token facts.
    • commit_barrier_consistency — Client linear state transition prohibits Client_Transmit_AppData before Client_Recv_CommitAck verifies SERVER_COMMIT_ACK.
  • CI & Local Environment Execution:
    • Verified live in GitHub Actions Ubuntu 24.04 CI (Run 47609459438) with Tamarin version 1.12.0 + Maude version 3.5.1 (processing time: 22.02s): executable (exists-trace): verified (18 steps), session_key_secrecy (all-traces): verified (10 steps), mutual_authentication (all-traces): verified (71 steps), commit_barrier_consistency (all-traces): verified (10 steps).
    • On the local Windows host (which lacks a native tamarin-prover binary and has com.docker.service stopped), formal/quantumguard_handshake.spthy and its CI wiring are additionally checked via test_formal_tamarin_model_and_ci_wiring.
    • Docker Hub image note: infsec/tamarin-prover:latest resolves (HTTP 200), and official release tamarin-prover-1.12.0-linux64-ubuntu.tar.gz installs cleanly on Ubuntu 24.04. Temporary Hugging Face Docker Space attempt returned HTTP 402 (Pro: No; no Space active), and nvidia-nim nim_guard_check returned HTTP 410 Gone (deepseek-ai/deepseek-v4.1-flash EOL).

LEO Decoy-BB84 Link Budget (500 km, 625 MHz) & Erasure QEC Crossover (benchmarks/satqkd_erasure_bench.py)

  • LEO Link Budget: From 15.0° elevation (35.71 dB loss, 4.191% QBER, 8,397.38 bps finite-key SKR) to 85.0° zenith (21.18 dB loss, 1.903% QBER, 367,391.20 bps SKR).
  • Noise-Regime Separation (benchmarks/results.json):
    • Regime I (circuit_level_pauli_stim): Evaluates unheralded full circuit-level gate Pauli noise on rotated surface codes (d = 3, 5, 10,000 shots/point) via Stim.
    • Regime II (code_capacity_memory_hold_erasure, 1,200 shots/point, p = 0.08): Evaluates heralded optical/neutral-atom memory-hold erasure on the satellite buffer using both block_ler and normalized per_logical_qubit_ler = 1 - (1 - block_ler)**(1/k):
      • Surface-d5 (rate = 0.0400, n=25, k=1): block_ler / per_logical_qubit_ler drops from 0.0842 [0.0698, 0.1012] (0% erasure, 217.1 ms) to 0.0008 [0.0001, 0.0047] (90% erasure conversion, 211.3 ms).
      • BB-qLDPC-[[144,12,12]] (rate = 0.0833, n=144, k=12, BP+OSD-cs order 2): at 0% erasure (531.6 ms), block_ler = 0.4242 [0.3965, 0.4523] corresponds to per_logical_qubit_ler = 0.0450; at 90% erasure conversion (95.5 ms), both block_ler and per_logical_qubit_ler collapse to 0.0000 [0.0000, 0.0032] while delivering 2.08x the encoding rate of d=5 rotated surface code.

Project Structure

QuantumGuard/
├── .github/workflows/
│   ├── ci.yml                     # Pytest, Bandit, 1000-attack fuzz, CBOM, dudect & Tamarin CI
│   ├── publish-pypi.yml           # OIDC PyPI Trusted Publishing release workflow (`quantumguard-cnsa2`)
│   └── quantumguard-cbom.yml      # Automated CycloneDX 1.6 CBOM compliance gate
├── assets/
│   └── quantumguard-architecture.svg # Architecture & assurance overview diagram
├── benchmarks/
│   ├── __init__.py
│   ├── results.json               # Saved Sat-QKD + Regime I/II Erasure QEC JSON benchmark artifact
│   └── satqkd_erasure_bench.py    # LEO finite-key BB84 & Stim vs. BB qLDPC runner
├── dist/                          # Built `.whl` and `.tar.gz` artifacts (gitignored)
├── formal/
│   ├── README.md                  # Tamarin Prover Docker & CI instructions
│   └── quantumguard_handshake.spthy # Symbolic CRQC-resilient handshake model (4 lemmas)
├── quantumguard/
│   ├── __init__.py
│   ├── __main__.py
│   ├── cbom_scanner.py            # AST + regex CycloneDX v1.6 scanner & policy gate
│   ├── cli.py                     # `quantumguard` CLI entrypoint (`kme-mock`, `sidechannel-check`, `bench`)
│   ├── crypto_core.py             # ML-KEM-1024, ML-DSA-87, P-384, ETSI 014, UUIDv7 pool, AES-GCM, WC MAC
│   ├── dashboard.py               # FastAPI interactive security console
│   ├── guard.py                   # Compact binary & JSON active downgrade/replay/abort firewall
│   ├── kme_mock.py                # FastAPI ETSI GS QKD 014 v1.1.1 HTTP Mock KME server
│   ├── py.typed
│   ├── sidechannel.py             # TEC 91011:2026 / dudect Welch's t-test side-channel detector
│   └── tunnel.py                  # Low-latency asyncio TCP_NODELAY proxy & tunnel
├── tests/
│   ├── vectors/                   # SHA-256 verified C2SP Wycheproof & NIST ACVP FIPS 203/204 JSONs
│   ├── test_cbom_and_dashboard.py # CBOM multi-language audit, FastAPI UI, kme-mock & QEC tests
│   ├── test_crypto_core.py        # FIPS sizes, KEM, HTTP ETSI 014, UUIDv7 TTL/LRU, HKDF, AEAD & MAC tests
│   ├── test_security_fuzz.py      # Hypothesis property fuzzing & Schemathesis ASGI OpenAPI tests
│   ├── test_tunnel_and_guard.py   # Live tunnel, proxy bridge, abort & 1,000-attack binary tests
│   └── test_wycheproof_and_kat.py # Wycheproof, NIST ACVP KAT, zeroization, dudect & Tamarin checks
├── .gitignore
├── Dockerfile                     # Non-root OCI container (port 7860)
├── LICENSE                        # MIT License
├── pyproject.toml                 # Package config (`name = "quantumguard-cnsa2"`)
├── README.md
└── SECURITY_AUDIT_REPORT.md

About

CNSA 2.0 Hybrid PQC (SecP384r1MLKEM1024 + ML-DSA-87) + ETSI GS QKD 014 Transport, Active Downgrade Firewall, CBOM Gate, Wycheproof/NIST KATs, TEC 91011:2026 dudect & Tamarin Prover Formal Model

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages