From 2614d6430ab59447c5d1380fd26446ba33823cde Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Fri, 16 Dec 2022 11:11:40 +0100 Subject: [PATCH] chore(tfhe): update check toolchain --- Makefile | 2 +- tfhe/benches/boolean/bench.rs | 14 +- tfhe/benches/shortint/bench.rs | 10 +- tfhe/src/boolean/server_key/tests.rs | 147 +++++------------- tfhe/src/c_api/utils.rs | 7 +- .../core_crypto/commons/math/random/tests.rs | 5 +- tfhe/src/core_crypto/commons/mod.rs | 4 +- .../fft_impl/crypto/wop_pbs/tests.rs | 25 ++- tfhe/src/core_crypto/fft_impl/math/fft/mod.rs | 11 +- tfhe/src/js_on_wasm_api/boolean.rs | 18 +-- tfhe/src/js_on_wasm_api/shortint.rs | 22 +-- tfhe/src/shortint/parameters/mod.rs | 4 +- .../parameters_wopbs_message_carry.rs | 4 +- tfhe/src/shortint/server_key/tests.rs | 16 +- tfhe/src/shortint/wopbs/test.rs | 2 +- toolchain.txt | 2 +- 16 files changed, 103 insertions(+), 190 deletions(-) diff --git a/Makefile b/Makefile index d6e217cc3..62f9f0094 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL:=$(shell /usr/bin/env which bash) -RS_CHECK_TOOLCHAIN:=$(shell cat toolchain.txt) +RS_CHECK_TOOLCHAIN:=$(shell cat toolchain.txt | tr -d '\n') CARGO_RS_CHECK_TOOLCHAIN:=+$(RS_CHECK_TOOLCHAIN) TARGET_ARCH_FEATURE:=$(shell ./scripts/get_arch_feature.sh) RS_BUILD_TOOLCHAIN:=$(shell \ diff --git a/tfhe/benches/boolean/bench.rs b/tfhe/benches/boolean/bench.rs index f4596e4b1..685cc8942 100644 --- a/tfhe/benches/boolean/bench.rs +++ b/tfhe/benches/boolean/bench.rs @@ -22,25 +22,25 @@ fn bench_gates(c: &mut Criterion, params: BooleanParameters, parameter_name: &st let ct2 = cks.encrypt(false); let ct3 = cks.encrypt(true); - let id = format!("AND gate {}", parameter_name); + let id = format!("AND gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.and(&ct1, &ct2)))); - let id = format!("NAND gate {}", parameter_name); + let id = format!("NAND gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.nand(&ct1, &ct2)))); - let id = format!("OR gate {}", parameter_name); + let id = format!("OR gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.or(&ct1, &ct2)))); - let id = format!("XOR gate {}", parameter_name); + let id = format!("XOR gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.xor(&ct1, &ct2)))); - let id = format!("XNOR gate {}", parameter_name); + let id = format!("XNOR gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.xnor(&ct1, &ct2)))); - let id = format!("NOT gate {}", parameter_name); + let id = format!("NOT gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.not(&ct1)))); - let id = format!("MUX gate {}", parameter_name); + let id = format!("MUX gate {parameter_name}"); c.bench_function(&id, |b| b.iter(|| black_box(sks.mux(&ct1, &ct2, &ct3)))); } diff --git a/tfhe/benches/shortint/bench.rs b/tfhe/benches/shortint/bench.rs index 6844aa573..cb96e9166 100644 --- a/tfhe/benches/shortint/bench.rs +++ b/tfhe/benches/shortint/bench.rs @@ -41,7 +41,7 @@ where let mut ct_0 = cks.encrypt(clear_0); let mut ct_1 = cks.encrypt(clear_1); - let bench_id = format!("{}::{}", bench_name, param_name); + let bench_id = format!("{bench_name}::{param_name}"); bench_group.bench_function(&bench_id, |b| { b.iter(|| { binary_op(sks, &mut ct_0, &mut ct_1); @@ -71,7 +71,7 @@ where let mut ct_0 = cks.encrypt(clear_0); - let bench_id = format!("{}::{}", bench_name, param_name); + let bench_id = format!("{bench_name}::{param_name}"); bench_group.bench_function(&bench_id, |b| { b.iter(|| { binary_op(sks, &mut ct_0, clear_1 as u8); @@ -97,7 +97,7 @@ fn carry_extract(c: &mut Criterion) { let ct_0 = cks.encrypt(clear_0); - let bench_id = format!("ServerKey::carry_extract::{}", param_name); + let bench_id = format!("ServerKey::carry_extract::{param_name}"); bench_group.bench_function(&bench_id, |b| { b.iter(|| { sks.carry_extract(&ct_0); @@ -125,7 +125,7 @@ fn programmable_bootstrapping(c: &mut Criterion) { let ctxt = cks.encrypt(clear_0); - let id = format!("ServerKey::programmable_bootstrap::{}", param_name); + let id = format!("ServerKey::programmable_bootstrap::{param_name}"); bench_group.bench_function(&id, |b| { b.iter(|| { @@ -151,7 +151,7 @@ fn bench_wopbs_param_message_8_norm2_5(c: &mut Criterion) { let mut ct = cks.encrypt_without_padding(clear as u64); let vec_lut = wopbs_key.generate_lut_native_crt(&ct, |x| x); - let id = format!("Shortint WOPBS: {:?}", param); + let id = format!("Shortint WOPBS: {param:?}"); bench_group.bench_function(&id, |b| { b.iter(|| { diff --git a/tfhe/src/boolean/server_key/tests.rs b/tfhe/src/boolean/server_key/tests.rs index 91ed0a8c2..5e38c8563 100644 --- a/tfhe/src/boolean/server_key/tests.rs +++ b/tfhe/src/boolean/server_key/tests.rs @@ -184,11 +184,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_and, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_and, "left: {ct1:?}, right: {ct2:?}"); // AND gate -> left: Ciphertext, right: bool let ct_res = sks.and(&ct1, b2); @@ -197,7 +193,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_and, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_and, "left: {ct1:?}, right: {b2:?}"); // AND gate -> left: bool, right: Ciphertext let ct_res = sks.and(b1, &ct2); @@ -206,7 +202,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_and, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_and, "left: {b1:?}, right: {ct2:?}"); // AND gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -216,11 +212,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_and, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_and, "left: {ct1:?}, right: {ct2:?}"); // AND gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -230,7 +222,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_and, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_and, "left: {ct1:?}, right: {b2:?}"); // AND gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -240,7 +232,7 @@ fn test_and_gate(parameters: BooleanParameters) { let dec_and = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_and, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_and, "left: {b1:?}, right: {ct2:?}"); } } @@ -276,8 +268,7 @@ fn test_mux_gate(parameters: BooleanParameters) { // assert assert_eq!( expected_result, dec_mux, - "cond: {:?}, then: {:?}, else: {:?}", - ct1, ct2, ct3 + "cond: {ct1:?}, then: {ct2:?}, else: {ct3:?}" ); } } @@ -308,11 +299,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_nand, "left: {ct1:?}, right: {ct2:?}"); // NAND gate -> left: Ciphertext, right: bool let ct_res = sks.nand(&ct1, b2); @@ -321,11 +308,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - ct1, b2 - ); + assert_eq!(expected_result, dec_nand, "left: {ct1:?}, right: {b2:?}"); // NAND gate -> left: bool, right: Ciphertext let ct_res = sks.nand(b1, &ct2); @@ -334,11 +317,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - b1, ct2 - ); + assert_eq!(expected_result, dec_nand, "left: {b1:?}, right: {ct2:?}"); // NAND gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -348,11 +327,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_nand, "left: {ct1:?}, right: {ct2:?}"); // NAND gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -362,11 +337,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - ct1, b2 - ); + assert_eq!(expected_result, dec_nand, "left: {ct1:?}, right: {b2:?}"); // NAND gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -376,11 +347,7 @@ fn test_nand_gate(parameters: BooleanParameters) { let dec_nand = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nand, - "left: {:?}, right: {:?}", - b1, ct2 - ); + assert_eq!(expected_result, dec_nand, "left: {b1:?}, right: {ct2:?}"); } } @@ -410,11 +377,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_nor, "left: {ct1:?}, right: {ct2:?}"); // NOR gate -> left: Ciphertext, right: bool let ct_res = sks.nor(&ct1, b2); @@ -423,7 +386,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_nor, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_nor, "left: {ct1:?}, right: {b2:?}"); // NOR gate -> left: bool, right: Ciphertext let ct_res = sks.nor(b1, &ct2); @@ -432,7 +395,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_nor, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_nor, "left: {b1:?}, right: {ct2:?}"); // NOR gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -442,11 +405,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_nor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_nor, "left: {ct1:?}, right: {ct2:?}"); // NOR gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -456,7 +415,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_nor, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_nor, "left: {ct1:?}, right: {b2:?}"); // NOR gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -466,7 +425,7 @@ fn test_nor_gate(parameters: BooleanParameters) { let dec_nor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_nor, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_nor, "left: {b1:?}, right: {ct2:?}"); } } @@ -532,7 +491,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", ct1, ct2); + assert_eq!(expected_result, dec_or, "left: {ct1:?}, right: {ct2:?}"); // OR gate -> left: Ciphertext, right: bool let ct_res = sks.or(&ct1, b2); @@ -541,7 +500,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_or, "left: {ct1:?}, right: {b2:?}"); // OR gate -> left: bool, right: Ciphertext let ct_res = sks.or(b1, &ct2); @@ -550,7 +509,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_or, "left: {b1:?}, right: {ct2:?}"); // OR gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -560,7 +519,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", ct1, ct2); + assert_eq!(expected_result, dec_or, "left: {ct1:?}, right: {ct2:?}"); // OR gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -570,7 +529,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_or, "left: {ct1:?}, right: {b2:?}"); // OR gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -580,7 +539,7 @@ fn test_or_gate(parameters: BooleanParameters) { let dec_or = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_or, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_or, "left: {b1:?}, right: {ct2:?}"); } } @@ -610,11 +569,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_xnor, "left: {ct1:?}, right: {ct2:?}"); // XNOR gate -> left: Ciphertext, right: bool let ct_res = sks.xnor(&ct1, b2); @@ -623,11 +578,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - ct1, b2 - ); + assert_eq!(expected_result, dec_xnor, "left: {ct1:?}, right: {b2:?}"); // XNOR gate -> left: bool, right: Ciphertext let ct_res = sks.xnor(b1, &ct2); @@ -636,11 +587,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - b1, ct2 - ); + assert_eq!(expected_result, dec_xnor, "left: {b1:?}, right: {ct2:?}"); // XNOR gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -650,11 +597,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_xnor, "left: {ct1:?}, right: {ct2:?}"); // XNOR gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -664,11 +607,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - ct1, b2 - ); + assert_eq!(expected_result, dec_xnor, "left: {ct1:?}, right: {b2:?}"); // XNOR gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -678,11 +617,7 @@ fn test_xnor_gate(parameters: BooleanParameters) { let dec_xnor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xnor, - "left: {:?}, right: {:?}", - b1, ct2 - ); + assert_eq!(expected_result, dec_xnor, "left: {b1:?}, right: {ct2:?}"); } } @@ -712,11 +647,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_xor, "left: {ct1:?}, right: {ct2:?}"); // XOR gate -> left: Ciphertext, right: bool let ct_res = sks.xor(&ct1, b2); @@ -725,7 +656,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_xor, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_xor, "left: {ct1:?}, right: {b2:?}"); // XOR gate -> left: bool, right: Ciphertext let ct_res = sks.xor(b1, &ct2); @@ -734,7 +665,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_xor, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_xor, "left: {b1:?}, right: {ct2:?}"); // XOR gate -> "left: {:?}, right: {:?}",ct1, ct2 let mut ct_res = ct1.clone(); @@ -744,11 +675,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!( - expected_result, dec_xor, - "left: {:?}, right: {:?}", - ct1, ct2 - ); + assert_eq!(expected_result, dec_xor, "left: {ct1:?}, right: {ct2:?}"); // XOR gate -> left: Ciphertext, right: bool let mut ct_res = ct1.clone(); @@ -758,7 +685,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_xor, "left: {:?}, right: {:?}", ct1, b2); + assert_eq!(expected_result, dec_xor, "left: {ct1:?}, right: {b2:?}"); // XOR gate -> left: bool, right: Ciphertext let mut ct_res = ct2.clone(); @@ -768,7 +695,7 @@ fn test_xor_gate(parameters: BooleanParameters) { let dec_xor = cks.decrypt(&ct_res); // assert - assert_eq!(expected_result, dec_xor, "left: {:?}, right: {:?}", b1, ct2); + assert_eq!(expected_result, dec_xor, "left: {b1:?}, right: {ct2:?}"); } } diff --git a/tfhe/src/c_api/utils.rs b/tfhe/src/c_api/utils.rs index f4752ff91..43c24dccc 100644 --- a/tfhe/src/c_api/utils.rs +++ b/tfhe/src/c_api/utils.rs @@ -17,10 +17,9 @@ pub fn check_ptr_is_non_null_and_aligned(ptr: *const T) -> Result<(), String> let expected_alignment = std::mem::align_of::(); if ptr as usize % expected_alignment != 0 { return Err(format!( - "pointer is misaligned, expected {} bytes alignement, got pointer: {:p}. \ - You May have mixed some pointers in your function call. If that's not the case \ - check tfhe.h for alignment constants for plain data types allocation.", - expected_alignment, ptr + "pointer is misaligned, expected {expected_alignment} bytes alignement, got pointer: \ + {ptr:p}. You May have mixed some pointers in your function call. If that's not the \ + case check tfhe.h for alignment constants for plain data types allocation.", )); } Ok(()) diff --git a/tfhe/src/core_crypto/commons/math/random/tests.rs b/tfhe/src/core_crypto/commons/math/random/tests.rs index 5929bc3d1..25ed11267 100644 --- a/tfhe/src/core_crypto/commons/math/random/tests.rs +++ b/tfhe/src/core_crypto/commons/math/random/tests.rs @@ -42,9 +42,8 @@ fn test_normal_random() { // test assert!( proportion_of_samples_outside_confidence_interval < 0.003, - "test normal random : proportion = {} ; n = {}", - proportion_of_samples_outside_confidence_interval, - number_of_samples_outside_confidence_interval + "test normal random : proportion = {proportion_of_samples_outside_confidence_interval} ; \ + n = {number_of_samples_outside_confidence_interval}" ); } diff --git a/tfhe/src/core_crypto/commons/mod.rs b/tfhe/src/core_crypto/commons/mod.rs index 84ad3f38f..96d07125d 100644 --- a/tfhe/src/core_crypto/commons/mod.rs +++ b/tfhe/src/core_crypto/commons/mod.rs @@ -134,9 +134,7 @@ pub mod test_tools { let torus_distance = distance / 2_f64.powi(Element::BITS as i32); assert!( torus_distance <= 5. * dist.get_standard_dev(), - "{} != {} ", - x, - y + "{x} != {y} " ); } } diff --git a/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/tests.rs b/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/tests.rs index 8bb247045..a2ceccb76 100644 --- a/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/tests.rs +++ b/tfhe/src/core_crypto/fft_impl/crypto/wop_pbs/tests.rs @@ -117,7 +117,7 @@ pub fn test_extract_bits() { // Encryption let message = Plaintext(val << delta_log.0); - println!("{:?}", message); + println!("{message:?}"); let mut lwe_in = LweCiphertextOwned::new(0u64, lwe_big_sk.lwe_dimension().to_lwe_size()); encrypt_lwe_ciphertext( &lwe_big_sk, @@ -155,8 +155,8 @@ pub fn test_extract_bits() { let decrypted_rounded = decomposer.closest_representable(decrypted_message.0); // Bring back the extracted bit found in the MSB in the LSB let decrypted_extract_bit = decrypted_rounded >> 63; - println!("extracted bit : {:?}", decrypted_extract_bit); - println!("{:?}", decrypted_message); + println!("extracted bit : {decrypted_extract_bit:?}"); + println!("{decrypted_message:?}"); assert_eq!( ((message.0 >> delta_log.0) >> i) & 1, decrypted_extract_bit, @@ -294,7 +294,7 @@ fn test_circuit_bootstrapping_binary() { let glwe_size = glwe_dimension.to_glwe_size(); //print the key to check if the RLWE in the GGSW seem to be well created - println!("RLWE secret key:\n{:?}", glwe_sk); + println!("RLWE secret key:\n{glwe_sk:?}"); let mut decrypted = PlaintextListOwned::new( 0_u64, PlaintextCount(polynomial_size.0 * level_count_cbs.0 * glwe_size.0), @@ -417,7 +417,7 @@ pub fn test_cmux_tree() { for _ in 0..number_of_test_runs { let mut value = test_tools::random_uint_between(0..2u64.pow(number_of_bits_for_payload as u32)); - println!("value: {}", value); + println!("value: {value}"); let witness = value % (1 << (64 - delta_log)); // Bit decomposition of the value from MSB to LSB @@ -489,8 +489,8 @@ pub fn test_cmux_tree() { // The recovered lut_number must be equal to the value stored in the lut at index // witness % 2 ^ {64 - delta_log} - println!("result : {:?}", decoded_result); - println!("witness : {:?}", witness); + println!("result : {decoded_result:?}"); + println!("witness : {witness:?}"); assert_eq!(decoded_result, witness) } } @@ -652,8 +652,8 @@ pub fn test_extract_bit_circuit_bootstrapping_vertical_packing() { let decrypted_message = decrypt_lwe_ciphertext(&lwe_small_sk, &ct); let extract_bit_result = (((decrypted_message.0 as f64) / (1u64 << (63)) as f64).round()) as u64; - println!("extract_bit_result: {:?}", extract_bit_result); - println!("decrypted_message: {:?}", decrypted_message); + println!("extract_bit_result: {extract_bit_result:?}"); + println!("decrypted_message: {decrypted_message:?}"); } // LUT creation @@ -733,11 +733,10 @@ pub fn test_extract_bit_circuit_bootstrapping_vertical_packing() { // print information if the result is wrong if decoded_message != cleartext { panic!( - "decoded_message ({:?}) != cleartext ({:?})\n\ - decrypted_message: {:?}, decoded_message: {:?}", - decoded_message, cleartext, decrypted_message, decoded_message + "decoded_message ({decoded_message:?}) != cleartext ({cleartext:?})\n\ + decrypted_message: {decrypted_message:?}, decoded_message: {decoded_message:?}", ); } - println!("{:?}", decoded_message); + println!("{decoded_message:?}"); } } diff --git a/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs b/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs index e086e4e91..17c22a5ad 100644 --- a/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs +++ b/tfhe/src/core_crypto/fft_impl/math/fft/mod.rs @@ -427,9 +427,9 @@ impl<'a> FftView<'a> { /// # Panics /// /// See [`Self::forward_as_torus`] - pub fn backward_as_torus<'out, Scalar: UnsignedTorus>( + pub fn backward_as_torus( self, - standard: PolynomialUninitMutView<'out, Scalar>, + standard: PolynomialUninitMutView<'_, Scalar>, fourier: FourierPolynomialView<'_>, stack: DynStack<'_>, ) { @@ -447,9 +447,9 @@ impl<'a> FftView<'a> { /// # Panics /// /// See [`Self::forward_as_torus`] - pub fn add_backward_as_torus<'out, Scalar: UnsignedTorus>( + pub fn add_backward_as_torus( self, - standard: PolynomialMutView<'out, Scalar>, + standard: PolynomialMutView<'_, Scalar>, fourier: FourierPolynomialView<'_>, stack: DynStack<'_>, ) { @@ -493,12 +493,11 @@ impl<'a> FftView<'a> { /// /// `conv_fn` must initialize the entirety of the mutable slices that it receives. unsafe fn backward_with_conv< - 'out, Scalar: UnsignedTorus, F: Fn(&mut [MaybeUninit], &mut [MaybeUninit], &[c64], TwistiesView<'_>), >( self, - mut standard: PolynomialUninitMutView<'out, Scalar>, + mut standard: PolynomialUninitMutView<'_, Scalar>, fourier: FourierPolynomialView<'_>, conv_fn: F, stack: DynStack<'_>, diff --git a/tfhe/src/js_on_wasm_api/boolean.rs b/tfhe/src/js_on_wasm_api/boolean.rs index d1ec3be1d..c386ecccf 100644 --- a/tfhe/src/js_on_wasm_api/boolean.rs +++ b/tfhe/src/js_on_wasm_api/boolean.rs @@ -50,7 +50,7 @@ impl Boolean { pub fn get_boolean_parameters(parameter_choice: u32) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); let parameter_choice = BooleanParameterSet::try_from(parameter_choice) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str()))?; + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str()))?; match parameter_choice { BooleanParameterSet::Default => Ok(crate::boolean::parameters::DEFAULT_PARAMETERS), @@ -162,14 +162,14 @@ impl Boolean { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&ciphertext.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_boolean_ciphertext(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(BooleanCiphertext) } @@ -177,14 +177,14 @@ impl Boolean { pub fn serialize_boolean_client_key(client_key: &BooleanClientKey) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&client_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_boolean_client_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(BooleanClientKey) } @@ -192,14 +192,14 @@ impl Boolean { pub fn serialize_boolean_public_key(public_key: &BooleanPublicKey) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&public_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_boolean_public_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(BooleanPublicKey) } @@ -207,14 +207,14 @@ impl Boolean { pub fn serialize_boolean_server_key(server_key: &BooleanServerKey) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&server_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_boolean_server_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(BooleanServerKey) } } diff --git a/tfhe/src/js_on_wasm_api/shortint.rs b/tfhe/src/js_on_wasm_api/shortint.rs index 4352f8e21..699d8c17e 100644 --- a/tfhe/src/js_on_wasm_api/shortint.rs +++ b/tfhe/src/js_on_wasm_api/shortint.rs @@ -143,7 +143,7 @@ impl Shortint { tmp_shortint_engine .new_client_key(parameters.0.to_owned()) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintClientKey) } @@ -220,14 +220,14 @@ impl Shortint { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&ciphertext.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_shortint_ciphertext(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintCiphertext) } @@ -237,14 +237,14 @@ impl Shortint { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&client_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_shortint_client_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintClientKey) } @@ -254,14 +254,14 @@ impl Shortint { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&public_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_shortint_public_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintPublicKey) } @@ -271,7 +271,7 @@ impl Shortint { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&public_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] @@ -280,7 +280,7 @@ impl Shortint { ) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintCompressedPublicKey) } @@ -290,14 +290,14 @@ impl Shortint { ) -> Result, JsError> { set_hook(Box::new(console_error_panic_hook::hook)); bincode::serialize(&server_key.0) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) } #[wasm_bindgen] pub fn deserialize_shortint_server_key(buffer: &[u8]) -> Result { set_hook(Box::new(console_error_panic_hook::hook)); bincode::deserialize(buffer) - .map_err(|e| wasm_bindgen::JsError::new(format!("{:?}", e).as_str())) + .map_err(|e| wasm_bindgen::JsError::new(format!("{e:?}").as_str())) .map(ShortintServerKey) } } diff --git a/tfhe/src/shortint/parameters/mod.rs b/tfhe/src/shortint/parameters/mod.rs index f9ba3d9ca..41ba376e6 100644 --- a/tfhe/src/shortint/parameters/mod.rs +++ b/tfhe/src/shortint/parameters/mod.rs @@ -842,8 +842,8 @@ pub fn get_parameters_from_message_and_carry(msg_space: usize, carry_space: usiz } if !flag { println!( - "### WARNING: NO PARAMETERS FOUND for msg_space = {} and carry_space = {} ### ", - rescaled_message_space, rescaled_carry_space + "### WARNING: NO PARAMETERS FOUND for msg_space = {rescaled_message_space} and \ + carry_space = {rescaled_carry_space} ### " ); } out diff --git a/tfhe/src/shortint/parameters/parameters_wopbs_message_carry.rs b/tfhe/src/shortint/parameters/parameters_wopbs_message_carry.rs index de7ca2627..dcb4b4dd1 100644 --- a/tfhe/src/shortint/parameters/parameters_wopbs_message_carry.rs +++ b/tfhe/src/shortint/parameters/parameters_wopbs_message_carry.rs @@ -959,8 +959,8 @@ pub fn get_parameters_from_message_and_carry_wopbs( } if !flag { println!( - "### WARNING: NO PARAMETERS FOUND for msg_space = {} and carry_space = {} ### ", - rescaled_message_space, rescaled_carry_space + "### WARNING: NO PARAMETERS FOUND for msg_space = {rescaled_message_space} and \ + carry_space = {rescaled_carry_space} ### ", ); } out diff --git a/tfhe/src/shortint/server_key/tests.rs b/tfhe/src/shortint/server_key/tests.rs index e39c8d698..8302814fb 100644 --- a/tfhe/src/shortint/server_key/tests.rs +++ b/tfhe/src/shortint/server_key/tests.rs @@ -266,7 +266,7 @@ fn shortint_keyswitch_bootstrap(param: Parameters) { // assert_eq!(clear_0, dec_res); } - println!("fail_rate = {}/{}", failures, 100); + println!("fail_rate = {failures}/{NB_TEST}"); assert_eq!(0, failures); } @@ -351,9 +351,7 @@ fn shortint_carry_extract(param: Parameters) { // assert println!( - "msg = {}, modulus = {}, msg/modulus = {}", - clear, - msg_modulus, + "msg = {clear}, modulus = {msg_modulus}, msg/modulus = {}", clear / msg_modulus ); assert_eq!(clear / msg_modulus, dec); @@ -1898,20 +1896,14 @@ fn shortint_encrypt_with_message_modulus_smart_add_and_mul(param: Parameters) { let mut ct1 = cks.encrypt_with_message_modulus(clear1, MessageModulus(modulus as usize)); let mut ct2 = cks.encrypt_with_message_modulus(clear2, MessageModulus(modulus as usize)); - println!( - "MUL SMALL CARRY:: clear1 = {}, clear2 = {}, mod = {}", - clear1, clear2, modulus - ); + println!("MUL SMALL CARRY:: clear1 = {clear1}, clear2 = {clear2}, mod = {modulus}"); let ct_res = sks.unchecked_mul_lsb_small_carry(&mut ct1, &mut ct2); assert_eq!( (clear1 * clear2) % modulus, cks.decrypt_message_and_carry(&ct_res) % modulus ); - println!( - "ADD:: clear1 = {}, clear2 = {}, mod = {}", - clear1, clear2, modulus - ); + println!("ADD:: clear1 = {clear1}, clear2 = {clear2}, mod = {modulus}"); let ct_res = sks.unchecked_add(&ct1, &ct2); assert_eq!((clear1 + clear2), cks.decrypt_message_and_carry(&ct_res)); } diff --git a/tfhe/src/shortint/wopbs/test.rs b/tfhe/src/shortint/wopbs/test.rs index 3d33d3664..a359b32c7 100644 --- a/tfhe/src/shortint/wopbs/test.rs +++ b/tfhe/src/shortint/wopbs/test.rs @@ -57,7 +57,7 @@ fn generate_lut(params: (Parameters, Parameters)) { } if 0 != tmp { println!("______"); - println!("failure rate {:?}/{:?}", tmp, NB_TEST); + println!("failure rate {tmp:?}/{NB_TEST:?}"); println!("______"); } assert_eq!(0, tmp); diff --git a/toolchain.txt b/toolchain.txt index 762dae8c2..3ff200564 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -1 +1 @@ -nightly-2022-11-03 \ No newline at end of file +nightly-2022-12-05