aswinpq/AI-Model-Integrity-Verification-System

GitHub: aswinpq/AI-Model-Integrity-Verification-System

基于零知识证明和可信执行环境的AI模型训练完整性验证框架,在保护商业机密的同时提供可公开审计的合规证明。

Stars: 0 | Forks: 0

# AI 模型完整性验证系统 [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) ## 问题背景 一家 AI 公司必须向监管机构、审计师和公众证明,其模型是**完全在授权数据上训练**的,并且**通过了规定的安全评估**——同时不暴露模型权重、架构或训练数据集本身。 ## 系统架构 ``` ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐ ┌──────────────┐ │ Training │ │ ZKP / TEE │ │ Public │ │ Auditor │ │ Pipeline │ ──► │ Attestation │ ──► │ Proof │ ──► │ Verifies │ └─────────────────┘ └─────────────────┘ └──────────────┘ └──────────────┘ ``` ### 五层验证体系 | 层级 | 目的 | 技术 | |-------|---------|------------| | **1 — 数据许可注册表** | 证明所有训练数据均已获得授权 | Merkle tree + ZK-SNARK (Circom/Groth16) | | **2 — 训练流水线认证** | 证明训练过程在可信环境中运行 | TEE (Intel TDX / AWS Nitro) | | **3 — 安全评估证明** | 证明模型通过了安全基准测试 | ZK-SNARK + TEE 认证 | | **4 — 证明聚合** | 将所有证明打包为可验证凭证 | W3C VC + IPFS + 链上锚点 | | **5 — 审计门户** | 公开验证接口 | Next.js + WASM 验证器 | ## 项目结构 ``` zk-ai-integrity/ ├── packages/ │ ├── core/ TypeScript shared types, crypto, credentials │ └── cli/ CLI verification tool (integrity-verify) ├── circuits/ │ ├── data-licensing/ Merkle inclusion + signature + license proof │ └── safety-eval/ Safety score threshold circuits ├── api/ FastAPI backend (routers, services, ORM) ├── enclave/ Rust TEE enclave (Ed25519 attestation, Merkle verifier) ├── contracts/ Solidity (IntegrityRegistry, Groth16Verifier) ├── portal/ Next.js 14 auditor portal ├── docs/ Threat model, integration guide ├── .github/workflows/ CI/CD attestation pipeline └── docker-compose.yml PostgreSQL + IPFS ``` ## 快速开始 ### 前置条件 - Node.js ≥ 18 - Python ≥ 3.11 - Rust ≥ 1.75 (用于 enclave) - Docker & Docker Compose (可选,用于本地服务) ### 设置 ``` # 克隆并安装 git clone https://github.com/aswinpq/AI-Model-Integrity-Verification-System.git cd zk-ai-integrity npm install # 配置环境 cp .env.example .env # 启动 API server cd api pip install -r requirements.txt uvicorn app.main:app --port 8000 # 启动 auditor portal (新终端) cd portal npm run dev ``` ### 验证模型 ``` # CLI 验证 (完整) npx integrity-verify --full # 用于自动化的 JSON 输出 npx integrity-verify --full --json # 通过 REST API curl http://localhost:8000/api/v1/models//credential # 通过 portal open http://localhost:3000/verify/ ``` ### 智能合约 ``` cd contracts npm install npx hardhat test npx hardhat run scripts/deploy.js --network arbitrum_sepolia ``` ### TEE Enclave ``` cd enclave cargo build --release ./target/release/integrity-enclave mock-attest --model-hash ``` ## API 端点 | 方法 | 端点 | 描述 | |--------|----------|-------------| | `POST` | `/api/v1/models/{id}/attestations` | 提交认证 | | `GET` | `/api/v1/models/{id}/credential` | 获取凭证 | | `POST` | `/api/v1/verify` | 验证 ZK 证明 | | `GET` | `/api/v1/registry/merkle-root` | 获取最新的 Merkle root | | `GET` | `/api/v1/registry/models` | 列出所有模型 | | `WS` | `/api/v1/events` | 实时事件流 | | `GET` | `/health` | 健康检查 (DB, 运行时间) | ## 安全性 - **API**: 速率限制、API 密钥认证、请求 ID 追踪、结构化 JSON 日志、安全请求头 (CSP, HSTS, X-Frame-Options) - **合约**: 两步所有权转移、重入保护、紧急暂停、自定义错误、输入验证 - **加密**: Ed25519 签名 (HSM)、Groth16 证明 (MPC 可信设置)、Poseidon 哈希、SHA-256 - **TEE**: enclave 度量验证、可复现构建、开源代码 - **凭证**: 90 天有效期、链上锚定、基于 nonce 的重放保护 请参阅 [`docs/threat-model.md`](docs/threat-model.md) 以获取完整的对抗分析。 ## 文档 - [威胁模型](docs/threat-model.md) — 5 种对抗者、TEE 侧信道、可信设置风险 - [集成指南](docs/integration-guide.md) — 适用于第三方审计师和验证者 - [API 文档](http://localhost:8000/docs) — 交互式 Swagger (本地运行时可用) ## 许可证 MIT
标签:AI安全, AI监管, AWS Nitro, Chat Copilot, Circom, Groth16, Intel TDX, IPFS, Merkle Tree, RegTech, TEE, TypeScript, W3C可验证凭证, WebAssembly, Zenmap, ZK-SNARK, 中间件, 人工智能治理, 区块链存证, 去中心化身份, 可信执行环境, 可视化界面, 合规科技, 安全插件, 密码学, 手动系统调用, 数字孪生, 数据完整性, 数据确权, 模型训练验证, 测试用例, 溯源, 联邦学习, 自动化攻击, 自动化攻击, 请求拦截, 逆向工具, 链上锚定, 隐私计算, 零知识证明