https://github.com/zama-ai/tfhe-rs Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this organization All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} zama-ai / tfhe-rs Public * Notifications * Fork 2 * Star 46 TFHE-rs is a pure Rust implementation of TFHE for boolean and small integer arithmetics over encrypted data. License View license 46 stars 2 forks Star Notifications * Code * Issues 5 * Pull requests 2 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights zama-ai/tfhe-rs This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 10 branches 7 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/z] Use Git or checkout with SVN using the web URL. [gh repo clone zama-a] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @jborfila @IceTDrinker jborfila and IceTDrinker doc(core_crypto): gitbook ... f5653f5 Jan 12, 2023 doc(core_crypto): gitbook f5653f5 Git stats * 150 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .cargo chore(tools): add tasks tools to escape latex equations in docs Jan 2, 2023 .config feat(tfhe): new tfhe-rs package, initial commit Nov 10, 2022 .github chore(ci): sync tags from public to internal repo Jan 4, 2023 ci chore(ci): measure and report key sizes used in benchmarks Jan 3, 2023 docker feat(tfhe): js tests, remove server key requirement for shortint PK Jan 2, 2023 scripts feat(tfhe): js tests, remove server key requirement for shortint PK Jan 2, 2023 tasks chore(tools): add tasks tools to escape latex equations in docs Jan 2, 2023 tfhe doc(core_crypto): gitbook Jan 12, 2023 .editorconfig chore(tools): add .editorconfig Jan 4, 2023 .gitbook.yaml feat(tfhe): new tfhe-rs package, initial commit Nov 10, 2022 .gitignore feat(tfhe): new tfhe-rs package, initial commit Nov 10, 2022 Cargo.toml chore(tools): add tasks tools to escape latex equations in docs Jan 2, 2023 LICENSE chore(all): update root licence Dec 2, 2022 Makefile chore(ci): rustdoc warnings as error Jan 5, 2023 README.md docs(tfhe): updated user documentation and API documentation Jan 12, 2023 katex-header.html feat(tfhe): new tfhe-rs package, initial commit Nov 10, 2022 rustfmt.toml feat(tfhe): new tfhe-rs package, initial commit Nov 10, 2022 toolchain.txt chore(tfhe): update check toolchain Jan 2, 2023 View code Getting Started Contributing Credits License Disclaimers Security Estimation Side-Channel Attacks README.md [201107820-b1b861be-6b3f-46cc-bccd-ed051201781a] [6874747073] [6874747073] [6874747073] [6874747073] [6874747073] TFHE-rs is a pure Rust implementation of TFHE for boolean and small integer arithmetics over encrypted data. It includes: * a Rust API * a C API * and a client-side WASM API TFHE-rs is meant for developers and researchers who want full control over what they can do with TFHE, while not having to worry about the low level implementation. The goal is to have a stable, simple, high-performance, and production-ready library for all the advanced features of TFHE. Getting Started To use the latest version of TFHE-rs in your project, you first need to add it as a dependency in your Cargo.toml: * For x86_64-based machines running Unix-like OSes: tfhe = { version = "*", features = ["boolean", "shortint", "x86_64-unix"] } * For Apple Silicon or aarch64-based machines running Unix-like OSes: tfhe = { version = "*", features = ["boolean", "shortint", "aarch64-unix"] } Note: users with ARM devices must use TFHE-rs by compiling using the nightly toolchain. * For x86_64-based machines with the rdseed instruction running Windows: tfhe = { version = "*", features = ["boolean", "shortint", "x86_64"] } Note: aarch64-based machines are not yet supported for Windows as it's currently missing an entropy source to be able to seed the CSPRNGs used in TFHE-rs Here is a full example evaluating a Boolean circuit: use tfhe::boolean::prelude::*; fn main() { // We generate a set of client/server keys, using the default parameters: let (mut client_key, mut server_key) = gen_keys(); // We use the client secret key to encrypt two messages: let ct_1 = client_key.encrypt(true); let ct_2 = client_key.encrypt(false); // We use the server public key to execute a boolean circuit: // if ((NOT ct_2) NAND (ct_1 AND ct_2)) then (NOT ct_2) else (ct_1 AND ct_2) let ct_3 = server_key.not(&ct_2); let ct_4 = server_key.and(&ct_1, &ct_2); let ct_5 = server_key.nand(&ct_3, &ct_4); let ct_6 = server_key.mux(&ct_5, &ct_3, &ct_4); // We use the client key to decrypt the output of the circuit: let output = client_key.decrypt(&ct_6); assert_eq!(output, true); } Another example of how the library can be used with shortints: use tfhe::shortint::prelude::*; fn main() { // We generate a set of client/server keys, using the default parameters: let (client_key, server_key) = gen_keys(Parameters::default()); let msg1 = 1; let msg2 = 0; let modulus = client_key.parameters.message_modulus.0; // We use the client key to encrypt two messages: let ct_1 = client_key.encrypt(msg1); let ct_2 = client_key.encrypt(msg2); // We use the server public key to execute an integer circuit: let ct_3 = server_key.unchecked_add(&ct_1, &ct_2); // We use the client key to decrypt the output of the circuit: let output = client_key.decrypt(&ct_3); assert_eq!(output, (msg1 + msg2) % modulus as u64); } Contributing There are two ways to contribute to TFHE-rs: * you can open issues to report bugs or typos, or to suggest new ideas * you can ask to become an official contributor by emailing hello@zama.ai. (becoming 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! Credits This library uses several dependencies and we would like to thank the contributors of those libraries. License This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at hello@zama.ai. Disclaimers Security Estimation Security estimations are done using the Lattice Estimator with red_cost_model = reduction.RC.BDGL16. When a new update is published in the Lattice Estimator, we update parameters accordingly. Side-Channel Attacks Mitigation for side channel attacks have not yet been implemented in TFHE-rs, and will be released in upcoming versions. About TFHE-rs is a pure Rust implementation of TFHE for boolean and small integer arithmetics over encrypted data. Topics rust cryptography homomorphic-encryption tfhe Resources Readme License View license Stars 46 stars Watchers 1 watching Forks 2 forks Releases 7 TFHE-rs version 0.1.6 Latest Jan 12, 2023 + 6 releases Packages 0 No packages published Contributors 6 * * * * * * Languages * Rust 94.9% * C 3.3% * Makefile 0.6% * Python 0.4% * JavaScript 0.3% * Shell 0.3% * Other 0.2% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.