Agnuxo1/ASIC-RAG-CHIMERA
GitHub: Agnuxo1/ASIC-RAG-CHIMERA
该项目通过 GPU 仿真 SHA-256 哈希引擎,构建了一套以加密哈希索引和 AES-256-GCM 加密为核心的隐私保护型 RAG 研究系统。
Stars: 5 | Forks: 1
# ASIC-RAG-CHIMERA
**受 Bitcoin 挖矿 ASIC 启发的 SHA-256 哈希引擎 GPU 仿真,并接入 RAG 流水线。纯软件实现;无需真实的 ASIC 硬件。**
[](https://doi.org/10.5281/zenodo.17872052)
[](https://pypi.org/project/asic-rag-chimera/)
[](tests/)
[](coverage.xml)
[](https://huggingface.co/spaces/Agnuxo/ASIC-RAG-CHIMERA)
[](https://python.org)
[](LICENSE)
## 这是什么
ASIC-RAG-CHIMERA 是一个**软件研究工件**。它包含:
1. 一个使用 PyTorch 实现的 **GPU 加速 SHA-256 哈希引擎**,用于*仿真* Bitcoin 风格 ASIC 会进行的大规模哈希运算。它可在普通的 CUDA GPU(或 CPU 回退)上运行。这是一个软件仿真,而非真实的 ASIC。
2. 一个**密码学 RAG 流水线**,它通过 SHA-256 标签而不是明文嵌入(embeddings)来索引文档,使用 AES-256-GCM 加密数据块,并通过 Merkle 树验证完整性。
3. 一个**带有合成患者记录的演示工作流**,说明了如何为隐私敏感数据配置该流水线(参见 `ASIC-RAG-HEALTH_Validation/`)。数据均为捏造。这**不是**临床工具,绝不能用于医疗决策。
## 这不是什么
- **不是**真实的 ASIC 硬件。没有硅片,没有 Verilog tape-out,没有 FPGA bitstream。名称中的“ASIC”是指 GPU 仿真模块(`asic_simulator/`)的架构*灵感*。
- **不是**医疗设备。健康演示使用的是合成记录,仅用于说明。
- **不是** Bitcoin 矿工。SHA-256 引擎用于内容寻址索引,而不是工作量证明。
## 安装
```
pip install asic-rag-chimera
```
可选附加项:
```
pip install "asic-rag-chimera[gpu]" # Ensure PyTorch with CUDA is available
pip install "asic-rag-chimera[wandb]" # Experiment tracking
pip install "asic-rag-chimera[dev]" # Tests, build, twine
```
从源码安装:
```
git clone https://github.com/Agnuxo1/ASIC-RAG-CHIMERA.git
cd ASIC-RAG-CHIMERA
pip install -e ".[dev]"
```
## 快速开始
```
import os
from asic_simulator import GPUHashEngine, IndexManager, KeyGenerator
from rag_system import DocumentProcessor, QueryEngine
hash_engine = GPUHashEngine()
index_manager = IndexManager()
key_generator = KeyGenerator(master_key=os.urandom(32))
processor = DocumentProcessor()
blocks = processor.create_blocks("Your document content here")
query_engine = QueryEngine(index_manager, hash_engine)
results = query_engine.search("your query", max_results=5)
```
或者使用集成的 facade:
```
from asic_rag_chimera import ASICRAGSystem
system = ASICRAGSystem(storage_path="./data", master_key=os.urandom(32))
system.ingest("document.txt")
result = system.query("What is the revenue?")
```
## 架构
```
┌──────────────┐ text ┌─────────────┐ tag hashes ┌────────────────────┐
│ User query │────────────▶│ LLM (GPU) │─────────────────▶│ GPU SHA-256 engine │
└──────────────┘ └─────────────┘ │ (asic_simulator) │
▲ └──────────┬─────────┘
│ decrypted blocks │ hash lookup
▼ ▼
┌────────────────────────────────────────────────────┐
│ Encrypted block storage (LMDB / AES-256-GCM) │
│ Merkle tree integrity proofs │
└────────────────────────────────────────────────────┘
```
## 运行测试和覆盖率
```
pytest tests/ -v # 53/53 tests pass
pytest tests/ --cov=asic_simulator --cov=rag_system --cov=asic_rag_chimera --cov-report=term --cov-report=xml
```
核心包的测量行覆盖率为 **57%**(共 1658 条语句,706 条遗漏),已写入 `coverage.xml`。之前的 README 声称是“100%”——那从未经过测量。这 53 个测试全部通过;它们只是没有运行到 `keyword_extractor`、`query_engine`、`key_generator` 等的每个分支。
## 安全模型
| 攻击向量 | 传统 RAG | ASIC-RAG-CHIMERA |
|--------------------------|--------------------------|-----------------------------|
| 磁盘失窃 | 明文暴露 | 加密的数据块 |
| 嵌入反演 | 部分恢复 | 不适用(未存储嵌入) |
| 索引枚举 | 知识图谱暴露 | 不透明的 SHA-256 标签 |
| 密钥捕获 | 永久访问 | 30秒 TTL 会话密钥 |
| 数据篡改 | 未检测到 | Merkle 证明验证 |
以上声明描述的是*设计*。这是一个研究原型,而不是经过审计的产品。
## 仓库布局
```
asic_simulator/ GPU SHA-256 engine + tag index + key generator
rag_system/ Document processor, block storage, query engine
asic_rag_chimera.py Integrated facade (ASICRAGSystem)
tests/ 53 pytest tests
benchmarks/ Microbenchmarks for hash and search latency
archive/ Historical artefacts (PDFs, HTML, duplicate dirs) — not shipped
huggingface_space/ HF Space demo app
```
## 引用
```
@software{angulo_asic_rag_chimera_2026,
author = {Angulo de Lafuente, Francisco},
title = {ASIC-RAG-CHIMERA: GPU Simulation of a SHA-256 Hash Engine for Cryptographic RAG},
year = {2026},
version = {1.0.0},
doi = {10.5281/zenodo.17872052},
url = {https://github.com/Agnuxo1/ASIC-RAG-CHIMERA}
}
```
参见 [`CITATION.cff`](CITATION.cff)。
## 作者
**Francisco Angulo de Lafuente** — [GitHub @Agnuxo1](https://github.com/Agnuxo1)
## 许可证
MIT — 参见 [许可证](LICENSE)。
## 相关项目
[@Agnuxo1](https://github.com/Agnuxo1) v1.0.0 开源目录(2026年4月)的一部分。
**AgentBoot 星系** — 代理和研究循环
- [AgentBoot](https://github.com/Agnuxo1/AgentBoot) — 用于裸机硬件检测和操作系统安装的对话式 AI 代理。
- [autoresearch-nano](https://github.com/Agnuxo1/autoresearch) — 基于 nanoGPT 的自主 ML 研究循环。
- [The Living Agent](https://github.com/Agnuxo1/The-Living-Agent) — 16x16 棋盘网格自主研究代理。
- [benchclaw-integrations](https://github.com/Agnuxo1/benchclaw-integrations) — BenchClaw API 的代理框架适配器。
**CHIMERA / 神经形态星系** — GPU 原生科学计算
- [NeuroCHIMERA](https://github.com/Agnuxo1/NeuroCHIMERA__GPU-Native_Neuromorphic_Consciousness) — 基于 OpenGL 计算着色器的 GPU 原生神经形态框架。
- [Holographic-Reservoir](https://github.com/Agnuxo1/Holographic-Reservoir) — 使用仿真 ASIC 后端的水库计算(Reservoir computing)。
- [QESN-MABe](https://github.com/Agnuxo1/QESN_MABe_V2_REPO) — 在二维晶格上的量子启发回声状态网络(经典)。
- [ARC2-CHIMERA](https://github.com/Agnuxo1/ARC2_CHIMERA) — 研究 PoC:用于符号推理的 OpenGL 原语。
- [Quantum-GPS](https://github.com/Agnuxo1/Quantum-GPS-Unified-Navigation-System) — 量子启发的 GPU 导航器(经典 Eikonal 求解器)。
标签:AES-256-GCM, PyTorch, RAG, SHA-256, Vectored Exception Handling, 人工智能, 凭据扫描, 密码学, 手动系统调用, 用户模式Hook绕过, 逆向工具, 默克尔树