# Private Computation

> Zero-Knowledge Execution for Sensitive Agent Tasks - Privacy computing framework for AI Agents

- Skill: `dvcrn/private-computation` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dvcrn/private-computation`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dvcrn/private-computation/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: dvcrn (https://skillmd.com/u/dvcrn)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/dvcrn/private-computation

---


# OpenClaw Private Computation

**Zero-Knowledge Execution for Sensitive Agent Tasks**
**AI Agent 敏感任务的零知识执行框架**

A privacy-first computation framework for AI Agents that need to process sensitive data securely. Built with TypeScript for the Node.js ecosystem.

为需要安全处理敏感数据的 AI Agent 打造的隐私优先计算框架。使用 TypeScript 为 Node.js 生态系统构建。

---

## ✨ Features / 功能特性

- 🔐 **Encrypted Credential Storage** / **加密凭证存储**
  - AES-256-GCM encryption for API keys and secrets
  - API 密钥和敏感信息的 AES-256-GCM 加密

- 🛡️ **Secure Task Execution** / **安全任务执行**
  - Isolated execution environment for sensitive operations
  - 敏感操作的隔离执行环境

- 📝 **Immutable Audit Trail** / **不可篡改审计日志**
  - Blockchain-style audit logs for compliance
  - 区块链式审计日志，满足合规要求

- 🎯 **Multiple Security Levels** / **多层安全级别**
  - Basic, Standard (TEE), and Strict (Zero-Knowledge)
  - 基础、标准（TEE）、严格（零知识证明）

- ✅ **GDPR & HIPAA Compliant** / **GDPR 和 HIPAA 合规**
  - Designed for regulatory compliance
  - 专为满足监管合规要求而设计

---

## 📦 Installation / 安装

### Via npm

```bash
npm install openclaw-private-computation
```

### Via ClawHub

```bash
clawhub install private-computation
```

---

## 🚀 Quick Start / 快速开始

```typescript
import { PrivateAgent } from 'openclaw-private-computation';

// Initialize agent / 初始化 Agent
const agent = new PrivateAgent({
  securityLevel: 'basic',  // basic | standard | strict
  audit: true              // 启用审计日志
});

// Store credentials securely / 安全存储凭证
await agent.setSecret('OPENAI_API_KEY', 'sk-...');

// Execute sensitive tasks / 执行敏感任务
const result = await agent.executeTask(async () => {
  const apiKey = await agent.getSecret('OPENAI_API_KEY');
  return await callAPI(apiKey);
}, {
  audit: true,
  metadata: { taskType: 'api_call' }
});

console.log(result);
// { status: 'success', data: {...}, auditId: '...', executionTime: 123 }
```

---

## 🎯 Use Cases / 使用场景

### 1. Medical AI (HIPAA) / 医疗 AI（HIPAA 合规）

```typescript
const diagnosis = await agent.executeTask(async () => {
  const key = await agent.getSecret('MEDICAL_API_KEY');
  return await analyzeMedicalData(patientData, key);
}, {
  audit: true,
  metadata: { complianceLevel: 'HIPAA' }
});
```

### 2. Financial Services (PCI-DSS) / 金融服务（PCI-DSS 合规）

```typescript
const transaction = await agent.executeTask(async () => {
  const bankKey = await agent.getSecret('BANK_API_KEY');
  return await processPayment(amount, bankKey);
}, {
  audit: true,
  timeout: 30000
});
```

### 3. AI Agent with Private Context / 带私有上下文的 AI Agent

```typescript
const response = await agent.executeTask(async () => {
  const llmKey = await agent.getSecret('LLM_API_KEY');
  // Private context never exposed / 私有上下文永不暴露
  return await generateAI(userQuery, privateContext, llmKey);
}, {
  audit: true
});
```

---

## 🔧 API Reference / API 文档

### Configuration / 配置

```typescript
const agent = new PrivateAgent({
  securityLevel: 'basic' | 'standard' | 'strict',
  encryption: 'aes-256-gcm' | 'chacha20-poly1305',
  audit: boolean,
  storagePath: string,  // Default: ~/.openclaw
  masterKey: string     // Auto-generated if not provided / 未提供时自动生成
});
```

### Security Levels / 安全级别

| Level / 级别 | Features / 功能 | Overhead / 开销 | Use Case / 适用场景 |
|--------------|----------------|-----------------|-------------------|
| **Basic / 基础** | Encrypted storage / 加密存储 | ~0% | Development / 开发测试 |
| **Standard / 标准** | + TEE isolation / + TEE 隔离 | ~10% | Production / 生产环境 |
| **Strict / 严格** | + Zero-knowledge proofs / + 零知识证明 | ~300% | High-security / 高度敏感 |

### Credential Management / 凭证管理

```typescript
// Store a secret / 存储密钥
await agent.setSecret('KEY_NAME', 'secret-value');

// Retrieve a secret / 获取密钥
const value = await agent.getSecret('KEY_NAME');

// List all secrets / 列出所有密钥（仅键名）
const keys = agent.listSecrets();

