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

Am/fix/0 3 compact #916

Merged
merged 8 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion docker/Dockerfile.wasm_tests
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > install-rustup.s
chmod +x install-node.sh && \
./install-node.sh && \
. "$HOME/.nvm/nvm.sh" && \
bash -i -c 'nvm install node && nvm use node'
bash -i -c 'nvm install 20 && nvm use 20'

WORKDIR /tfhe-wasm-tests/tfhe-rs/
10 changes: 6 additions & 4 deletions tfhe/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tfhe"
version = "0.3.1"
version = "0.3.2"
edition = "2021"
readme = "../README.md"
keywords = ["fully", "homomorphic", "encryption", "fhe", "cryptography"]
Expand Down Expand Up @@ -29,7 +29,7 @@ lazy_static = { version = "1.4.0" }
criterion = "0.4.0"
doc-comment = "0.3.3"
serde_json = "1.0.94"
clap = { version = "4.2.7", features = ["derive"] }
clap = { version = "=4.2.7", features = ["derive"] }
# Used in user documentation
bincode = "1.3.3"
fs2 = { version = "0.4.3" }
Expand Down Expand Up @@ -65,15 +65,17 @@ fs2 = { version = "0.4.3", optional = true }
itertools = "0.10.5"

# wasm deps
wasm-bindgen = { version = "0.2.86", features = [
wasm-bindgen = { version = "=0.2.86", features = [
"serde-serialize",
], optional = true }
# MSRV was bumped in a minor update, pin to still be able to build in CI
bumpalo = { version = "=3.14" }
wasm-bindgen-rayon = { version = "1.0", optional = true }
js-sys = { version = "0.3", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }
serde-wasm-bindgen = { version = "0.4", optional = true }
getrandom = { version = "0.2.8", optional = true }
bytemuck = "1.13.1"
bytemuck = "=1.14.1"

[features]
boolean = []
Expand Down
8 changes: 4 additions & 4 deletions tfhe/docs/core_crypto/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Welcome to this tutorial about `TFHE-rs` `core_crypto` module.
To use `TFHE-rs`, it first has to be added as a dependency in the `Cargo.toml`:

```toml
tfhe = { version = "0.3.1", features = [ "x86_64-unix" ] }
tfhe = { version = "0.3.2", features = [ "x86_64-unix" ] }
```

This enables the `x86_64-unix` feature to have efficient implementations of various algorithms for `x86_64` CPUs on a Unix-like system. The 'unix' suffix indicates that the `UnixSeeder`, which uses `/dev/random` to generate random numbers, is activated as a fallback if no hardware number generator is available (like `rdseed` on `x86_64` or if the [`Randomization Services`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes?language=objc) on Apple platforms are not available). To avoid having the `UnixSeeder` as a potential fallback or to run on non-Unix systems (e.g., Windows), the `x86_64` feature is sufficient.
Expand All @@ -19,19 +19,19 @@ For Apple Silicon, the `aarch64-unix` or `aarch64` feature should be enabled. `a
In short: For `x86_64`-based machines running Unix-like OSes:

```toml
tfhe = { version = "0.3.1", features = ["x86_64-unix"] }
tfhe = { version = "0.3.2", features = ["x86_64-unix"] }
```

For Apple Silicon or aarch64-based machines running Unix-like OSes:

```toml
tfhe = { version = "0.3.1", features = ["aarch64-unix"] }
tfhe = { version = "0.3.2", features = ["aarch64-unix"] }
```

For `x86_64`-based machines with the [`rdseed instruction`](https://en.wikipedia.org/wiki/RDRAND) running Windows:

```toml
tfhe = { version = "0.3.1", features = ["x86_64"] }
tfhe = { version = "0.3.2", features = ["x86_64"] }
```

### Commented code to double a 2-bit message in a leveled fashion and using a PBS with the `core_crypto` module.
Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
To use `TFHE-rs` in your project, you first need to add it as a dependency in your `Cargo.toml`:

```toml
tfhe = { version = "0.3.1", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
tfhe = { version = "0.3.2", features = [ "boolean", "shortint", "integer", "x86_64-unix" ] }
```

{% hint style="success" %}
Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/getting_started/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() {

The default configuration for x86 Unix machines:
```toml
tfhe = { version = "0.3.1", features = ["integer", "x86_64-unix"]}
tfhe = { version = "0.3.2", features = ["integer", "x86_64-unix"]}
```

Configuration options for different platforms can be found [here](../getting_started/installation.md). Other rust and homomorphic types features can be found [here](../how_to/rust_configuration.md).
Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/how_to/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ To serialize our data, a [data format](https://serde.rs/#data-formats) should be

[dependencies]
# ...
tfhe = { version = "0.3.1", features = ["integer","x86_64-unix"]}
tfhe = { version = "0.3.2", features = ["integer","x86_64-unix"]}
bincode = "1.3.3"
```

Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/tutorials/latin_fhe_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ To use the `FheUint8` type, the `integer` feature must be activated:

[dependencies]
# Default configuration for x86 Unix machines:
tfhe = { version = "0.3.1", features = ["integer", "x86_64-unix"]}
tfhe = { version = "0.3.2", features = ["integer", "x86_64-unix"]}
```

Other configurations can be found [here](../getting_started/installation.md).
Expand Down
2 changes: 1 addition & 1 deletion tfhe/docs/tutorials/parity_bit.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To use Booleans, the `booleans` feature in our Cargo.toml must be enabled:
# Cargo.toml

# Default configuration for x86 Unix machines:
tfhe = { version = "0.3.1", features = ["boolean", "x86_64-unix"]}
tfhe = { version = "0.3.2", features = ["boolean", "x86_64-unix"]}
```

Other configurations can be found [here](../getting_started/installation.md).
Expand Down
8 changes: 6 additions & 2 deletions tfhe/src/core_crypto/fft_impl/fft64/crypto/wop_pbs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ pub fn test_extract_bits() {
&mut encryption_generator,
);

let input_lwe_dimension = lwe_big_sk.lwe_dimension();

let req = || {
StackReq::try_any_of([
fill_with_forward_fourier_scratch(fft)?,
extract_bits_scratch::<u64>(
lwe_dimension,
input_lwe_dimension,
ksk_lwe_big_to_small.output_key_lwe_dimension(),
glwe_dimension.to_glwe_size(),
polynomial_size,
Expand Down Expand Up @@ -597,6 +599,8 @@ pub fn test_extract_bit_circuit_bootstrapping_vertical_packing() {
PodStack::new(&mut mem),
);

let input_lwe_dimension = lwe_big_sk.lwe_dimension();

let ksk_lwe_big_to_small: LweKeyswitchKeyOwned<u64> =
allocate_and_generate_new_lwe_keyswitch_key(
&lwe_big_sk,
Expand Down Expand Up @@ -661,7 +665,7 @@ pub fn test_extract_bit_circuit_bootstrapping_vertical_packing() {

let mut mem = GlobalPodBuffer::new(
extract_bits_scratch::<u64>(
lwe_dimension,
input_lwe_dimension,
ksk_lwe_big_to_small.output_key_lwe_dimension(),
fourier_bsk.glwe_size(),
polynomial_size,
Expand Down
13 changes: 9 additions & 4 deletions tfhe/src/shortint/public_key/compact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ impl CompactPublicKey {
self.parameters.ciphertext_modulus(),
);

let encryption_noise = match self.pbs_order {
crate::shortint::PBSOrder::KeyswitchBootstrap => self.parameters.glwe_modular_std_dev(),
crate::shortint::PBSOrder::BootstrapKeyswitch => self.parameters.lwe_modular_std_dev(),
};

// No parallelism allowed
#[cfg(all(feature = "__wasm_api", not(feature = "parallel-wasm-api")))]
{
Expand All @@ -150,8 +155,8 @@ impl CompactPublicKey {
&self.key,
&mut ct_list,
&plaintext_list,
self.parameters.glwe_modular_std_dev(),
self.parameters.lwe_modular_std_dev(),
encryption_noise,
encryption_noise,
&mut engine.secret_generator,
&mut engine.encryption_generator,
);
Expand All @@ -167,8 +172,8 @@ impl CompactPublicKey {
&self.key,
&mut ct_list,
&plaintext_list,
self.parameters.glwe_modular_std_dev(),
self.parameters.lwe_modular_std_dev(),
encryption_noise,
encryption_noise,
&mut engine.secret_generator,
&mut engine.encryption_generator,
);
Expand Down
Loading