rwilliamspbg-ops/smp-tee-runtime
GitHub: rwilliamspbg-ops/smp-tee-runtime
一个最小化的 Rust TEE 运行时,用于在硬件可信执行环境中安全执行联邦学习聚合算法。
Stars: 2 | Forks: 0
# smp-tee-runtime
一个加固、最小化的 Rust 运行时,用于在 TEE(SGX/TDX/SEV-SNP/Nitro)内进行联邦学习聚合。
## 快速开始
1. 在本地构建并测试该 crate:
```
cargo build
cargo test
```
2. 运行演示公共 API 的示例流程:
```
cargo run --example basic_tee_call
cargo run --example xdp_integration
```
3. 运行跟踪聚合和入口模拟成本的基准测试套件:
```
cargo bench --bench aggregation
```
## 仓库结构
```
smp-tee-runtime/
├── Cargo.toml
├── src/
│ ├── lib.rs
│ ├── main.rs
│ ├── tee_interface/
│ │ ├── mod.rs
│ │ └── traits.rs
│ ├── data_pipeline/
│ │ ├── mod.rs
│ │ └── xdp_ingress.rs
│ └── aggregation/
│ ├── mod.rs
│ └── multi_krum.rs
├── build-scripts/
├── examples/
│ ├── basic_tee_call.rs
│ └── xdp_integration.rs
├── benches/
│ └── aggregation.rs
├── tests/
│ └── end_to_end.rs
├── CONTRIBUTING.md
└── SECURITY.md
```
### 目标构建
- SGX/TDX:`cargo build --target `
- SEV-SNP:在启用了 SNP 的客户虚拟机/工具链环境中构建。
## 性能跟踪
下表记录了所提供基准测试目标的当前 Criterion 结果。
数据收集于 2026 年 5 月 26 日,测试环境为 Ubuntu 24.04.4 LTS 开发容器,使用 `stable-x86_64-unknown-linux-gnu` 和 `rustc 1.95.0`,通过 `cargo bench --bench aggregation` 运行。
| Benchmark | 当前结果 | 测量内容 |
| --- | --- | --- |
| `federated_averaging` | 35.325 ns 到 36.458 ns | 对小型内存批次的平均聚合 |
| `multi_krum` | 3.5111 ns 到 3.6398 ns | 对小型候选集的鲁棒聚合选择 |
| `simulated_packet_pointer_pass_1m` | 630.24 µs 到 644.61 µs | 100万数据包入口模拟的指针传递开销 |
### 更新性能数据
在更新上表时,请使用此确切工作流:
```
cargo bench --bench aggregation
```
仅当新的 Criterion 结果与当前值有显著差异时,才更新该表。
## 端到端流程示例
```
cargo run --example xdp_integration
```
此示例演示:类 XDP 入口数据包视图 -> TEE 内存写入 -> 聚合 -> 输出。
## 库使用
将此运行时嵌入到另一个 Rust crate 时,请直接使用公共 API。以下代码片段展示了与端到端测试所执行的相同的内存流程:
```
use smp_tee_runtime::{AggregationAlgorithm, ComputationParams, InMemoryTee, TeeGuard};
let mut tee = InMemoryTee::default();
tee.initialize().expect("TEE init failed");
let left = tee.allocate_memory(8).expect("left allocation failed");
let right = tee.allocate_memory(8).expect("right allocation failed");
let _result = tee
.execute_computation(
&[left.cast_const(), right.cast_const()],
&ComputationParams {
algorithm: AggregationAlgorithm::FederatedAveraging,
},
)
.expect("aggregation failed");
```
标签:可视化界面, 通知系统