Skip to content

Commit

Permalink
chore(docs): improve getting started page following feedback
Browse files Browse the repository at this point in the history
- add more details to set-up a rust project from 0 and add TFHE-rs as a
dependency
  • Loading branch information
IceTDrinker committed Oct 2, 2024
1 parent 4a93026 commit 1cb9b73
Showing 1 changed file with 76 additions and 20 deletions.
96 changes: 76 additions & 20 deletions tfhe/docs/getting_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,83 @@

This document explains the basic steps of using the high-level API of **TFHE-rs.**

## Workflow explanation
## Setting up a Rust project

These are the steps to use the **TFHE-rs** high-level API:
If you already know how to set up a Rust project, feel free to go directly to the next [section](#using-tfhe-rs-and-its-apis).

1. [Import the **TFHE-rs** prelude](quick\_start.md#imports)
First, install the Rust programming language tools. Visit https://rustup.rs/ and follow the instructions. For alternative installation methods, refer to the [official Rust installation page](https://rust-lang.github.io/rustup/installation/other.html).

After installing Rust, you can call the build and package manager `Cargo`:

```console
$ cargo --version
cargo 1.81.0 (2dbb1af80 2024-08-20)
```

Your version may differ depending on when you installed Rust. To update your installation, invoke `rustup update`.

Now you can invoke `Cargo` and create a new default Rust project:

```console
$ cargo new tfhe-example
Creating binary (application) `tfhe-example` package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
```

This will create a `tfhe-example` directory and populate it with the following:

```console
$ tree tfhe-example/
tfhe-example/
├── Cargo.toml
└── src
└── main.rs

1 directory, 2 files
```

You now have a minimal Rust project.

In the next section, we'll explain how to add **TFHE-rs** as a dependency to the project and start using it to perform FHE computations.

## Using TFHE-rs and its APIs

To use **TFHE-rs**, you need to add it as a dependency to `tfhe-example`.

The `Cargo.toml` file is located at the root of the project. Initially, the file is minimal and doesn't contain any dependencies:

```toml
[package]
name = "tfhe-example"
version = "0.1.0"
edition = "2021"

[dependencies]
```

For x86 Unix systems, add the following configuration to include **TFHE-rs**:

```toml
tfhe = { version = "0.8.0", features = ["integer", "x86_64-unix"]}
```

Your updated `Cargo.toml` file should look like this:

```toml
[package]
name = "tfhe-example"
version = "0.1.0"
edition = "2021"

[dependencies]
tfhe = { version = "0.8.0", features = ["integer", "x86_64-unix"]}
```

If you are on a different platform please refer to the [installation documentation](installation.md) for configuration options of other supported platforms.

Now that the project has **TFHE-rs** as a dependency here are the detailed steps to use its high-level API:

1. Import the **TFHE-rs** prelude with the following Rust code: `use tfhe::prelude::*;`
2. Client-side: [configure and generate keys](../fundamentals/configure-and-generate-keys.md)
3. Client-side: [encrypt data](../fundamentals/encrypt-data.md)
4. Server-side: [set the server key](../fundamentals/set-the-server-key.md)
Expand Down Expand Up @@ -44,20 +116,4 @@ fn main() {
}
```

The default configuration for x86 Unix machines is as follows:

```toml
tfhe = { version = "0.8.0", features = ["integer", "x86_64-unix"]}
```

Refer to the [installation documentation](installation.md) for configuration options of different platforms.Learn more about homomorphic types features in the [configuration documentation.](../guides/rust\_configuration.md)

## Step1: Importing

**TFHE-rs** uses `traits` to implement consistent APIs and generic functions. To use `traits`, they must be in scope.

The `prelude` pattern provides a convenient way to globally import all important **TFHE-rs** traits at once. This approach saves time and avoids confusion.

```rust
use tfhe::prelude::*;
```
You can learn more about homomorphic types and associated compilation features in the [configuration documentation.](../guides/rust\_configuration.md)

0 comments on commit 1cb9b73

Please sign in to comment.