# What is TFHE-rs?

![](https://3720182160-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwBxNWXyOsQL2MZp4SDQC%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 [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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zama.org/tfhe-rs/tfhe-rs/1.0/get-started/getting_started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