// Delete a secret / 删除密钥
await agent.deleteSecret('KEY_NAME');
```

### Task Execution / 任务执行

```typescript
const result = await agent.executeTask(async () => {
  // Your task logic / 你的任务逻辑
  return someData;
}, {
  audit: true,           // Enable audit logging / 启用审计日志
  proof: true,           // Generate ZK proof / 生成零知识证明 (strict mode)
  timeout: 30000,        // Timeout in ms / 超时时间（毫秒）
  metadata: {...}        // Custom metadata / 自定义元数据
});
```

### Audit & Compliance / 审计与合规

```typescript
// Get audit logs / 获取审计日志
const logs = agent.getAuditLogs(10);

// Verify integrity / 验证完整性
const integrity = agent.verifyAuditIntegrity();
// { valid: true }

// Get statistics / 获取统计信息
const stats = agent.getAuditStatistics();
// { totalLogs: 42, byAction: {...}, byResult: {...} }
```

---

## 🏗️ Architecture / 架构

```
OpenClaw Private Computation
│
├── Core Layer / 核心层
│   ├── Encryption Manager / 加密管理器 (AES-256-GCM)
│   ├── Credential Vault / 凭证保险库
│   ├── Audit Logger / 审计日志器 (Blockchain-style)
│   └── Task Executor / 任务执行器
│
├── Crypto Layer (Future) / 加密层（未来）
│   ├── zk-SNARKs (Zero-Knowledge Proofs) / 零知识证明
│   ├── TEE (Trusted Execution Environment) / 可信执行环境
│   └── Homomorphic Encryption / 同态加密
│
└── Integration Layer (Future) / 集成层（未来）
    ├── LangChain Adapter
    ├── Vercel AI SDK Adapter
    └── Claude API Adapter
```

---

## 🛣️ Roadmap / 路线图

### Phase 1: MVP ✅ (Current / 当前)
- [x] Encrypted credential storage / 加密凭证存储
- [x] Basic audit logging / 基础审计日志
- [x] Simple SDK API / 简洁的 SDK API
- [x] Examples and documentation / 示例和文档

### Phase 2: Zero-Knowledge (Next / 下一步)
- [ ] zk-SNARKs integration / zk-SNARKs 集成
- [ ] Proof generation and verification / 证明生成和验证
- [ ] Circuit library / 电路库

### Phase 3: TEE Integration / TEE 集成
- [ ] Intel SGX support / Intel SGX 支持
- [ ] ARM TrustZone support / ARM TrustZone 支持
- [ ] Hybrid mode (TEE + zk) / 混合模式（TEE + 零知识）

### Phase 4: Enterprise Features / 企业功能
- [ ] AI framework integrations / AI 框架集成
- [ ] Compliance reporting / 合规报告
- [ ] Multi-party computation / 多方计算

---

## 🔬 Technology / 技术栈

- **Language / 语言**: TypeScript
- **Runtime / 运行时**: Node.js 18+
- **Encryption / 加密**: Node.js Crypto (AES-256-GCM, ChaCha20-Poly1305)
- **Zero-Knowledge / 零知识**: snarkjs (coming soon / 即将推出)
- **TEE**: Intel SGX (planned / 规划中)
- **Audit / 审计**: Blockchain-inspired immutable logs / 区块链式不可篡改日志

---

## 📚 Documentation / 文档

- [GitHub Repository / 代码仓库](https://github.com/ZhenRobotics/openclaw-private-computation)
- [Quick Start Guide / 快速开始指南](https://github.com/ZhenRobotics/openclaw-private-computation/blob/main/QUICKSTART.md)
- [Full Documentation / 完整文档](https://github.com/ZhenRobotics/openclaw-private-computation#readme)
- [Examples / 示例](https://github.com/ZhenRobotics/openclaw-private-computation/tree/main/examples)

---

## 🌟 Why Choose OpenClaw? / 为什么选择 OpenClaw？

> **"The first production-ready privacy computing framework for TypeScript"**
> **"首个生产级 TypeScript 隐私计算框架"**

No other TypeScript/JavaScript library provides:
其他 TypeScript/JavaScript 库都不提供：

- ✅ Zero-knowledge execution for AI agents / AI Agent 的零知识执行
- ✅ HIPAA/GDPR-ready audit trails / HIPAA/GDPR 就绪的审计追踪
- ✅ Simple API for complex cryptography / 复杂加密的简洁 API
- ✅ Open source and extensible / 开源且可扩展

---

## 🤝 Contributing / 贡献

We welcome contributions! Please see our [GitHub repository](https://github.com/ZhenRobotics/openclaw-private-computation) for details.

欢迎贡献！详情请查看我们的 [GitHub 仓库](https://github.com/ZhenRobotics/openclaw-private-computation)。

---

## 📄 License / 许可证

MIT-0 License - Free and open source, no attribution required.
MIT-0 许可证 - 免费开源，无需署名。

---

**Built for the AI Agent era. Secure by default. Private by design.**
**为 AI Agent 时代而生。默认安全。隐私优先。** 🚀

