Skip to content

Commit

Permalink
chore(all): update toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeul-zama committed Jan 8, 2025
1 parent adf52ac commit 665d653
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions tfhe/src/core_crypto/fft_impl/fft128/math/fft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions tfhe/src/core_crypto/fft_impl/fft128_u128/math/fft/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tfhe/src/integer/server_key/radix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tfhe/src/integer/server_key/radix/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tfhe/src/integer/server_key/radix_parallel/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tfhe/src/integer/server_key/radix_parallel/scalar_shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tfhe/src/shortint/client_key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion toolchain.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-11-29
nightly-2025-01-08

0 comments on commit 665d653

Please sign in to comment.