Skip to content

Commit

Permalink
chore: quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontaigu committed Nov 14, 2024
1 parent 520648a commit 87ac779
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions tfhe/src/shortint/server_key/tests/noise_level.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::shortint::ciphertext::NoiseLevel;
use crate::shortint::keycache::KEY_CACHE;
use crate::shortint::parameters::PARAM_MESSAGE_2_CARRY_2_KS_PBS;
use crate::shortint::{Ciphertext, ServerKey};
use crate::shortint::{Ciphertext, MaxNoiseLevel, ServerKey};

fn test_ct_unary_op_noise_level_propagation(sk: &ServerKey, ct: &Ciphertext) {
let test_fn = |op: &dyn Fn(&ServerKey, &Ciphertext) -> Ciphertext,
Expand Down Expand Up @@ -324,6 +324,11 @@ fn test_noise_level_propagation_ci_run_filter() {
let keys = KEY_CACHE.get_from_param(params);
let (ck, sk) = (keys.client_key(), keys.server_key());

// The goal of this test is to check the noise level is properly propagated
// thus it does operations in a way that is not correct noise-wise
let mut sk = sk.clone();
sk.max_noise_level = MaxNoiseLevel::new(usize::MAX);

let modulus: u64 = params.message_modulus.0 as u64;

for _ in 0..10 {
Expand All @@ -335,21 +340,21 @@ fn test_noise_level_propagation_ci_run_filter() {
let ct2 = sk.unchecked_add(&ct1, &ct1);

for ct in [&trivial0, &trivial, &ct1, &ct2] {
test_ct_unary_op_noise_level_propagation(sk, ct);
test_ct_unary_op_assign_noise_level_propagation(sk, ct);
test_ct_unary_op_noise_level_propagation(&sk, ct);
test_ct_unary_op_assign_noise_level_propagation(&sk, ct);
}

for ct_left in [&trivial0, &trivial, &ct1, &ct2] {
for ct_right in [&trivial0, &trivial, &ct1, &ct2] {
test_ct_binary_op_noise_level_propagation(sk, ct_left, ct_right);
test_ct_binary_op_assign_noise_level_propagation(sk, ct_left, ct_right);
test_ct_binary_op_noise_level_propagation(&sk, ct_left, ct_right);
test_ct_binary_op_assign_noise_level_propagation(&sk, ct_left, ct_right);
}
}

for ct in [&trivial0, &trivial, &ct1, &ct2] {
for scalar in 0..params.carry_modulus.0 * params.message_modulus.0 {
test_ct_scalar_op_noise_level_propagation(sk, ct, scalar as u8);
test_ct_scalar_op_assign_noise_level_propagation(sk, ct, scalar as u8);
test_ct_scalar_op_noise_level_propagation(&sk, ct, scalar as u8);
test_ct_scalar_op_assign_noise_level_propagation(&sk, ct, scalar as u8);
}
}
}
Expand Down

0 comments on commit 87ac779

Please sign in to comment.