Commit 39db5d8e authored by Jakub Klemsa's avatar Jakub Klemsa
Browse files

Calculation of heart & club improved: taking V_BK/KS as argument.

parent 60209ebb
......@@ -370,12 +370,14 @@ impl Params {
n_max: usize,
v0_corr: f64,
) -> f64 {
let log_v_ks = -2.0 * s_lambda * n_max as f64;
// total
Params::total_var_err_budget(pi)
// round
- Params::round_err_bound(nu, n_min)
// (♣)
- Params::club(pow_2Delta, nu, s_lambda, n_max, kappa, t) / v0_corr
- Params::club(pow_2Delta, nu, kappa, t, log_v_ks) / v0_corr
}
/// Calculate remaining error budget after rounding, (♠) and (♣)
......@@ -390,12 +392,14 @@ impl Params {
n: usize,
v0_corr: f64,
) -> f64 {
let log_v_ks = -2.0 * s_lambda * n as f64;
// total
Params::total_var_err_budget(pi)
// round
- Params::round_err_bound(nu, n)
// (♣)
- Params::club(pow_2Delta, nu, s_lambda, n, kappa, t) / v0_corr
- Params::club(pow_2Delta, nu, kappa, t, log_v_ks) / v0_corr
// (♠)
- Params::spade(pow_2Delta, nu, kappa, t) / v0_corr
}
......@@ -440,16 +444,19 @@ impl Params {
l: usize,
v0_corr: f64,
) -> f64 {
let log_v_bk = -2.0 * s_lambda * (1 << nu) as f64;
let log_v_ks = -2.0 * s_lambda * n as f64;
// total
Params::total_var_err_budget(pi)
// round
- Params::round_err_bound(nu, n)
// (♣)
- Params::club(pow_2Delta, nu, s_lambda, n, kappa, t) / v0_corr
- Params::club(pow_2Delta, nu, kappa, t, log_v_ks) / v0_corr
// (♠)
- Params::spade(pow_2Delta, nu, kappa, t) / v0_corr
// (♥)
- Params::heart(pow_2Delta, nu, s_lambda, n, gamma, l) / v0_corr
- Params::heart(pow_2Delta, nu, n, gamma, l, log_v_bk) / v0_corr
}
/// Calculate final remaining error budget
......@@ -466,16 +473,19 @@ impl Params {
l: usize,
v0_corr: f64,
) -> f64 {
let log_v_bk = -2.0 * s_lambda * (1 << nu) as f64;
let log_v_ks = -2.0 * s_lambda * n as f64;
// total
Params::total_var_err_budget(pi)
// round
- Params::round_err_bound(nu, n)
// (♣)
- Params::club(pow_2Delta, nu, s_lambda, n, kappa, t) / v0_corr
- Params::club(pow_2Delta, nu, kappa, t, log_v_ks) / v0_corr
// (♠)
- Params::spade(pow_2Delta, nu, kappa, t) / v0_corr
// (♥)
- Params::heart(pow_2Delta, nu, s_lambda, n, gamma, l) / v0_corr
- Params::heart(pow_2Delta, nu, n, gamma, l, log_v_bk) / v0_corr
// (♦)
- Params::diamond(pow_2Delta, nu, n, gamma, l) / v0_corr
}
......
......@@ -113,24 +113,22 @@ impl Params {
#[allow(non_snake_case)]
pow_2Delta: usize,
nu: usize,
s_lambda: f64,
n: usize,
gamma: usize,
l: usize,
log_v_bk: f64,
) -> f64 {
// (♥)
// orig. variant w/o updated Var
// 2^2Delta * factor from BRot * 2 * n * l * N * 2^(2(gamma-1)) * V_BK(N)
// (pow_2Delta * BROT_NOISE_FACTOR * 2 * n * l * (1 << nu)) as f64 * ((2*(gamma-1)) as f64).exp2() * (-2.0 * s_lambda * (1 << nu) as f64).exp2() / v0_corr
// updated Var
// 2^2Delta * factor from BRot * 2 * n * l * N * (2^(2 gamma-1) + 1) / 6 * V_BK(N)
(pow_2Delta * BROT_NOISE_FACTOR * 2 * n * l * (1 << nu)) as f64 * (( (2*gamma-1) as f64).exp2() + 1.0) / 6.0 * (-2.0 * s_lambda * (1 << nu) as f64).exp2()
//TODO FIXME apparently there is an overflow for gamma >~ 32 ??
// also log alpha = -77 is little too much
// 2^2Delta * factor from BRot * 2 * n * l * N * (2^(2 gamma-1) + 1) / 6 * V_BK(N)
(pow_2Delta * BROT_NOISE_FACTOR * 2 * n * l * (1 << nu)) as f64 * (( (2*gamma-1) as f64).exp2() + 1.0) / 6.0 * log_v_bk.exp2()
}
pub fn heart_ins(&self) -> f64 {
Params::heart(self.quad_weight, (self.rlwe_params.polynomial_size as f64).log2().round() as usize, self.s_lambda, self.lwe_params.dimension, self.bs_base_log, self.bs_level)
Params::heart(self.quad_weight, (self.rlwe_params.polynomial_size as f64).log2().round() as usize, self.lwe_params.dimension, self.bs_base_log, self.bs_level, (2 * self.rlwe_params.log2_std_dev) as f64)
}
/// V_(♦) bound
......@@ -160,10 +158,9 @@ impl Params {
#[allow(non_snake_case)]
pow_2Delta: usize,
nu: usize,
s_lambda: f64,
n: usize,
kappa: usize,
t: usize,
log_v_ks: f64,
) -> f64 {
// (♣)
// orig. variant w/o updated Var
......@@ -171,11 +168,11 @@ impl Params {
// (pow_2Delta * (1 << nu) * t) as f64 * ((2*(kappa-1)) as f64).exp2() * (-2.0 * s_lambda * n_max as f64).exp2() / v0_corr
// updated Var
// 2^2Delta * N * t * (2^(2 kappa-1) + 1) / 6 * V_KS(n)
(pow_2Delta * (1 << nu) * t) as f64 * (( (2*kappa-1) as f64).exp2() + 1.0) / 6.0 * (-2.0 * s_lambda * n as f64).exp2()
(pow_2Delta * (1 << nu) * t) as f64 * (( (2*kappa-1) as f64).exp2() + 1.0) / 6.0 * log_v_ks.exp2()
}
pub fn club_ins(&self) -> f64 {
Params::club(self.quad_weight, (self.rlwe_params.polynomial_size as f64).log2().round() as usize, self.s_lambda, self.lwe_params.dimension, self.ks_base_log, self.ks_level)
Params::club(self.quad_weight, (self.rlwe_params.polynomial_size as f64).log2().round() as usize, self.ks_base_log, self.ks_level, (2 * self.lwe_params.log2_std_dev) as f64)
}
/// V_(♠) bound
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment