{"id":13490074,"url":"https://github.com/zama-ai/tfhe-rs","last_synced_at":"2026-03-12T12:14:27.586Z","repository":{"id":63174650,"uuid":"550755640","full_name":"zama-ai/tfhe-rs","owner":"zama-ai","description":"TFHE-rs: A Pure Rust implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data.","archived":false,"fork":false,"pushed_at":"2025-06-27T09:31:22.000Z","size":33313,"stargazers_count":1235,"open_issues_count":42,"forks_count":189,"subscribers_count":21,"default_branch":"main","last_synced_at":"2025-06-27T10:28:27.143Z","etag":null,"topics":["cryptography","homomorphic-encryption","rust","tfhe"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zama-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-10-13T09:20:07.000Z","updated_at":"2025-06-26T16:31:38.000Z","dependencies_parsed_at":"2024-02-12T09:42:15.146Z","dependency_job_id":"6652c580-6409-47d5-b3d8-2c85530b9ed4","html_url":"https://github.com/zama-ai/tfhe-rs","commit_stats":{"total_commits":340,"total_committers":12,"mean_commits":"28.333333333333332","dds":0.3294117647058824,"last_synced_commit":"20f6c5419b6064cbf878b3499aa3fdd1b7343c62"},"previous_names":[],"tags_count":141,"template":false,"template_full_name":null,"purl":"pkg:github/zama-ai/tfhe-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Ftfhe-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Ftfhe-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Ftfhe-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Ftfhe-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zama-ai","download_url":"https://codeload.github.com/zama-ai/tfhe-rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Ftfhe-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262969877,"owners_count":23392530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","homomorphic-encryption","rust","tfhe"],"created_at":"2024-07-31T19:00:40.263Z","updated_at":"2026-03-12T12:14:27.573Z","avatar_url":"https://github.com/zama-ai.png","language":"Rust","funding_links":[],"categories":["Libraries and solutions","Rust","Libraries","Cryptography"],"sub_categories":["Homomorphic Encryption","[Sunscreen](https://sunscreen.tech/)"],"readme":"\u003cp align=\"center\"\u003e\n\u003c!-- product name logo --\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/zama-ai/tfhe-rs/assets/157474013/5283e0ba-da1e-43af-9f2a-c5221367a12b\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/zama-ai/tfhe-rs/assets/157474013/b94a8c96-7595-400b-9311-70765c706955\"\u003e\n  \u003cimg width=600 alt=\"Zama TFHE-rs\"\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\n\u003chr/\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zama-ai/tfhe-rs-handbook/blob/main/tfhe-rs-handbook.pdf\"\u003e 📃 Read Handbook\u003c/a\u003e |\u003ca href=\"https://docs.zama.org/tfhe-rs\"\u003e 📒 Documentation\u003c/a\u003e | \u003ca href=\"https://www.zama.org/community-channels\"\u003e 💛 Community support\u003c/a\u003e | \u003ca href=\"https://github.com/zama-ai/awesome-zama\"\u003e 📚 FHE resources by Zama\u003c/a\u003e\n\u003c/p\u003e\n\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zama-ai/tfhe-rs/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/zama-ai/tfhe-rs?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-BSD--3--Clause--Clear-%23ffb243?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/zama-ai/bounty-program\"\u003e\u003cimg src=\"https://img.shields.io/badge/Contribute-Zama%20Bounty%20Program-%23ffd208?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://slsa.dev\"\u003e\u003cimg alt=\"SLSA 3\" src=\"https://slsa.dev/images/gh-badge-level3.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\n### What is TFHE-rs\n\n**TFHE-rs** is a pure Rust implementation of TFHE for boolean and integer arithmetics over encrypted data.\n\nIt includes:\n- a **Rust** API\n- a **C** API\n- and a **client-side WASM** API\n\nTFHE-rs is designed for developers and researchers who want full control over\nwhat they can do with TFHE, while not having to worry about the low-level\nimplementation. The goal is to have a stable, simple, high-performance, and\nproduction-ready library for all the advanced features of TFHE.\n\u003cbr\u003e\u003c/br\u003e\n\n### Main features\n\n- **Low-level cryptographic library** that implements Zama’s variant of TFHE, including programmable bootstrapping\n- **Implementation of the original TFHE boolean API** that can be used as a drop-in replacement for other TFHE libraries\n- **Short integer API** that enables exact, unbounded FHE integer arithmetics with up to 8 bits of message space\n- **Size-efficient public key encryption**\n- **Ciphertext and server key compression** for efficient data transfer\n- **Full Rust API, C bindings to the Rust High-Level API, and client-side JavaScript API using WASM**.\n\n*Learn more about TFHE-rs features in the [documentation](https://docs.zama.org/tfhe-rs).*\n\u003cbr\u003e\u003c/br\u003e\n\n## Table of Contents\n- **[Getting started](#getting-started)**\n   - [Cargo.toml configuration](#cargotoml-configuration)\n   - [A simple example](#a-simple-example)\n- **[Resources](#resources)**\n   - [TFHE deep dive](#tfhe-deep-dive)\n   - [Tutorials](#tutorials)\n   - [Documentation](#documentation)\n- **[Working with TFHE-rs](#working-with-tfhe-rs)**\n   - [Disclaimers](#disclaimers)\n   - [Citations](#citations)\n   - [Contributing](#contributing)\n   - [License](#license)\n- **[Support](#support)**\n\u003cbr\u003e\u003c/br\u003e\n\n## Getting started\n\n\u003e [!Important]\n\u003e **TFHE-rs** released its first stable version v1.0.0 in February 2025, stabilizing the high-level API for the x86 CPU backend.\n\n### Cargo.toml configuration\nTo use the latest version of `TFHE-rs` in your project, you first need to add it as a dependency in your `Cargo.toml`:\n\n```toml\ntfhe = { version = \"*\", features = [\"boolean\", \"shortint\", \"integer\"] }\n```\n\n\u003e [!Note]\n\u003e Note: You need Rust version 1.91.1 or newer to compile TFHE-rs. You can check your version with `rustc --version`.\n\n\u003e [!Note]\n\u003e Note: AArch64-based machines are not supported for Windows as it's currently missing an entropy source to be able to seed the [CSPRNGs](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) used in TFHE-rs.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n### A simple example\n\nHere is a full example:\n\n``` rust\nuse tfhe::prelude::*;\nuse tfhe::{generate_keys, set_server_key, ConfigBuilder, FheUint32, FheUint8};\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Basic configuration to use homomorphic integers\n    let config = ConfigBuilder::default().build();\n\n    // Key generation\n    let (client_key, server_keys) = generate_keys(config);\n\n    let clear_a = 1344u32;\n    let clear_b = 5u32;\n    let clear_c = 7u8;\n\n    // Encrypting the input data using the (private) client_key\n    // FheUint32: Encrypted equivalent to u32\n    let mut encrypted_a = FheUint32::try_encrypt(clear_a, \u0026client_key)?;\n    let encrypted_b = FheUint32::try_encrypt(clear_b, \u0026client_key)?;\n\n    // FheUint8: Encrypted equivalent to u8\n    let encrypted_c = FheUint8::try_encrypt(clear_c, \u0026client_key)?;\n\n    // On the server side:\n    set_server_key(server_keys);\n\n    // Clear equivalent computations: 1344 * 5 = 6720\n    let encrypted_res_mul = \u0026encrypted_a * \u0026encrypted_b;\n\n    // Clear equivalent computations: 6720 \u003e\u003e 5 = 210\n    encrypted_a = \u0026encrypted_res_mul \u003e\u003e \u0026encrypted_b;\n\n    // Clear equivalent computations: let casted_a = a as u8;\n    let casted_a: FheUint8 = encrypted_a.cast_into();\n\n    // Clear equivalent computations: min(210, 7) = 7\n    let encrypted_res_min = \u0026casted_a.min(\u0026encrypted_c);\n\n    // Operation between clear and encrypted data:\n    // Clear equivalent computations: 7 \u0026 1 = 1\n    let encrypted_res = encrypted_res_min \u0026 1_u8;\n\n    // Decrypting on the client side:\n    let clear_res: u8 = encrypted_res.decrypt(\u0026client_key);\n    assert_eq!(clear_res, 1_u8);\n\n    Ok(())\n}\n```\n\nTo run this code, use the following command:\n\u003cp align=\"center\"\u003e \u003ccode\u003e cargo run --release \u003c/code\u003e \u003c/p\u003e\n\n\u003e [!Note]\n\u003e Note that when running code that uses `TFHE-rs`, it is highly recommended\nto run in release mode with cargo's `--release` flag to have the best performance possible.\n\n*Find an example with more explanations in [this part of the documentation](https://docs.zama.org/tfhe-rs/get-started/quick-start)*\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n\n\n## Resources\n\n### TFHE-rs Handbook\nA document containing scientific and technical details about algorithms implemented into the library is available here: [TFHE-rs: A (Practical) Handbook](https://github.com/zama-ai/tfhe-rs-handbook/blob/main/tfhe-rs-handbook.pdf).\n\n### TFHE deep dive\n- [TFHE Deep Dive - Part I - Ciphertext types](https://www.zama.org/post/tfhe-deep-dive-part-1)\n- [TFHE Deep Dive - Part II - Encodings and linear leveled operations](https://www.zama.org/post/tfhe-deep-dive-part-2)\n- [TFHE Deep Dive - Part III - Key switching and leveled multiplications](https://www.zama.org/post/tfhe-deep-dive-part-3)\n- [TFHE Deep Dive - Part IV - Programmable Bootstrapping](https://www.zama.org/post/tfhe-deep-dive-part-4)\n\u003cbr\u003e\u003c/br\u003e\n\n### Tutorials\n- [Video tutorial: Implement signed integers using TFHE-rs](https://www.zama.org/post/video-tutorial-implement-signed-integers-sing-tfhe-rs)\n- [Homomorphic parity bit](https://docs.zama.org/tfhe-rs/tutorials/parity-bit)\n- [Homomorphic case changing on Ascii string](https://docs.zama.org/tfhe-rs/tutorials/ascii-fhe-string)\n- [Boolean SHA256 with TFHE-rs](https://www.zama.org/post/boolean-sha256-tfhe-rs)\n- [Dark market with TFHE-rs](https://www.zama.org/post/dark-market-tfhe-rs)\n- [Regular expression engine with TFHE-rs](https://www.zama.org/post/regex-engine-tfhe-rs)\n\n*Explore more useful resources in [TFHE-rs tutorials](https://docs.zama.org/tfhe-rs/tutorials) and [Awesome Zama repo](https://github.com/zama-ai/awesome-zama)*\n\u003cbr\u003e\u003c/br\u003e\n### Documentation\n\nFull, comprehensive documentation is available here: [https://docs.zama.org/tfhe-rs](https://docs.zama.org/tfhe-rs).\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n\n## Working with TFHE-rs\n\n### Disclaimers\n\n#### Security estimation\n\nSecurity estimations are done using the\n[Lattice Estimator](https://github.com/malb/lattice-estimator)\nwith `red_cost_model = reduction.RC.BDGL16`.\n\nWhen a new update is published in the Lattice Estimator, we update parameters accordingly.\n\n### Security model\n\nBy default, the parameter sets used in the High-Level API have a failure probability $\\le 2^{-128}$ to securely work in the IND-CPA^D model using the algorithmic techniques provided in our code base [1].\nIf you want to work within the IND-CPA security model, which is less strict than the IND-CPA-D model, the parameter sets can easily be changed and would have slightly better performance. More details can be found in the [TFHE-rs documentation](https://docs.zama.org/tfhe-rs).\n\n[1] Bernard, Olivier, et al. \"Drifting Towards Better Error Probabilities in Fully Homomorphic Encryption Schemes\". https://eprint.iacr.org/2024/1718.pdf\n\n[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\n\n#### Side-channel attacks\n\nMitigation for side-channel attacks has not yet been implemented in TFHE-rs,\nand will be released in upcoming versions.\n\u003cbr\u003e\u003c/br\u003e\n\n### Citations\nTo cite TFHE-rs in academic papers, please use the following entry:\n\n```text\n@Misc{TFHE-rs,\n  title={{TFHE-rs: A Pure Rust Implementation of the TFHE Scheme for Boolean and Integer Arithmetics Over Encrypted Data}},\n  author={Zama},\n  year={2022},\n  note={\\url{https://github.com/zama-ai/tfhe-rs}},\n}\n```\n\n### Contributing\n\nThere are two ways to contribute to TFHE-rs:\n\n- [Open issues](https://github.com/zama-ai/tfhe-rs/issues/new/choose) to report bugs and typos, or to suggest new ideas\n- Request to become an official contributor by emailing [hello@zama.org](mailto:hello@zama.org).\n\nBecoming an approved contributor involves signing our Contributor License Agreement (CLA). Only approved contributors can send pull requests, so please make sure to get in touch before you do!\n\u003cbr\u003e\u003c/br\u003e\n\n### License\nThis software is distributed under the **BSD-3-Clause-Clear** license. Read [this](LICENSE) for more details.\n\n#### FAQ\n**Is Zama’s technology free to use?**\n\u003eZama’s libraries are free to use under the BSD 3-Clause Clear license only for development, research, prototyping, and experimentation purposes. However, for any commercial use of Zama's open source code, companies must purchase Zama’s commercial patent license.\n\u003e\n\u003eEverything we do is open source and we are very transparent on what it means for our users, you can read more about how we monetize our open source products at Zama in [this blogpost](https://www.zama.org/post/open-source).\n\n**What do I need to do if I want to use Zama’s technology for commercial purposes?**\n\u003eTo commercially use Zama’s technology you need to be granted Zama’s patent license. Please contact us hello@zama.org for more information.\n\n**Do you file IP on your technology?**\n\u003eYes, all Zama’s technologies are patented.\n\n**Can you customize a solution for my specific use case?**\n\u003eWe are open to collaborating and advancing the FHE space with our partners. If you have specific needs, please email us at hello@zama.org.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n\n## Support\n\n\u003ca target=\"_blank\" href=\"https://community.zama.org\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/zama-ai/tfhe-rs/assets/157474013/08656d0a-3f44-4126-b8b6-8c601dff5380\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/zama-ai/tfhe-rs/assets/157474013/1c9c9308-50ac-4aab-a4b9-469bb8c536a4\"\u003e\n  \u003cimg alt=\"Support\"\u003e\n\u003c/picture\u003e\n\u003c/a\u003e\n\n🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzama-ai%2Ftfhe-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzama-ai%2Ftfhe-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzama-ai%2Ftfhe-rs/lists"}