Skip to content

Commit

Permalink
fix noise in woppbs
Browse files Browse the repository at this point in the history
  • Loading branch information
samcrx authored and youben11 committed Oct 24, 2023
1 parent e5ed6f0 commit be8cc50
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backends/concrete-cpu/implementation/include/concrete-cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,12 @@ void simulation_circuit_bootstrap_boolean_vertical_packing_lwe_ciphertext_u64(co
uint64_t glwe_dimension,
uint64_t log_poly_size,
uint64_t lwe_dimension,
uint64_t pbs_level,
uint64_t pbs_log_base,
uint64_t cb_level,
uint64_t cb_log_base,
uint64_t pp_level,
uint64_t pp_log_base,
uint32_t ciphertext_modulus_log,
uint64_t security_level);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ pub unsafe extern "C" fn simulation_circuit_bootstrap_boolean_vertical_packing_l
glwe_dimension: u64,
log_poly_size: u64,
lwe_dimension: u64,
pbs_level: u64,
pbs_log_base: u64,
cb_level: u64,
cb_log_base: u64,
pp_level: u64,
pp_log_base: u64,
ciphertext_modulus_log: u32,
security_level: u64,
) {
Expand All @@ -76,8 +80,12 @@ pub unsafe extern "C" fn simulation_circuit_bootstrap_boolean_vertical_packing_l
glwe_dimension,
log_poly_size,
lwe_dimension,
pbs_level,
pbs_log_base,
cb_level,
cb_log_base,
pp_level,
pp_log_base,
ciphertext_modulus_log,
security_level,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::implementation::{from_torus, zip_eq};
use concrete_cpu_noise_model::gaussian_noise::noise::blind_rotate::variance_blind_rotate;
use concrete_cpu_noise_model::gaussian_noise::noise::keyswitch::variance_keyswitch;
use concrete_cpu_noise_model::gaussian_noise::noise::modulus_switching::estimate_modulus_switching_noise_with_binary_key;
use concrete_cpu_noise_model::gaussian_noise::noise::private_packing_keyswitch::estimate_packing_private_keyswitch;
use concrete_csprng::generators::{RandomGenerator, SoftwareRandomGenerator};
use concrete_csprng::seeders::Seed;
use concrete_security_curves::gaussian::security::{minimal_variance_glwe, minimal_variance_lwe};
Expand Down Expand Up @@ -411,8 +412,13 @@ fn log2(a: usize) -> usize {
pub fn blind_rotate(
log_poly_size: u64,
glwe_dimension: u64,
lwe_dimension: u64,
fpks_log_base: u64,
fpks_level: u64,
cb_log_base: u64,
cb_level: u64,
pbs_log_base: u64,
pbs_level: u64,
lookup_table: &mut [u64],
ggsw_list: &[u64],
ciphertext_modulus_log: u32,
Expand Down Expand Up @@ -442,6 +448,29 @@ pub fn blind_rotate(
security_level,
);

let blind_rotate_variance = variance_blind_rotate(
lwe_dimension,
glwe_dimension,
polynomial_size,
pbs_log_base,
pbs_level,
ciphertext_modulus_log,
53,
variance_bsk,
);

let ppks_variance = estimate_packing_private_keyswitch(
0.,
variance_bsk,
fpks_log_base,
fpks_level,
glwe_dimension,
polynomial_size,
ciphertext_modulus_log,
);

let ggsw_variance = blind_rotate_variance + ppks_variance;

let vertical_packing_variance = variance_blind_rotate(
ggsw_list.len() as u64,
glwe_dimension,
Expand All @@ -450,7 +479,7 @@ pub fn blind_rotate(
cb_level,
ciphertext_modulus_log,
53,
variance_bsk,
ggsw_variance,
);

let (vertical_packing_variance, _) =
Expand All @@ -471,8 +500,13 @@ pub fn vertical_packing(
ggsw_list: &[u64],
log_poly_size: u64,
glwe_dimension: u64,
lwe_dimension: u64,
fpks_log_base: u64,
fpks_level: u64,
cb_log_base: u64,
cb_level: u64,
pbs_log_base: u64,
pbs_level: u64,
ciphertext_modulus_log: u32,
security_level: u64,
sw_csprng: &mut SoftwareRandomGenerator,
Expand Down Expand Up @@ -535,8 +569,13 @@ pub fn vertical_packing(
blind_rotate(
log_poly_size,
glwe_dimension,
lwe_dimension,
fpks_log_base,
fpks_level,
cb_log_base,
cb_level,
pbs_log_base,
pbs_level,
&mut cmux_tree_lut_res,
br_ggsw,
ciphertext_modulus_log,
Expand All @@ -559,8 +598,12 @@ pub fn circuit_bootstrap_boolean_vertical_packing(
glwe_dimension: u64,
log_poly_size: u64,
lwe_dimension: u64,
pbs_level: u64,
pbs_log_base: u64,
cb_level: u64,
cb_log_base: u64,
pp_level: u64,
pp_log_base: u64,
ciphertext_modulus_log: u32,
security_level: u64,
) {
Expand All @@ -585,8 +628,13 @@ pub fn circuit_bootstrap_boolean_vertical_packing(
&ggsw_list,
log_poly_size,
glwe_dimension,
lwe_dimension,
pp_log_base,
pp_level,
cb_log_base,
cb_level,
pbs_log_base,
pbs_level,
ciphertext_modulus_log,
security_level,
sw_csprng,
Expand Down

0 comments on commit be8cc50

Please sign in to comment.