From 665d653caa267affd333d26a689de45496aba6bf Mon Sep 17 00:00:00 2001 From: "Mayeul@Zama" <69792125+mayeul-zama@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:18:16 +0100 Subject: [PATCH] chore(all): update toolchain --- tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs | 6 +++--- tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs | 8 ++++---- tfhe/src/integer/server_key/radix/mod.rs | 2 +- tfhe/src/integer/server_key/radix/slice.rs | 2 +- tfhe/src/integer/server_key/radix_parallel/comparison.rs | 2 +- .../server_key/radix_parallel/scalar_comparison.rs | 2 +- .../src/integer/server_key/radix_parallel/scalar_shift.rs | 4 ++-- tfhe/src/shortint/client_key/mod.rs | 2 +- toolchain.txt | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs index 8ec1926983..7b5169d551 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs @@ -166,7 +166,7 @@ pub fn f64_to_u128(f: f64) -> u128 { 0 } else { // >= 1, < max - let m = 1 << 127 | (f as u128) << 75; // Mantissa and the implicit 1-bit. + let m = (1 << 127) | ((f as u128) << 75); // Mantissa and the implicit 1-bit. let s = 1150 - (f >> 52); // Shift based on the exponent and bias. if s >= 128 { 0 @@ -180,13 +180,13 @@ pub fn f64_to_u128(f: f64) -> u128 { pub fn f64_to_i128(f: f64) -> i128 { let f = f.to_bits(); - let a = f & !0 >> 1; // Remove sign bit. + let a = f & (!0 >> 1); // Remove sign bit. if a < 1023 << 52 { // >= 0, < 1 0 } else { // >= 1, < max - let m = 1 << 127 | (a as u128) << 75; // Mantissa and the implicit 1-bit. + let m = (1 << 127) | ((a as u128) << 75); // Mantissa and the implicit 1-bit. let s = 1150 - (a >> 52); // Shift based on the exponent and bias. let u = (m >> s) as i128; // Unsigned result. if (f as i64) < 0 { diff --git a/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs index b9915e6f5d..52fdb790cd 100644 --- a/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs @@ -33,7 +33,7 @@ pub fn u128_to_f64((lo, hi): (u64, u64)) -> f64 { const C: f64 = (1u128 << 76) as f64; const D: f64 = u128::MAX as f64; if hi < 1 << 40 { - let l = f64::from_bits(A.to_bits() | (lo << 12) >> 12) - A; + let l = f64::from_bits(A.to_bits() | ((lo << 12) >> 12)) - A; let h = f64::from_bits(B.to_bits() | ((lo >> 52) | (hi << 12))) - B; l + h } else { @@ -306,7 +306,7 @@ pub fn f64_to_u128(f: f64) -> (u64, u64) { (0u64, 0u64) } else { // >= 1, < max - let hi = 1 << 63 | f << 11; + let hi = (1 << 63) | (f << 11); let s = 1150 - (f >> 52); // Shift based on the exponent and bias. if s >= 128 { (0u64, 0u64) @@ -322,13 +322,13 @@ pub fn f64_to_u128(f: f64) -> (u64, u64) { pub fn f64_to_i128(f: f64) -> (u64, u64) { let f = f.to_bits(); - let a = f & !0 >> 1; // Remove sign bit. + let a = f & (!0 >> 1); // Remove sign bit. if a < 1023 << 52 { // >= 0, < 1 (0, 0) } else { // >= 1, < max - let hi = 1 << 63 | a << 11; + let hi = (1 << 63) | (a << 11); let s = 1150 - (a >> 52); // Shift based on the exponent and bias. let u = if s >= 128 { (0, 0) diff --git a/tfhe/src/integer/server_key/radix/mod.rs b/tfhe/src/integer/server_key/radix/mod.rs index 4ad4bcf36b..6623505f26 100644 --- a/tfhe/src/integer/server_key/radix/mod.rs +++ b/tfhe/src/integer/server_key/radix/mod.rs @@ -501,7 +501,7 @@ impl ServerKey { let num_bits_in_block = message_modulus.ilog2(); let padding_block_creator_lut = self.key.generate_lookup_table(|x| { let x = x % message_modulus; - let x_sign_bit = x >> (num_bits_in_block - 1) & 1; + let x_sign_bit = (x >> (num_bits_in_block - 1)) & 1; // padding is a message full of 1 if sign bit is one // else padding is a zero message (message_modulus - 1) * x_sign_bit diff --git a/tfhe/src/integer/server_key/radix/slice.rs b/tfhe/src/integer/server_key/radix/slice.rs index c04846754c..0df05f854e 100644 --- a/tfhe/src/integer/server_key/radix/slice.rs +++ b/tfhe/src/integer/server_key/radix/slice.rs @@ -45,7 +45,7 @@ pub(in crate::integer) fn slice_oneblock_clear_unaligned( offset: usize, block_size: usize, ) -> u64 { - cur_block >> (offset) | ((next_block << (block_size - offset)) % (1 << block_size)) + (cur_block >> (offset)) | ((next_block << (block_size - offset)) % (1 << block_size)) } impl ServerKey { diff --git a/tfhe/src/integer/server_key/radix_parallel/comparison.rs b/tfhe/src/integer/server_key/radix_parallel/comparison.rs index 9f08371741..2392ec5a17 100644 --- a/tfhe/src/integer/server_key/radix_parallel/comparison.rs +++ b/tfhe/src/integer/server_key/radix_parallel/comparison.rs @@ -311,7 +311,7 @@ impl ServerKey { is_x_less_than_y_given_input_borrow(x, y, 0, self.message_modulus()); let b1 = is_x_less_than_y_given_input_borrow(x, y, 1, self.message_modulus()); - (b1 << 1 | b0) << 2 + ((b1 << 1) | b0) << 2 }); Some(PreparedSignedCheck::Unified( diff --git a/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs b/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs index f6eb10e94d..8635cc92f7 100644 --- a/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs +++ b/tfhe/src/integer/server_key/radix_parallel/scalar_comparison.rs @@ -969,7 +969,7 @@ impl ServerKey { }; let b0 = is_x_less_than_y_given_input_borrow(x, y, 0, modulus); let b1 = is_x_less_than_y_given_input_borrow(x, y, 1, modulus); - (b1 << 1 | b0) << 2 + ((b1 << 1) | b0) << 2 }); Some(PreparedSignedCheck::Unified( diff --git a/tfhe/src/integer/server_key/radix_parallel/scalar_shift.rs b/tfhe/src/integer/server_key/radix_parallel/scalar_shift.rs index f93af2375e..77a2da1f31 100644 --- a/tfhe/src/integer/server_key/radix_parallel/scalar_shift.rs +++ b/tfhe/src/integer/server_key/radix_parallel/scalar_shift.rs @@ -176,7 +176,7 @@ impl ServerKey { let shift_last_block = || { let last_block_lut = self.key.generate_lookup_table(|x| { let x = x % message_modulus; - let x_sign_bit = x >> (num_bits_in_block - 1) & 1; + let x_sign_bit = (x >> (num_bits_in_block - 1)) & 1; let shifted = x >> shift_within_block; // padding is a message full of 1 if sign bit is one // else padding is a zero message @@ -193,7 +193,7 @@ impl ServerKey { let pad_block_creator_lut = self.key.generate_lookup_table(|x| { let x = x % message_modulus; - let x_sign_bit = x >> (num_bits_in_block - 1) & 1; + let x_sign_bit = (x >> (num_bits_in_block - 1)) & 1; // padding is a message full of 1 if sign bit is one // else padding is a zero message (message_modulus - 1) * x_sign_bit diff --git a/tfhe/src/shortint/client_key/mod.rs b/tfhe/src/shortint/client_key/mod.rs index 26d9aca041..4a727b3460 100644 --- a/tfhe/src/shortint/client_key/mod.rs +++ b/tfhe/src/shortint/client_key/mod.rs @@ -798,7 +798,7 @@ impl ClientKey { let decrypted_u64: u64 = self.decrypt_no_decode(ct); let mut result = decrypted_u64 as u128 * basis as u128; - result = result.wrapping_add((result & 1 << 63) << 1) / (1 << 64); + result = result.wrapping_add((result & (1 << 63)) << 1) / (1 << 64); result as u64 % basis } diff --git a/toolchain.txt b/toolchain.txt index e56b2c71eb..abaa0a9425 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -1 +1 @@ -nightly-2024-11-29 +nightly-2025-01-08