tfhe 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/README.md +141 -58
  2. package/package.json +1 -1
  3. package/tfhe.d.ts +2776 -425
  4. package/tfhe.js +7542 -176
  5. package/tfhe_bg.wasm +0 -0
package/README.md CHANGED
@@ -1,41 +1,71 @@
1
1
  <p align="center">
2
2
  <!-- product name logo -->
3
- <img width=600 src="https://user-images.githubusercontent.com/5758427/231206749-8f146b97-3c5a-4201-8388-3ffa88580415.png">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/zama-ai/tfhe-rs/assets/157474013/5283e0ba-da1e-43af-9f2a-c5221367a12b">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/zama-ai/tfhe-rs/assets/157474013/b94a8c96-7595-400b-9311-70765c706955">
6
+ <img width=600 alt="Zama TFHE-rs">
7
+ </picture>
4
8
  </p>
9
+
5
10
  <hr/>
11
+
6
12
  <p align="center">
7
- <a href="https://docs.zama.ai/tfhe-rs"> 📒 Read documentation</a> | <a href="https://zama.ai/community"> 💛 Community support</a> | <a href="https://github.com/zama-ai/awesome-zama"> 📚 FHE resources</a>
13
+ <a href="https://docs.zama.ai/tfhe-rs"> 📒 Documentation</a> | <a href="https://zama.ai/community"> 💛 Community support</a> | <a href="https://github.com/zama-ai/awesome-zama"> 📚 FHE resources by Zama</a>
8
14
  </p>
15
+
16
+
9
17
  <p align="center">
10
- <!-- Version badge using shields.io -->
11
- <a href="https://github.com/zama-ai/tfhe-rs/releases">
12
- <img src="https://img.shields.io/github/v/release/zama-ai/tfhe-rs?style=flat-square">
13
- </a>
14
- <!-- Link to tutorials badge using shields.io -->
15
- <a href="#license">
16
- <img src="https://img.shields.io/badge/License-BSD--3--Clause--Clear-orange?style=flat-square">
17
- </a>
18
- <!-- Zama Bounty Program -->
19
- <a href="https://github.com/zama-ai/bounty-program">
20
- <img src="https://img.shields.io/badge/Contribute-Zama%20Bounty%20Program-yellow?style=flat-square">
21
- </a>
18
+ <a href="https://github.com/zama-ai/tfhe-rs/releases"><img src="https://img.shields.io/github/v/release/zama-ai/tfhe-rs?style=flat-square"></a>
19
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-BSD--3--Clause--Clear-%23ffb243?style=flat-square"></a>
20
+ <a href="https://github.com/zama-ai/bounty-program"><img src="https://img.shields.io/badge/Contribute-Zama%20Bounty%20Program-%23ffd208?style=flat-square"></a>
22
21
  </p>
23
- <hr/>
24
22
 
23
+ ## About
24
+
25
+ ### What is TFHE-rs
25
26
 
26
- **TFHE-rs** is a pure Rust implementation of TFHE for boolean and integer
27
- arithmetics over encrypted data. It includes:
28
- - a **Rust** API
29
- - a **C** API
30
- - and a **client-side WASM** API
27
+ **TFHE-rs** is a pure Rust implementation of TFHE for boolean and integer arithmetics over encrypted data.
31
28
 
32
- **TFHE-rs** is meant for developers and researchers who want full control over
33
- what they can do with TFHE, while not having to worry about the low level
29
+ It includes:
30
+ - a **Rust** API
31
+ - a **C** API
32
+ - and a **client-side WASM** API
33
+
34
+ TFHE-rs is designed for developers and researchers who want full control over
35
+ what they can do with TFHE, while not having to worry about the low-level
34
36
  implementation. The goal is to have a stable, simple, high-performance, and
35
37
  production-ready library for all the advanced features of TFHE.
