Nuqasm/Qcap

GitHub: Nuqasm/Qcap

面向量子与 AI 工作负载的离线防篡改溯源方案,通过加密签名的 .qcap 归档证明运行内容、硬件环境与授权信息。

Stars: 2 | Forks: 0

# qcap **面向量子与 AI 工作负载的开放、离线、防篡改溯源方案 —— 经过加密签名的 `.qcap` 归档。** [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/Nuqasm/Qcap/actions/workflows/ci.yml) [![License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE) [![PQC](https://img.shields.io/badge/signatures-ML--DSA--87-7b3fe4)](#cryptography) `.qcap` 是一个经过签名、防篡改的凭证,记录了*运行了什么、在什么硬件上、在谁的授权下,以及产出了什么。* 任何人都可以生成它并**离线**验证 —— 无需账户,也无需网络连接。 本仓库包含格式规范([`SPEC.md`](SPEC.md))、参考 CLI、JSON schema、示例以及一致性测试。 ## 快速开始(不到 2 分钟) ``` pip install -e . bash demo/demo.sh ``` 或者在浏览器中运行:**[在 Colab 中打开](https://colab.research.google.com/github/Nuqasm/Qcap/blob/main/demo/colab.ipynb)**。 ``` $ qcap seal examples/quantum_circuit/job_record.json --reference circuit.qasm --out run.qcap --signer alice sealed run.qcap algorithm=ML-DSA-87 signer=alice subject=quantum_circuit $ qcap verify run.qcap --reference circuit.qasm=examples/quantum_circuit/circuit.qasm ✓ signature valid (ML-DSA-87) ✓ payload hashes match manifest ✓ signer: alice ✓ no network used $ printf 'x' >> run.qcap $ qcap verify run.qcap ✗ VERIFICATION FAILED — payload hash mismatch (capsule has been modified) ``` ## 示例 | 示例 | 主体类型 | 路径 | |---------|--------------|------| | 量子任务 + 电路 | `quantum_circuit` | [`examples/quantum_circuit/`](examples/quantum_circuit/) | | 模型监管链 | `model` | [`examples/model_custody/`](examples/model_custody/) | | 推理运行凭证 | `inference` | [`examples/exec_receipt/`](examples/exec_receipt/) | ## `.qcap` 里包含什么 `.qcap` 是一个 ZIP 归档: - **`manifest.json`** — 包含 SHA-256 哈希值和 `subject_type` 的 payload 条目 - **`record.json`** — 审计元数据([`schema/audit-record.schema.json`](schema/audit-record.schema.json)) - **`signature.json`** — 针对规范化后的 `manifest.json` + `record.json` 生成的签名 主体类型:`quantum_circuit` · `model` · `inference` · `agent_action` 完整格式:[`SPEC.md`](SPEC.md) ## CLI ``` qcap seal --out --signer [--reference PATH...] [--algorithm ml-dsa-87|ed25519] qcap verify [--reference NAME=PATH...] qcap ledger add qcap ledger verify ``` 通过哈希值引用大文件,无需将它们嵌入: ``` qcap seal modelcard.json --reference weights.safetensors --out custody.qcap --signer alice qcap verify custody.qcap --reference weights.safetensors=./weights.safetensors ``` ## 加密 - **ML-DSA-87** (FIPS 204) 通过 `liboqs-python` —— `pip install -e ".[pqc]"` - **Ed25519** (标准库) —— 零依赖回退方案 ## 项目文档 - [`CONTRIBUTING.md`](CONTRIBUTING.md) — 如何贡献 - [`GOVERNANCE.md`](GOVERNANCE.md) — 规范演进流程 - [`SECURITY.md`](SECURITY.md) — 报告漏洞 ## 背景 溯源模型源自《*From Trustworthy AI to Trustworthy Quantum*》(S. Vemula,IEEE Quantum Week,QCE26)。有关磁盘上的映射,请参阅 [`SPEC.md`](SPEC.md)。 ## 许可证 Apache-2.0 —— 详见 [`LICENSE`](LICENSE)。
标签:CVE, 人工智能, 密码学, 手动系统调用, 抗量子密码, 数字签名, 溯源, 用户模式Hook绕过, 逆向工具, 量子计算