> For the complete documentation index, see [llms.txt](https://docs.zama.org/tfhe-rs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/tfhe-rs/tfhe-rs/0.7-1/get-started/getting_started.md).

# What is TFHE-rs?

![](https://2926672354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lncwOydNiUtyylsQLpc%2Fuploads%2Fgit-blob-eac33320ca51f7e916bfabfee8f6cb149e507748%2Fdoc_header_tfhe-rs.png?alt=media)

**TFHE-rs** is a pure Rust implementation of Fully Homomorphic Encryption over the Torus (TFHE) to perform Boolean and integer arithmetic on encrypted data.

**TFHE-rs** implements advanced TFHE features, empowering developers and researchers with fine-grained control over TFHE so that they can focus on high-level functionality without delving into low-level implementation.

**TFHE-rs** includes:

* **Rust API**: the primary API for working with **TFHE-rs** in Rust projects.
* **C API**: for developers who prefer to use C.
* **Client-side WASM API**: to integrate **TFHE-rs** functionalities into WebAssembly applications.

## Key cryptographic concepts

TFHE is a Fully Homomorphic Encryption (FHE) scheme based on Learning With Errors (LWE), which is a secure cryptographic primitive against even quantum computers. The **TFHE-rs** library implements Zama’s variant of TFHE.

#### Homomorphic Encryption Basics

The basic elements of cryptography:

* **Message (or Cleartext):** raw values before encryption.
* **Plaintext:** encoded messages.
* **Ciphertext**: encrypted messages.

FHE allows to compute on ciphertexts without revealing the content of the messages. A scheme is fully homomorphic if it supports at least two of the following operations when evaluating any programs. ($$x$$ is a plaintext and $$E\[x]$$ is the corresponding ciphertext):

* **Homomorphic univariate function evaluation:** $$f(E\[x]) = E\[f(x)]$$
* **Homomorphic addition:** $$E\[x] + E\[y] = E\[x + y]$$
* **Homomorphic multiplication:** $$E\[x] \* E\[y] = E\[x \* y]$$

## Zama's variant of TFHE

Zama's variant of TFHE is a fully homomorphic scheme that takes fixed-precision numbers as messages. It implements all homomorphic operations needed, such as addition and function evaluation via Programmable Bootstrapping.

Refer to the the [preliminary whitepaper](https://whitepaper.zama.ai/) for more details.

Using **TFHE-rs** in Rust includes the following steps:

1. **Key generation**: generate a pair of keys using secure parameters.
   * **Client key**: used for encryption and decryption of data. This key must be kept secret.
   * **Server key (or Evaluation key)**: used for performing operations on encrypted data. This key could be public.
2. **Encryption**: encrypt plaintexts using the client key to produce ciphertexts.
3. **Homomorphic operation**: perform operations on ciphertexts using the server key.
4. **Decryption**: decrypt the resulting ciphertexts back to plaintexts using the client key.

To understand more about FHE applications, see the [6-minute introduction to homomorphic encryption](https://6min.zama.ai/).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/tfhe-rs/tfhe-rs/0.7-1/get-started/getting_started.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
