zama-ai/tfhe-rs
GitHub: zama-ai/tfhe-rs
TFHE-rs 是一个纯 Rust 实现的全同态加密库,支持在加密数据上直接执行布尔和整数算术运算。
Stars: 1602 | Forks: 322
📃 阅读手册 | 📒 文档 | 💛 社区支持 | 📚 Zama 的 FHE 资源
## 关于 ### 什么是 TFHE-rs **TFHE-rs** 是 TFHE 的纯 Rust 实现,用于对加密数据进行布尔和整数算术运算。 它包括: - 一个 **Rust** API - 一个 **C** API - 以及一个 **客户端 WASM** API TFHE-rs 专为希望完全控制 使用 TFHE 可以做些什么的开发人员和研究人员而设计,同时无需担心 底层实现。我们的目标是提供一个稳定、简单、高性能且 生产就绪的库,以支持 TFHE 的所有高级功能。### 主要特性 - **底层密码学库**,实现了 Zama 的 TFHE 变体,包括可编程自举 - **实现了原始的 TFHE 布尔 API**,可直接替换其他 TFHE 库 - **短整数 API**,支持精确的、无界的 FHE 整数算术运算,消息空间高达 8 位 - **大小高效的公钥加密** - **密文和服务器密钥压缩**,实现高效的数据传输 - **完整的 Rust API、针对 Rust 高级 API 的 C 绑定以及使用 WASM 的客户端 JavaScript API**。 *在[文档](https://docs.zama.org/tfhe-rs)中了解更多关于 TFHE-rs 的特性。*
## 目录 - **[入门指南](#getting-started)** - [Cargo.toml 配置](#cargotoml-configuration) - [一个简单的示例](#a-simple-example) - **[资源](#resources)** - [TFHE 深入探讨](#tfhe-deep-dive) - [教程](#tutorials) - [文档](#documentation) - **[使用 TFHE-rs](#working-with-tfhe-rs)** - [免责声明](#disclaimers) - [引用](#citations) - [贡献](#contributing) - [许可证](#license) - **[支持](#support)**
## 入门指南 ### Cargo.toml 配置 要在你的项目中使用最新版本的 `TFHE-rs`,你首先需要将其作为依赖项添加到你的 `Cargo.toml` 中: ``` tfhe = { version = "*", features = ["boolean", "shortint", "integer"] } ``` ### 一个简单的示例 这是一个完整的示例: ``` use tfhe::prelude::*; use tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32, FheUint8}; fn main() -> Result<(), Box
cargo run --release
### 教程 - [视频教程:使用 TFHE-rs 实现有符号整数](https://www.zama.org/post/video-tutorial-implement-signed-integers-sing-tfhe-rs) - [同构奇偶校验位](https://docs.zama.org/tfhe-rs/tutorials/parity-bit) - [Ascii 字符串上的同构大小写转换](https://docs.zama.org/tfhe-rs/tutorials/ascii-fhe-string) - [使用 TFHE-rs 的布尔 SHA256](https://www.zama.org/post/boolean-sha256-tfhe-rs) - [使用 TFHE-rs 的暗网市场](https://www.zama.org/post/dark-market-tfhe-rs) - [使用 TFHE-rs 的正则表达式引擎](https://www.zama.org/post/regex-engine-tfhe-rs) *在 [TFHE-rs 教程](https://docs.zama.org/tfhe-rs/tutorials)和 [Awesome Zama 仓库](https://github.com/zama-ai/awesome-zama)中探索更多有用的资源。*
### 文档 完整、详尽的文档可在此处获取:[https://docs.zama.org/tfhe-rs](https://docs.zama.org/tfhe-rs)。 ## 使用 TFHE-rs ### 免责声明 #### 安全性评估 安全性评估使用 [Lattice Estimator](https://github.com/malb/lattice-estimator) 完成,参数设置为 `red_cost_model = reduction.RC.BDGL16`。 当 Lattice Estimator 发布新更新时,我们会相应地更新参数。 ### 安全模型 默认情况下,高级 API 中使用的参数集具有失败概率 $\le 2^{-128}$,以便使用我们代码库 [1] 中提供的算法技术在 IND-CPA^D 模型中安全运行。 如果你希望在比 IND-CPA-D 模型宽松的 IND-CPA 安全模型内工作,可以轻松更改参数集,并且会获得稍好的性能。更多细节可以在 [TFHE-rs 文档](https://docs.zama.org/tfhe-rs)中找到。 [1] Bernard, Olivier, et al. "Drifting Towards Better Error Probabilities in Fully Homomorphic Encryption Schemes". https://eprint.iacr.org/2024/1718.pdf [2] Li, Baiyu, et al. "Securing approximate homomorphic encryption using differential privacy." Annual International Cryptology Conference. Cham: Springer Nature Switzerland, 2022. https://eprint.iacr.org/2022/816.pdf #### 旁路攻击 TFHE-rs 尚未实现针对旁路攻击的缓解措施, 这将在即将发布的版本中提供。
### 引用 要在学术论文中引用 TFHE-rs,请使用以下条目: ``` @Misc{TFHE-rs, title={{TFHE-rs: A Pure Rust Implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data}}, author={Zama}, year={2022}, note={\url{https://github.com/zama-ai/tfhe-rs}}, } ``` ### 贡献 有两种方式可以为 TFHE-rs 做贡献: - [提交 Issue](https://github.com/zama-ai/tfhe-rs/issues/new/choose) 以报告 bug 和拼写错误,或提出新想法 - 通过发送电子邮件至 [hello@zama.org](mailto:hello@zama.org) 申请成为官方贡献者。 成为获批贡献者需要签署我们的贡献者许可协议 (CLA)。只有获批的贡献者才能发送 Pull Request,因此请务必在提交前与我们取得联系!
### 许可证 本软件基于 **BSD-3-Clause-Clear** 许可证分发。请阅读[此文](LICENSE)了解更多详情。 #### 常见问题解答 **Zama 的技术可以免费使用吗?** **如果我想将 Zama 的技术用于商业目的,我需要做什么?** **你们会为你们的技术申请知识产权 (IP) 吗?** **你们能针对我的特定用例定制解决方案吗?** ## 支持
标签:FHE, Rust, TFHE, WASM, WebAssembly, Web加密, YAML, Zama, 全同态加密, 加密数据计算, 加密算法, 可编程自举, 可视化界面, 安全多方计算, 安全库, 密码学, 密码学库, 布尔运算, 底层密码学, 手动系统调用, 数据加密, 数据可视化, 整数算术, 机密计算, 网络安全, 网络流量审计, 通知系统, 隐私保护, 隐私计算