privacy-computing-data-space
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "privacy-computing-data-space" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5ba13d46de22f54b0b75dd104b218020a8c50ea8add5ea2d1b264e1856affc20. Verify the upstream source and version against https://skillhub.cn/skills/user_69009747/privacy-computing-data-space before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Privacy-computing and trusted data-space tool covering federated learning, multi-party computation (MPC), the FATE framework, data circulation and privacy protection technologies. Includes differential privacy, homomorphic encryption, trusted execution environments (TEE), data elements and data security, and concepts like data non-export, focused on privacy-preserving computation scenarios.
Introduction source: third_party · user_69009747 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Software, accounts and paid services
- docker-compose up -d
- Testing
- Not tested
Browse files
Frontmatter
name: privacy-computing-data-space
description: >
隐私计算 / 可信数据空间 / 联邦学习 / 多方安全计算 / MPC / FATE 框架 / 数据流通 / 隐私保护 / 差分隐私 / 同态加密 / 可信执行环境 / TEE / 数据要素 / 国家数据局 / 数据安全 / 数据不出域 / 隐私保护计算
version: 1.0.0
author: Marvis
tags:
- privacy-computing
- federated-learning
- mpc
- trusted-data-space
- data-elements
- fate
- differential-privacy隐私计算与可信数据空间
数据可用不可见,数据不动模型动——"让数据流通不再以牺牲隐私为代价"。
一、隐私计算全景图
┌─────────────────────────┐
│ 隐私计算技术栈 │
└────────────┬────────────┘
│
┌────────────┬────────────┬───┴───┬────────────┐
▼ ▼ ▼ ▼ ▼
联邦学习 多方安全计算 同态加密 差分隐私 可信执行环境
(FL) (MPC) (HE) (DP) (TEE)
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
横向/纵向 秘密分享 全同态 拉普拉斯 Intel SGX
迁移学习 不经意传输 半同态 高斯噪声 AMD SEV
FATE框架 SPDZ协议 CKKS 指数机制 ARM TrustZone
二、快速开始
# 一键部署隐私计算实验环境
docker-compose up -d
# 启动 FATE 联邦学习(两方)
bash scripts/start_fate_cluster.sh
# 运行联邦逻辑回归演示
python scripts/fl_demo.py --parties 2 --algorithm logistic_regression
# 运行多方安全计算演示(三方平均值)
python scripts/mpc_demo.py --parties 3 --operation average
三、联邦学习入门实战
3.1 核心概念
传统机器学习: 联邦学习:
┌──────────┐ ┌──────┐ ┌──────┐ ┌──────┐
│ 中心服务器 │ │ Party │ │ Party │ │ Party │
│ 汇总所有 │ │ A │ │ B │ │ C │
│ 原始数据 │ │ 数据A │ │ 数据B │ │ 数据C │
└──────────┘ └──┬───┘ └──┬───┘ └──┬───┘
▲ │ 梯度 │ 梯度 │ 梯度
│ └───┬────┴───┬────┘
┌────┴─────┐ ▼ ▼
│ 数据A+B+C │ ┌─────────────────┐
└──────────┘ │ 协调服务器 │
│ 聚合梯度+更新 │
│ 模型,数据不出域 │
└─────────────────┘
3.2 FATE 框架快速上手
FATE(Federated AI Technology Enabler)是微众银行开源的联邦学习框架,支持横向/纵向/迁移联邦学习。
# scripts/fl_demo.py
"""FedAvg 联邦平均算法演示 —— 逻辑回归"""
from pipeline.backend.pipeline import PipeLine
from pipeline.component import Reader, DataTransform, Intersection, HeteroLR, Evaluation
from pipeline.interface import Data
# 1. 定义 Pipeline
pipeline = PipeLine().set_initiator(role='guest', party_id=9999)
pipeline.set_roles(guest=9999, host=10000, arbiter=10000)
# 2. 读取数据(各方本地读取,不出域)
reader_0 = Reader(name="reader_0")
reader_0.get_party_instance(role='guest', party_id=9999) \
.component_param(table={"name": "breast_cancer_guest", "namespace": "experiment"})
reader_0.get_party_instance(role='host', party_id=10000) \
.component_param(table={"name": "breast_cancer_host", "namespace": "experiment"})
# 3. 数据对齐(求样本交集,不泄露对方数据)
intersection_0 = Intersection(name="intersection_0")
# 4. 联邦逻辑回归训练
hetero_lr_0 = HeteroLR(
name="hetero_lr_0",
early_stop="weight_diff",
max_iter=20,
penalty="L2",
optimizer="rmsprop",
tol=0.0001,
alpha=0.01,
batch_size=128,
learning_rate=0.15,
encrypt_param={"method": "Paillier"} # 同态加密保护梯度
)
# 5. 评估
evaluation_0 = Evaluation(name="evaluation_0", eval_type="binary")
# 6. 组装执行
pipeline.add_component(reader_0)
pipeline.add_component(intersection_0, data=Data(data=reader_0.output.data))
pipeline.add_component(hetero_lr_0, data=Data(train_data=intersection_0.output.data))
pipeline.add_component(evaluation_0, data=Data(data=hetero_lr_0.output.data))
pipeline.compile()
pipeline.fit()
3.3 三种联邦学习模式
| 模式 | 特征 | 典型场景 | FATE 支持 |
|---|---|---|---|
| 横向联邦 | 特征相同,样本不同 | 银行间联合风控建模 | ✅ |
| 纵向联邦 | 样本相同,特征不同 | 银行+电商联合营销 | ✅ |
| 联邦迁移 | 样本和特征都不同 | 跨行业知识迁移 | ✅ |
四、多方安全计算(MPC)
4.1 核心协议
# scripts/mpc_demo.py
"""三方安全平均值计算:每方有私有数字,计算平均值但互不知晓对方数值"""
import random
from typing import List
class SecureAverageMPC:
"""
基于秘密分享的隐私平均值协议
原理:
1. 每方将私有值拆成 N 份随机份额,分发 N-1 份给其他方
2. 各方汇总收到的份额,公开总和
3. 总和/N = 平均值,但任何一方无法反推他人的原始值
"""
def __init__(self, n_parties: int = 3):
self.n = n_parties
def compute(self, private_values: List[float]) -> float:
"""各方输入私有值,输出平均值"""
# Step 1: 每方生成 N 份份额,和为私有值
shares = []
for v in private_values:
random_shares = [random.uniform(-1000, 1000) for _ in range(self.n - 1)]
last_share = v - sum(random_shares)
shares.append(random_shares + [last_share])
# Step 2: 每方将第 j 份发给第 j 方
party_sums = []
for j in range(self.n):
received = [shares[i][j] for i in range(self.n)]
party_sums.append(sum(received))
# Step 3: 各方公开自己收到的总和
total_sum = sum(party_sums)
avg = total_sum / len(private_values)
return avg, party_sums # 返回平均值和各方汇总值(可公开)
# 示例运行
mpc = SecureAverageMPC(n_parties=3)
avg, shares = mpc.compute(private_values=[1500.0, 2200.0, 1800.0])
print(f"安全计算结果:平均值 = {avg:.2f}")
# 输出: 平均值 = 1833.33
# 每一方只知道自己的值和收到的随机份额,无法反推其他方的值
4.2 MPC 协议对比
| 协议 | 安全性 | 通信轮次 | 适用场景 |
|---|---|---|---|
| 秘密分享 | 信息论安全 | O(1) | 加减乘 |
| 混淆电路 | 计算安全 | O(depth) | 比较、条件判断 |
| 不经意传输(OT) | 计算安全 | O(1) | 隐私集合求交 |
| SPDZ | 主动安全 | 在线/离线 | 通用计算 |
| 全同态加密(FHE) | 计算安全 | 1轮 | 任意计算,通信最优 |
五、差分隐私(DP)
# scripts/dp_demo.py
"""差分隐私实现:向统计结果注入拉普拉斯噪声,保护个体隐私"""
import numpy as np
class DifferentialPrivacy:
"""
ε-差分隐私:对查询结果加噪,使攻击者无法判断某个个体是否在数据集中
ε 越小 → 噪声越大 → 隐私保护越强,但结果精度越低
行业推荐:ε ∈ [0.1, 1.0]
"""
def __init__(self, epsilon: float = 0.5):
self.epsilon = epsilon
def laplace_noise(self, sensitivity: float, n_queries: int = 1) -> float:
"""生成拉普拉斯噪声: scale = sensitivity / epsilon"""
scale = sensitivity / self.epsilon
return np.random.laplace(0, scale)
def private_count(self, true_count: int, sensitivity: float = 1.0) -> float:
"""差分隐私计数:count + Laplace(1/ε)"""
noise = self.laplace_noise(sensitivity)
return true_count + noise
def private_mean(self, true_mean: float, data_range: float, n_samples: int,
sensitivity: float = None) -> float:
"""差分隐私均值:mean + Laplace(range/(n*ε))"""
if sensitivity is None:
sensitivity = data_range / n_samples
noise = self.laplace_noise(sensitivity)
return true_mean + noise
def compose_epsilon(self, epsilons: List[float]) -> float:
"""顺序组合定理:多次查询的隐私预算累加"""
return sum(epsilons)
# 演示
dp = DifferentialPrivacy(epsilon=0.5)
true_salary_mean = 15000.0
dp_salary_mean = dp.private_mean(true_salary_mean, data_range=50000, n_samples=1000)
print(f"真实平均薪资: {true_salary_mean}")
print(f"DP 发布值: {dp_salary_mean:.2f} (差异: {abs(dp_salary_mean - true_salary_mean):.2f})")
六、可信数据空间架构
┌──────────────────────────────────────────────────────────┐
│ 可 信 数 据 空 间 │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ 数据提供方 │ │ 数据使用方 │ │ 监管节点 │ │
│ │ (Provider) │ │ (Consumer) │ │ (Regulator) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ 连接器 │ │
│ │ (Connector) │ │
│ └──────┬──────┘ │
│ │ │
│ ┌────────────────┼────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌────────────┐ ┌────────────┐ ┌────────────┐ │
│ │ 身份认证 │ │ 使用控制 │ │ 审计追溯 │ │
│ │ (DID/VC) │ │ (Policy) │ │ (Audit) │ │
│ └────────────┘ └────────────┘ └────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ 数据流通合规框架 1.0 │ │
│ │ · 数据分类分级 · 使用合约 · 存证上链 │ │
│ └─────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────┘
七、技术选型决策树
需要保护数据隐私?
│
├─ 多方联合建模,数据不能出域?
│ └─ 联邦学习(FATE / FedML / PySyft)
│ ├─ 同特征不同样本 → 横向联邦
│ ├─ 同样本不同特征 → 纵向联邦
│ └─ 完全不同数据分布 → 联邦迁移
│
├─ 简单统计查询(求和/平均/最值)?
│ └─ 多方安全计算(秘密分享 / SPDZ)
│
├─ 发布统计结果,防止个体推断?
│ └─ 差分隐私(拉普拉斯 / 高斯机制)
│
├─ 全量数据加密后计算?
│ └─ 同态加密(CKKS / BGV / TFHE)
│ ├─ 仅加法 → 半同态(Paillier)
│ └─ 任意计算 → 全同态(CKKS)
│
└─ 硬件级隔离执行环境?
└─ TEE(Intel SGX / AMD SEV / ARM TrustZone)
八、国家政策速览
| 时间 | 政策/事件 | 核心要点 |
|---|---|---|
| 2026.5 | 国家数据局强调 | 加快推进隐私计算和可信数据空间建设 |
| 2025 | 数据二十条深化落地 | 数据产权三权分置,推动数据流通 |
| 2024 | 数据要素×三年行动计划 | 12个重点领域数据融合应用 |
| 2023 | 可信数据空间发展行动计划 | 到2025年建成100个以上可信数据空间 |
九、生产 Checklist
- [ ] 联邦学习各方数据已对齐(PSI 隐私集合求交)
- [ ] 梯度/中间结果使用同态加密或秘密分享保护
- [ ] 差分隐私 ε 预算已分配(单次查询 ≤ 1.0,累计 ≤ 10)
- [ ] 可信数据空间连接器已部署
- [ ] 数据使用合约(DUC)已签署并存证
- [ ] 审计日志完整记录所有数据访问
- [ ] 模型安全评估已通过(成员推断攻击防御)
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 覆盖隐私计算核心技术栈,包括联邦学习、多方安全计算、差分隐私等高价值领域
- 提供 FATE 框架实战代码和部署脚本,具备工程落地指导价值
- 结合国家数据局政策,贴合可信数据空间建设热点需求
Highlights
- 触发词全面覆盖隐私计算生态核心术语,边界清晰
- 支持多种技术变体(如横向/纵向联邦、秘密分享/混淆电路)
Areas to improve
-
缺少 When to Use 章节 Reported severity: Minor
未明确说明适用场景和使用时机
Recommendation: 建议在快速开始章节前增加 When to Use 说明
-
文档过长 Reported severity: Minor
SKILL.md 内容约1800行,影响可读性
Recommendation: 考虑将部分代码示例移至独立脚本文件并通过引用方式展示
Highlights
- 章节划分清晰,从理论到实践逻辑连贯
- 提供技术选型决策树,帮助用户快速定位方案
Areas to improve
-
异常处理不足 Reported severity: Major
部署脚本和代码示例未覆盖网络失败、依赖缺失等常见异常
Recommendation: 建议在关键操作处增加 try-catch 和错误提示
Highlights
- 提供了完整的 Docker 部署和 FATE 启动脚本
- 代码参数配置合理,包含加密方式和优化器选择
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Invoke commands or scripts
Read the script and arguments first. Use ordinary privileges and a scoped directory; confirm installation or execution in your host tool.
Mentioned in main document · lines 46
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
docker-compose up -d
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.