Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc regroup #2092

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions tasks/src/check_tfhe_docs_are_tested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,18 @@ pub fn check_tfhe_docs_are_tested() -> Result<(), Error> {
}

let difference = doc_files.difference(&tested_files);
let files_that_may_not_exist = tested_files.difference(&doc_files);
let files_that_dont_exist: Vec<_> = files_that_may_not_exist
.into_iter()
.filter(|p| !p.exists())
.collect();

let debug_format = format!("missing file from user doc tests: {difference:#?}");
let debug_format = format!(
"missing file from user doc tests: {difference:#?}\n\
files that are tested but don't exist: {files_that_dont_exist:#?}"
);

if difference.count() != 0 {
if difference.count() != 0 || !files_that_dont_exist.is_empty() {
return Err(Error::new(ErrorKind::NotFound, debug_format));
}

Expand Down
17 changes: 13 additions & 4 deletions tfhe/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,27 @@ layout:

Learn the basics of TFHE-rs, set it up, and make it run with ease.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>What is TFHE-rs?</strong></td><td>Understand TFHE-rs library and basic cryptographic concepts</td><td><a href="getting_started/readme.md">getting_started.md</a></td><td><a href=".gitbook/assets/start1.png">start1.png</a></td></tr><tr><td><strong>Installation</strong></td><td>Follow the step by step guide to import TFHE-rs in your project</td><td><a href="getting_started/installation.md">installation.md</a></td><td><a href=".gitbook/assets/start2.png">start2.png</a></td></tr><tr><td><strong>Quick start</strong></td><td>See a full example of using TFHE-rs to compute on encrypted data</td><td><a href="getting_started/quick_start.md">quick_start.md</a></td><td><a href=".gitbook/assets/start3.png">start3.png</a></td></tr></tbody></table>
<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>What is TFHE-rs?</strong></td><td>Understand TFHE-rs library and basic cryptographic concepts</td><td><a href="getting_started/">getting_started</a></td><td><a href=".gitbook/assets/start1.png">start1.png</a></td></tr><tr><td><strong>Installation</strong></td><td>Follow the step by step guide to import TFHE-rs in your project</td><td><a href="getting_started/installation.md">installation.md</a></td><td><a href=".gitbook/assets/start2.png">start2.png</a></td></tr><tr><td><strong>Quick start</strong></td><td>See a full example of using TFHE-rs to compute on encrypted data</td><td><a href="getting_started/quick_start.md">quick_start.md</a></td><td><a href=".gitbook/assets/start3.png">start3.png</a></td></tr></tbody></table>

## Build with TFHE-rs

Start building with TFHE-rs by exploring its core features, discovering essential guides, and learning more with user-friendly tutorials.

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Fundamentals</strong></td><td>Explore the core features.</td><td><ul><li><a href="fundamentals/configure-and-generate-keys.md">Configure</a></li><li><a href="fundamentals/encrypt-data.md">Encrypt data</a></li></ul></td><td><a href=".gitbook/assets/build1.png">build1.png</a></td></tr><tr><td><strong>Guides</strong></td><td>Deploy your project.</td><td><ul><li><a href="guides/run_on_gpu.md">Run on GPU</a></li><li><a href="guides/rust_configuration.md">Configure Rust</a></li></ul></td><td><a href=".gitbook/assets/build2.png">build2.png</a></td></tr><tr><td><strong>Tutorials</strong></td><td>Learn more with tutorials.</td><td><ul><li><a href="tutorials/see-all-tutorials.md#start-here">Start here</a></li><li><a href="tutorials/see-all-tutorials.md#go-further">Go further</a></li></ul></td><td><a href=".gitbook/assets/build3.png">build3.png</a></td></tr></tbody></table>
<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>FHE Computations</strong></td><td>Run FHE computation on encrypted data.</td><td><ul><li><a href="fhe-computation/types/">Types </a></li><li><a href="fhe-computation/operations/">Operations</a></li></ul></td><td><a href=".gitbook/assets/build1.png">build1.png</a></td></tr><tr><td><strong>Configuration</strong></td><td>Advanced configuration for better performance.</td><td><ul><li><a href="configuration/rust_configuration.md">Advanced Rust </a></li><li><a href="configuration/run_on_gpu.md">GPU acceleration</a></li></ul></td><td><a href=".gitbook/assets/build2.png">build2.png</a></td></tr><tr><td><strong>Integration</strong></td><td>Use TFHE-rs in different contexts or platforms..</td><td><ul><li><a href="integration/c_api.md">C API</a></li><li><a href="integration/js_on_wasm_api.md">JS on WASM API</a></li></ul></td><td><a href=".gitbook/assets/build3.png">build3.png</a></td></tr></tbody></table>

## Explore more

Access to additional resources and join the Zama community.

### Tutorials

Explore step-by-step guides that walk you through real-world uses of TFHE-rs.&#x20;

* [Homomorphic parity bit](tutorials/parity_bit.md): Learn how to implement a parity bit calculation over encrypted data
* [Homomorphic case changing on ASCII string](tutorials/ascii_fhe_string.md): See how to process string data securely by changing cases while keeping the data encrypted.
* [SHA256 with Boolean API](tutorials/sha256_bool.md): Delve into a more complex example: implementing the SHA256 hash function entirely on encrypted boolean values.
* [All tutorials](tutorials/see-all-tutorials.md): A complete list of all available tutorials in one place.tutorials: A complete list of all available tutorials in one place.

### References & Explanations

Take a deep dive into TFHE-rs, exploring APIs from the highest to the lowest level of abstraction and accessing additional resources for in-depth explanations.
Expand All @@ -56,8 +65,8 @@ Collaborate with us to advance the FHE spaces and drive innovation together.

* [Contribute to TFHE-rs](dev/contributing.md)
* [Check the latest release note](https://github.com/zama-ai/tfhe-rs/releases)
* [Request a feature](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=feature\_request\&projects=\&template=feature\_request.md\&title=)
* [Report a bug](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=triage\_required\&projects=\&template=bug\_report.md\&title=)
* [Request a feature](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=feature_request\&projects=\&template=feature_request.md\&title=)
* [Report a bug](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=triage_required\&projects=\&template=bug_report.md\&title=)

***

Expand Down
103 changes: 59 additions & 44 deletions tfhe/docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,73 @@

## Get Started

* [What is TFHE-rs?](getting\_started/readme.md)
* [Installation](getting\_started/installation.md)
* [Quick start](getting\_started/quick\_start.md)
* [Types & Operations](getting\_started/operations.md)
* [Benchmarks](getting\_started/benchmarks/summary.md)
* [CPU Benchmarks](getting\_started/benchmarks/cpu\_benchmarks.md)
* [GPU Benchmarks](getting\_started/benchmarks/gpu\_benchmarks.md)
* [What is TFHE-rs?](getting_started/readme.md)
* [Installation](getting_started/installation.md)
* [Quick start](getting_started/quick_start.md)
* [Benchmarks](getting_started/benchmarks/summary.md)
* [CPU Benchmarks](getting_started/benchmarks/cpu_benchmarks.md)
* [GPU Benchmarks](getting_started/benchmarks/gpu_benchmarks.md)
* [Zero-knowledge proof benchmarks](getting_started/benchmarks/zk_proof_benchmarks.md)
* [Security and cryptography](getting\_started/security\_and\_cryptography.md)

## Fundamentals

* [Configuration and key generation](fundamentals/configure-and-generate-keys.md)
* [Server key](fundamentals/set-the-server-key.md)
* [Encryption](fundamentals/encrypt-data.md)
* [Computation on encrypted data](fundamentals/compute.md)
* [Decryption](fundamentals/decrypt-data.md)
* [Encrypted pseudo random values](fundamentals/encrypted-prf.md)
* [Serialization/deserialization](fundamentals/serialization.md)
* [Compressing ciphertexts/keys](fundamentals/compress.md)
* [Debugging](fundamentals/debug.md)

## Guides

* [Rust configuration](guides/rust\_configuration.md)
* [GPU acceleration](guides/run\_on\_gpu.md)
* [Overflow detection](guides/overflow\_operations.md)
* [Data versioning](guides/data\_versioning.md)
* [Public key encryption](guides/public\_key.md)
* [Zero-knowledge proofs](guides/zk-pok.md)
* [Generic trait bounds](guides/trait\_bounds.md)
* [Parallelized PBS](guides/parallelized\_pbs.md)
* [High-level API in C](guides/c\_api.md)
* [JS on WASM API](guides/js\_on\_wasm\_api.md)
* [Multi-threading with Rayon crate](guides/rayon\_crate.md)
* [Trivial ciphertexts](guides/trivial\_ciphertext.md)
* [PBS statistics](guides/pbs-stats.md)
* [Array](guides/array.md)
* [Strings](guides/strings.md)
* [Security and cryptography](getting_started/security_and_cryptography.md)

## FHE Computation

* [Types](fhe-computation/types/README.md)
* [Integer](fhe-computation/types/integer.md)
* [Strings](fhe-computation/types/strings.md)
* [Array](fhe-computation/types/array.md)
* [Operations](fhe-computation/operations/README.md)
* [Arithmetic operations](fhe-computation/operations/arithmetic-operations.md)
* [Bitwise operations](fhe-computation/operations/bitwise-operations.md)
* [Comparison operations](fhe-computation/operations/comparison-operations.md)
* [Min/Max operations](fhe-computation/operations/min-max-operations.md)
* [Ternary conditional operations](fhe-computation/operations/ternary-conditional-operations.md)
* [Casting operations](fhe-computation/operations/casting-operations.md)
* [Boolean Operations](fhe-computation/operations/boolean-operations.md)
* [Core workflow](fhe-computation/compute/README.md)
* [Configuration and key generation](fhe-computation/compute/configure-and-generate-keys.md)
* [Server key](fhe-computation/compute/set-the-server-key.md)
* [Encryption](fhe-computation/compute/encrypt-data.md)
* [Decryption](fhe-computation/compute/decrypt-data.md)
* [Data handling](fhe-computation/data-handling/README.md)
* [Compressing ciphertexts/keys](fhe-computation/data-handling/compress.md)
* [Serialization/deserialization](fhe-computation/data-handling/serialization.md)
* [Data versioning](fhe-computation/data-handling/data_versioning.md)
* [Advanced features](fhe-computation/advanced-features/README.md)
* [Encrypted pseudo random values](fhe-computation/advanced-features/encrypted-prf.md)
* [Overflow detection](fhe-computation/advanced-features/overflow_operations.md)
* [Public key encryption](fhe-computation/advanced-features/public_key.md)
* [Trivial ciphertexts](fhe-computation/advanced-features/trivial_ciphertext.md)
* [Zero-knowledge proofs](fhe-computation/advanced-features/zk-pok.md)
* [Multi-threading with Rayon crate](fhe-computation/advanced-features/rayon_crate.md)
* [Tooling](fhe-computation/tooling/README.md)
* [PBS statistics](fhe-computation/tooling/pbs-stats.md)
* [Generic trait bounds](fhe-computation/tooling/trait_bounds.md)
* [Debugging](fhe-computation/tooling/debug.md)

## Configuration

* [Advanced Rust setup](configuration/rust_configuration.md)
* [GPU acceleration](configuration/run_on_gpu.md)
* [Parallelized PBS](configuration/parallelized_pbs.md)

## Integration

* [JS on WASM API](integration/js_on_wasm_api.md)
* [High-level API in C](integration/c_api.md)

## Tutorials

* [Homomorphic parity bit](tutorials/parity_bit.md)
* [Homomorphic case changing on Ascii string](tutorials/ascii_fhe_string.md)
* [SHA256 with Boolean API](tutorials/sha256_bool.md)
* [All tutorials](tutorials/see-all-tutorials.md)
* [Homomorphic parity bit](tutorials/parity\_bit.md)
* [Homomorphic case changing on Ascii string](tutorials/ascii\_fhe\_string.md)
* [SHA256 with Boolean API](tutorials/sha256\_bool.md)

## References

* [API references](https://docs.rs/tfhe/latest/tfhe/)
* [Fine-grained APIs](references/fine-grained-apis/README.md)
* [Quick start](references/fine-grained-apis/quick\_start.md)
* [Quick start](references/fine-grained-apis/quick_start.md)
* [Boolean](references/fine-grained-apis/boolean/README.md)
* [Operations](references/fine-grained-apis/boolean/operations.md)
* [Cryptographic parameters](references/fine-grained-apis/boolean/parameters.md)
Expand All @@ -80,5 +95,5 @@

* [Contributing](dev/contributing.md)
* [Release note](https://github.com/zama-ai/tfhe-rs/releases)
* [Feature request](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=feature\_request\&projects=\&template=feature\_request.md\&title=)
* [Bug report](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=triage\_required\&projects=\&template=bug\_report.md\&title=)
* [Feature request](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=feature_request\&projects=\&template=feature_request.md\&title=)
* [Bug report](https://github.com/zama-ai/tfhe-rs/issues/new?assignees=\&labels=triage_required\&projects=\&template=bug_report.md\&title=)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Parallelized PBS

This document describes the implementation and benefits of parallelized [Programmable Bootstrapping](../getting\_started/security\_and\_cryptography.md) (PBS) in **TFHE-rs**, including code examples for using multi-bit PBS parameters and ensuring deterministic execution.
This document describes the implementation and benefits of parallelized [Programmable Bootstrapping](../getting_started/security_and_cryptography.md) (PBS) in **TFHE-rs**, including code examples for using multi-bit PBS parameters and ensuring deterministic execution.

## Parallelized Programmable Bootstrapping

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ This guide explains how to update your existing program to leverage GPU accelera
* [gcc](https://gcc.gnu.org/) >= 8.0 - check this [page](https://gist.github.com/ax3l/9489132) for more details about nvcc/gcc compatible versions
* [cmake](https://cmake.org/) >= 3.24
* libclang, to match Rust bingen [requirements](https://rust-lang.github.io/rust-bindgen/requirements.html) >= 9.0
* Rust version - check this [page](rust\_configuration.md)
* Rust version - check this [page](rust_configuration.md)

## Importing to your project

To use the **TFHE-rs** GPU backend in your project, add the following dependency in your `Cargo.toml`.


```toml
tfhe = { version = "1.0.0", features = ["boolean", "shortint", "integer", "gpu"] }
```
Expand All @@ -31,7 +30,7 @@ For optimal performance when using **TFHE-rs**, run your code in release mode wi
**TFHE-rs** GPU backend is supported on Linux (x86, aarch64).

| OS | x86 | aarch64 |
|---------|-------------|---------------|
| ------- | ----------- | ------------- |
| Linux | Supported | Supported\* |
| macOS | Unsupported | Unsupported\* |
| Windows | Unsupported | Unsupported |
Expand All @@ -40,7 +39,7 @@ For optimal performance when using **TFHE-rs**, run your code in release mode wi

### Configuring and creating keys.

Comparing to the [CPU example](../getting\_started/quick\_start.md), GPU set up differs in the key creation, as detailed [here](run\_on\_gpu.md#Setting-the-keys)
Comparing to the [CPU example](../getting_started/quick_start.md), GPU set up differs in the key creation, as detailed [here](run\_on\_gpu.md#setting-the-keys)

Here is a full example (combining the client and server parts):

Expand Down Expand Up @@ -77,9 +76,7 @@ fn main() {
}
```

Beware that when the GPU feature is activated, when calling: `let config = ConfigBuilder::default().build();`,
the cryptographic parameters differ from the CPU ones, used when the GPU feature is not activated.
Indeed, TFHE-rs uses dedicated parameters for the GPU in order to achieve better performance.
Beware that when the GPU feature is activated, when calling: `let config = ConfigBuilder::default().build();`, the cryptographic parameters differ from the CPU ones, used when the GPU feature is not activated. Indeed, TFHE-rs uses dedicated parameters for the GPU in order to achieve better performance.

### Setting the keys

Expand All @@ -103,7 +100,7 @@ On the client-side, the method to encrypt the data is exactly the same than the

The server first need to set up its keys with `set_server_key(gpu_key)`.

Then, homomorphic computations are performed using the same approach as the [CPU operations](../getting\_started/operations.md).
Then, homomorphic computations are performed using the same approach as the [CPU operations](../fhe-computation/operations/README.md).

```Rust
//Server-side
Expand Down Expand Up @@ -131,7 +128,7 @@ Finally, the client decrypts the results using:
The GPU backend includes the following operations for both signed and unsigned encrypted integers:

| name | symbol | `Enc`/`Enc` | `Enc`/ `Int` |
|-----------------------|----------------|----------------------------|----------------------------|
| --------------------- | -------------- | -------------------------- | -------------------------- |
| Neg | `-` | :heavy\_check\_mark: | N/A |
| Add | `+` | :heavy\_check\_mark: | :heavy\_check\_mark: |
| Sub | `-` | :heavy\_check\_mark: | :heavy\_check\_mark: |
Expand All @@ -157,31 +154,32 @@ The GPU backend includes the following operations for both signed and unsigned e
| Cast (from src type) | `cast_from` | :heavy\_multiplication\_x: | N/A |
| Ternary operator | `select` | :heavy\_check\_mark: | :heavy\_multiplication\_x: |


{% hint style="info" %}
All operations follow the same syntax than the one described in [here](../getting\_started/operations.md).
All operations follow the same syntax than the one described in [here](../fhe-computation/operations/README.md).
{% endhint %}

## Multi-GPU support

TFHE-rs supports platforms with multiple GPUs. There is **nothing to change in the code to execute on such platforms**. To keep the API as user-friendly as possible, the configuration is automatically set, i.e., the user has no fine-grained control over the number of GPUs to be used.

## Benchmark
## Benchmark

Please refer to the [GPU benchmarks](../getting_started/benchmarks/gpu_benchmarks.md) for detailed performance benchmark results.

## Warning

When measuring GPU times on your own on Linux, set the environment variable `CUDA_MODULE_LOADING=EAGER` to avoid CUDA API overheads during the first kernel execution.

## Compressing ciphertexts after some homomorphic computation on the GPU

You can compress ciphertexts using the GPU, even after computations, just like on the [CPU](../fundamentals/compress.md#compression-ciphertexts-after-some-homomorphic-computation).
You can compress ciphertexts using the GPU, even after computations, just like on the [CPU](../fhe-computation/data-handling/compress.md#compression-ciphertexts-after-some-homomorphic-computation).

The way to do it is very similar to how it's done on the CPU. The following example shows how to compress and decompress a list containing 4 messages:

The way to do it is very similar to how it's done on the CPU.
The following example shows how to compress and decompress a list containing 4 messages:
- One 32-bits integer
- One 64-bit integer
- One Boolean
- One 2-bit integer
* One 32-bits integer
* One 64-bit integer
* One Boolean
* One 2-bit integer

```rust
use tfhe::prelude::*;
Expand Down Expand Up @@ -246,7 +244,8 @@ fn main() {

## Array types

It is possible to use array types on GPU, just as [on CPU](array.md). Here is an example showing how to do it:
It is possible to use array types on GPU, just as [on CPU](../fhe-computation/types/array.md). Here is an example showing how to do it:

```rust
use tfhe::{ConfigBuilder, set_server_key, ClearArray, ClientKey, CompressedServerKey};
use tfhe::array::GpuFheUint32Array;
Expand Down
Loading
Loading