38
+ <br></br>
39
+
40
+ ### Main features
41
+
42
+ - **Low-level cryptographic library** that implements Zama’s variant of TFHE, including programmable bootstrapping
43
+ - **Implementation of the original TFHE boolean API** that can be used as a drop-in replacement for other TFHE libraries
44
+ - **Short integer API** that enables exact, unbounded FHE integer arithmetics with up to 8 bits of message space
45
+ - **Size-efficient public key encryption**
46
+ - **Ciphertext and server key compression** for efficient data transfer
47
+ - **Full Rust API, C bindings to the Rust High-Level API, and client-side Javascript API using WASM**.
48
+
49
+ *Learn more about TFHE-rs features in the [documentation](https://docs.zama.ai/tfhe-rs/readme).*
50
+ <br></br>
51
+
52
+ ## Table of Contents
53
+ - **[Getting Started](#getting-started)**
54
+ - [Cargo.toml configuration](#cargotoml-configuration)
55
+ - [A simple example](#a-simple-example)
56
+ - **[Resources](#resources)**
57
+ - [TFHE deep dive](#tfhe-deep-dive)
58
+ - [Tutorials](#tutorials)
59
+ - [Documentation](#documentation)
60
+ - **[Working with TFHE-rs](#working-with-tfhe-rs)**
61
+ - [Disclaimers](#disclaimers)
62
+ - [Citations](#citations)
63
+ - [Contributing](#contributing)
64
+ - [License](#license)
65
+ - **[Support](#support)**
66
+ <br></br>
36
67
 
37
68
  ## Getting Started
38
- The steps to run a first example are described below.
39
69
 
40
70
  ### Cargo.toml configuration
41
71
  To use the latest version of `TFHE-rs` in your project, you first need to add it as a dependency in your `Cargo.toml`:
@@ -51,20 +81,24 @@ tfhe = { version = "*", features = ["boolean", "shortint", "integer", "x86_64-un
51
81
  ```toml
52
82
  tfhe = { version = "*", features = ["boolean", "shortint", "integer", "aarch64-unix"] }
53
83
  ```
54
- Note: users with ARM devices must compile `TFHE-rs` using a stable toolchain with version >= 1.72.
55
-
56
84
 
57
- + For x86_64-based machines with the [`rdseed instruction`](https://en.wikipedia.org/wiki/RDRAND)
58
- running Windows:
85
+ + For x86_64-based machines with the [`rdseed instruction`](https://en.wikipedia.org/wiki/RDRAND) running Windows:
59
86
 
60
87
  ```toml
61
88
  tfhe = { version = "*", features = ["boolean", "shortint", "integer", "x86_64"] }
62
89
  ```
63
90
 
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](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) used in TFHE-rs.
91
+ > [!Note]
92
+ > Note: You need to use a Rust version >= 1.73 to compile TFHE-rs.
65
93
 
94
+ > [!Note]
95
+ > 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](https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator) used in TFHE-rs.
66
96
 
67
- ## A simple example
97
+ <p align="right">
98
+ <a href="#about" > ↑ Back to top </a>
99
+ </p>
100
+
101
+ ### A simple example
68
102
 
69
103
  Here is a full example:
70
104
 
@@ -97,13 +131,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
97
131
  // Clear equivalent computations: 1344 * 5 = 6720
98
132
  let encrypted_res_mul = &encrypted_a * &encrypted_b;
99
133
 
100
- // Clear equivalent computations: 1344 >> 5 = 42
134
+ // Clear equivalent computations: 6720 >> 5 = 210
101
135
  encrypted_a = &encrypted_res_mul >> &encrypted_b;
102
136
 
103
137
  // Clear equivalent computations: let casted_a = a as u8;
104
138
  let casted_a: FheUint8 = encrypted_a.cast_into();
105
139
 
106
- // Clear equivalent computations: min(42, 7) = 7
140
+ // Clear equivalent computations: min(210, 7) = 7
107
141
  let encrypted_res_min = &casted_a.min(&encrypted_c);
108
142
 
109
143
  // Operation between clear and encrypted data:
@@ -121,34 +155,70 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
121
155
  To run this code, use the following command:
122
156
  <p align="center"> <code> cargo run --release </code> </p>
123
157
 
124
- Note that when running code that uses `tfhe-rs`, it is highly recommended
158
+ > [!Note]
159
+ > Note that when running code that uses `TFHE-rs`, it is highly recommended
125
160
  to run in release mode with cargo's `--release` flag to have the best performances possible.
126
161
 
162
+ *Find an example with more explanations in [this part of the documentation](https://docs.zama.ai/tfhe-rs/getting-started/quick_start)*
127
163
 
128
- ## Contributing
164
+ <p align="right">
165
+ <a href="#about" > ↑ Back to top </a>
166
+ </p>
129
167
 
130
- There are two ways to contribute to TFHE-rs:
131
168
 
132
- - you can open issues to report bugs or typos, or to suggest new ideas
133
- - you can ask to become an official contributor by emailing [hello@zama.ai](mailto:hello@zama.ai).
134
- (becoming an approved contributor involves signing our Contributor License Agreement (CLA))
135
169
 
136
- Only approved contributors can send pull requests, so please make sure to get in touch before you do!
170
+ ## Resources
137
171
 
138
- ## Credits
172
+ ### TFHE deep dive
173
+ - [TFHE Deep Dive - Part I - Ciphertext types](https://www.zama.ai/post/tfhe-deep-dive-part-1)
174
+ - [TFHE Deep Dive - Part II - Encodings and linear leveled operations](https://www.zama.ai/post/tfhe-deep-dive-part-2)
175
+ - [TFHE Deep Dive - Part III - Key switching and leveled multiplications](https://www.zama.ai/post/tfhe-deep-dive-part-3)
176
+ - [TFHE Deep Dive - Part IV - Programmable Bootstrapping](https://www.zama.ai/post/tfhe-deep-dive-part-4)
177
+ <br></br>
139
178
 
140
- This library uses several dependencies and we would like to thank the contributors of those
141
- libraries.
179
+ ### Tutorials
180
+ - [[Video tutorial] Implement signed integers using TFHE-rs ](https://www.zama.ai/post/video-tutorial-implement-signed-integers-ssing-tfhe-rs)
181
+ - [Homomorphic parity bit](https://docs.zama.ai/tfhe-rs/tutorials/parity_bit)
182
+ - [Homomorphic case changing on Ascii string](https://docs.zama.ai/tfhe-rs/tutorials/ascii_fhe_string)
183
+ - [Boolean SHA256 with TFHE-rs](https://www.zama.ai/post/boolean-sha256-tfhe-rs)
184
+ - [Dark market with TFHE-rs](https://www.zama.ai/post/dark-market-tfhe-rs)
185
+ - [Regular expression engine with TFHE-rs](https://www.zama.ai/post/regex-engine-tfhe-rs)
142
186
 
143
- ## Need support?
144
- <a target="_blank" href="https://community.zama.ai">
145
- <img src="https://github.com/zama-ai/tfhe-rs/assets/157474013/33d856dc-f25d-454b-a010-af12bff2aa7d">
146
- </a>
187
+ *Explore more useful resources in [TFHE-rs tutorials](https://docs.zama.ai/tfhe-rs/tutorials) and [Awesome Zama repo](https://github.com/zama-ai/awesome-zama)*
188
+ <br></br>
189
+ ### Documentation
190
+
191
+ Full, comprehensive documentation is available here: [https://docs.zama.ai/tfhe-rs](https://docs.zama.ai/tfhe-rs).
192
+ <p align="right">
193
+ <a href="#about" > ↑ Back to top </a>
194
+ </p>
147
195
 
148
196
 
197
+ ## Working with TFHE-rs
149
198
 
150
- ## Citing TFHE-rs
199
+ ### Disclaimers
200
+
201
+ #### Security Estimation
202
+
203
+ Security estimations are done using the
204
+ [Lattice Estimator](https://github.com/malb/lattice-estimator)
205
+ with `red_cost_model = reduction.RC.BDGL16`.
151
206
 
207
+ When a new update is published in the Lattice Estimator, we update parameters accordingly.
208
+
209
+ ### Security Model
210
+
211
+ The default parameters for the TFHE-rs library are chosen considering the IND-CPA security model, and are selected with a bootstrapping failure probability fixed at p_error = $2^{-40}$. In particular, it is assumed that the results of decrypted computations are not shared by the secret key owner with any third parties, as such an action can lead to leakage of the secret encryption key. If you are designing an application where decryptions must be shared, you will need to craft custom encryption parameters which are chosen in consideration of the IND-CPA^D security model [1].
212
+
213
+ [1] Li, Baiyu, et al. "Securing approximate homomorphic encryption using differential privacy." Annual International Cryptology Conference. Cham: Springer Nature Switzerland, 2022. https://eprint.iacr.org/2022/816.pdf
214
+
215
+ #### Side-Channel Attacks
216
+
217
+ Mitigation for side-channel attacks has not yet been implemented in TFHE-rs,
218
+ and will be released in upcoming versions.
219
+ <br></br>
220
+
221
+ ### Citations
152
222
  To cite TFHE-rs in academic papers, please use the following entry:
153
223
 
154
224
  ```text
@@ -160,22 +230,35 @@ To cite TFHE-rs in academic papers, please use the following entry:
160
230
  }
161
231
  ```
162
232
 
163
- ## License
233
+ ### Contributing
164
234
 
165
- This software is distributed under the BSD-3-Clause-Clear license. If you have any questions,
166
- please contact us at `hello@zama.ai`.
235
+ There are two ways to contribute to TFHE-rs:
167
236
 
168
- ## Disclaimers
237
+ - [Open issues](https://github.com/zama-ai/tfhe-rs/issues/new/choose) to report bugs and typos, or to suggest new ideas
238
+ - Request to become an official contributor by emailing [hello@zama.ai](mailto:hello@zama.ai).
169
239
 
170
- ### Security Estimation
240
+ 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!
241
+ <br></br>
171
242
 
172
- Security estimations are done using the
173
- [Lattice Estimator](https://github.com/malb/lattice-estimator)
174
- with `red_cost_model = reduction.RC.BDGL16`.
243
+ ### License
244
+ This software is distributed under the **BSD-3-Clause-Clear** license. If you have any questions, please contact us at hello@zama.ai.
245
+ <p align="right">
246
+ <a href="#about" > ↑ Back to top </a>
247
+ </p>
175
248
 
176
- When a new update is published in the Lattice Estimator, we update parameters accordingly.
177
249
 
178
- ### Side-Channel Attacks
250
+ ## Support
179
251
 
180
- Mitigation for side channel attacks have not yet been implemented in TFHE-rs,
181
- and will be released in upcoming versions.
252
+ <a target="_blank" href="https://community.zama.ai">
253
+ <picture>
254
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/zama-ai/tfhe-rs/assets/157474013/08656d0a-3f44-4126-b8b6-8c601dff5380">
255
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/zama-ai/tfhe-rs/assets/157474013/1c9c9308-50ac-4aab-a4b9-469bb8c536a4">
256
+ <img alt="Support">
257
+ </picture>
258
+ </a>
259
+
260
+ 🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.
261
+
262
+ <p align="right">
263
+ <a href="#about" > ↑ Back to top </a>
264
+ </p>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tfhe",
3
3
  "description": "TFHE-rs is a fully homomorphic encryption (FHE) library that implements Zama's variant of TFHE.",
4
- "version": "0.5.2",
4
+ "version": "0.6.0",
5
5
  "license": "BSD-3-Clause-Clear",
6
6
  "repository": {
7
7
  "type": "git",