hard coded noise bound to 6 sigma
jump to
@@ -97,7 +97,6 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where ScalarZnx<DataPt>: ScalarZnxToRef,@@ -153,7 +152,6 @@ sk_dft,
source_xa, source_xe, sigma, - bound, scratch_3, );
@@ -119,7 +119,6 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where ScalarZnx<DataPt>: ScalarZnxToRef,@@ -168,7 +167,6 @@ sk_dft,
source_xa, source_xe, sigma, - bound, scrach_2, );
@@ -7,6 +7,7 @@ };
use sampling::source::Source; use crate::{ + SIX_SIGMA, elem::Infos, gglwe_ciphertext::GGLWECiphertext, ggsw_ciphertext::GGSWCiphertext,@@ -145,7 +146,6 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where VecZnx<DataPt>: VecZnxToRef,@@ -158,7 +158,6 @@ sk_dft,
source_xa, source_xe, sigma, - bound, scratch, ); }@@ -170,14 +169,11 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where ScalarZnxDft<DataSk, FFT64>: ScalarZnxDftToRef<FFT64>, { - self.encrypt_sk_private( - module, None, sk_dft, source_xa, source_xe, sigma, bound, scratch, - ); + self.encrypt_sk_private(module, None, sk_dft, source_xa, source_xe, sigma, scratch); } pub fn encrypt_pk<DataPt, DataPk>(@@ -188,7 +184,6 @@ pk: &GLWEPublicKey<DataPk, FFT64>,
source_xu: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where VecZnx<DataPt>: VecZnxToRef,@@ -201,7 +196,6 @@ pk,
source_xu, source_xe, sigma, - bound, scratch, ); }@@ -213,14 +207,11 @@ pk: &GLWEPublicKey<DataPk, FFT64>,
source_xu: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where VecZnxDft<DataPk, FFT64>: VecZnxDftToRef<FFT64>, { - self.encrypt_pk_private( - module, None, pk, source_xu, source_xe, sigma, bound, scratch, - ); + self.encrypt_pk_private(module, None, pk, source_xu, source_xe, sigma, scratch); } pub fn keyswitch<DataLhs, DataRhs>(@@ -279,7 +270,6 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where VecZnx<DataPt>: VecZnxToRef,@@ -335,7 +325,7 @@ });
} // c[0] += e - c0_big.add_normal(log_base2k, 0, log_k, source_xe, sigma, bound); + c0_big.add_normal(log_base2k, 0, log_k, source_xe, sigma, sigma * SIX_SIGMA); // c[0] += m if col = 0 if let Some((pt, col)) = pt {@@ -356,7 +346,6 @@ pk: &GLWEPublicKey<DataPk, FFT64>,
source_xu: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where VecZnx<DataPt>: VecZnxToRef,@@ -406,7 +395,7 @@ // ci_big = u * p[i]
let mut ci_big = module.vec_znx_idft_consume(ci_dft); // ci_big = u * pk[i] + e - ci_big.add_normal(log_base2k, 0, pk.k(), source_xe, sigma, bound); + ci_big.add_normal(log_base2k, 0, pk.k(), source_xe, sigma, sigma * SIX_SIGMA); // ci_big = u * pk[i] + e + m (if col = i) if let Some((pt, col)) = pt {
@@ -122,7 +122,6 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where ScalarZnxDft<DataSk, FFT64>: ScalarZnxDftToRef<FFT64>,@@ -133,9 +132,7 @@ data: vec_znx_tmp,
basek: self.basek, k: self.k, }; - ct_idft.encrypt_zero_sk( - module, sk_dft, source_xa, source_xe, sigma, bound, scratch_1, - ); + ct_idft.encrypt_zero_sk(module, sk_dft, source_xa, source_xe, sigma, scratch_1); ct_idft.dft(module, self); }
@@ -216,7 +216,6 @@ sk_dft: &SecretKeyFourier<S, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, ) where VecZnxDft<C, FFT64>: VecZnxDftToMut<FFT64> + VecZnxDftToRef<FFT64>, ScalarZnxDft<S, FFT64>: ScalarZnxDftToRef<FFT64> + ZnxInfos,@@ -241,7 +240,6 @@ sk_dft,
source_xa, source_xe, sigma, - bound, scratch.borrow(), ); self.dist = sk_dft.dist;
@@ -111,15 +111,13 @@ sk_dft: &SecretKeyFourier<DataSk, FFT64>,
source_xa: &mut Source, source_xe: &mut Source, sigma: f64, - bound: f64, scratch: &mut Scratch, ) where ScalarZnx<DataPt>: ScalarZnxToRef, ScalarZnxDft<DataSk, FFT64>: ScalarZnxDftToRef<FFT64>, { - self.0.encrypt_sk( - module, pt, sk_dft, source_xa, source_xe, sigma, bound, scratch, - ); + self.0 + .encrypt_sk(module, pt, sk_dft, source_xa, source_xe, sigma, scratch); } }
@@ -10,3 +10,5 @@ #[cfg(test)]
mod test_fft64; mod utils; pub mod vec_glwe_product; + +pub(crate) const SIX_SIGMA: f64 = 6.0;
@@ -21,7 +21,6 @@ let rank: usize = 1;
let rank_out: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_ct, rows, rank, rank_out); let mut pt: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::new(&module, log_base2k, log_k_ct);@@ -52,7 +51,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -77,7 +75,6 @@
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe_s0s1: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank);@@ -127,7 +124,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -139,7 +135,6 @@ &sk2_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -188,7 +183,6 @@ let rank: usize = 1;
let rank_out: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe_s0s1: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank_out);@@ -231,7 +225,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -243,7 +236,6 @@ &sk2_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -294,7 +286,6 @@ let rank: usize = 1;
let rank_out: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe_in: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank_out);@@ -341,7 +332,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -352,7 +342,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -408,11 +397,10 @@ let log_base2k: usize = 12;
let log_k_grlwe: usize = 60; let rows: usize = (log_k_grlwe + log_base2k - 1) / log_base2k; - let rank = 1; - let rank_out = 1; + let rank: usize = 1; + let rank_out: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank_out);@@ -452,7 +440,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -463,7 +450,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );
@@ -23,7 +23,6 @@ let rows: usize = 4;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_ct, rows, rank); let mut pt_have: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::new(&module, log_base2k, log_k_ct);@@ -54,7 +53,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -99,7 +97,6 @@
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank);@@ -145,7 +142,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -156,7 +152,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -220,7 +215,6 @@ let rows: usize = (log_k_rgsw + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank);@@ -260,7 +254,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -271,7 +264,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -336,7 +328,6 @@ let rows: usize = (log_k_rgsw_lhs_in + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw_rhs: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_rgsw_rhs, rows, rank); let mut ct_rgsw_lhs_in: GGSWCiphertext<Vec<u8>, FFT64> =@@ -382,7 +373,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -393,7 +383,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -468,7 +457,6 @@ let rows: usize = (log_k_rgsw_lhs + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw_rhs: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_rgsw_rhs, rows, rank); let mut ct_rgsw_lhs: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_rgsw_lhs, rows, rank);@@ -506,7 +494,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -517,7 +504,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );
@@ -1,6 +1,6 @@
use base2k::{ Decoding, Encoding, FFT64, FillUniform, Module, ScalarZnx, ScalarZnxAlloc, ScratchOwned, Stats, VecZnxOps, VecZnxToMut, - ZnxView, ZnxViewMut, ZnxZero, + ZnxViewMut, ZnxZero, }; use itertools::izip; use sampling::source::Source;@@ -33,7 +33,6 @@ }
fn encrypt_sk(log_n: usize, basek: usize, k_ct: usize, k_pt: usize, sigma: f64, rank: usize) { let module: Module<FFT64> = Module::<FFT64>::new(1 << log_n); - let bound: f64 = sigma * 6.0; let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, k_ct, rank); let mut pt: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::new(&module, basek, k_pt);@@ -68,7 +67,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -102,7 +100,6 @@ let k_ct: usize = 55;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut pt: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::new(&module, basek, k_ct);@@ -128,7 +125,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), ); ct_dft.decrypt(&module, &mut pt, &sk_dft, scratch.borrow());@@ -145,7 +141,6 @@ let log_k_pk: usize = 64;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, k_ct, rank); let mut pt_want: GLWEPlaintext<Vec<u8>> = GLWEPlaintext::new(&module, basek, k_ct);@@ -161,14 +156,7 @@ let mut sk_dft: SecretKeyFourier<Vec<u8>, FFT64> = SecretKeyFourier::new(&module, rank);
sk_dft.dft(&module, &sk); let mut pk: GLWEPublicKey<Vec<u8>, FFT64> = GLWEPublicKey::new(&module, basek, log_k_pk, rank); - pk.generate( - &module, - &sk_dft, - &mut source_xa, - &mut source_xe, - sigma, - bound, - ); + pk.generate(&module, &sk_dft, &mut source_xa, &mut source_xe, sigma); let mut scratch: ScratchOwned = ScratchOwned::new( GLWECiphertext::encrypt_sk_scratch_space(&module, rank, ct.size())@@ -191,7 +179,6 @@ &pk,
&mut source_xu, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -215,7 +202,6 @@ let rows: usize = (log_k_rlwe_in + basek - 1) / basek;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, basek, log_k_grlwe, rows, rank, rank); let mut ct_rlwe_in: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, log_k_rlwe_in, rank);@@ -263,7 +249,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -274,7 +259,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -315,7 +299,6 @@ let rows: usize = (log_k_rlwe + basek - 1) / basek;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, basek, log_k_grlwe, rows, rank, rank); let mut ct_rlwe: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, log_k_rlwe, rank);@@ -357,7 +340,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -368,7 +350,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -410,7 +391,6 @@ let rows: usize = (log_k_rlwe_in + basek - 1) / basek;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, basek, log_k_grlwe, rows, rank); let mut ct_rlwe_in: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, log_k_rlwe_in, rank);@@ -459,7 +439,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -470,7 +449,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -523,7 +501,6 @@ let rows: usize = (log_k_rlwe_in + basek - 1) / basek;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, basek, log_k_grlwe, rows, rank); let mut ct_rlwe: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, basek, log_k_rlwe_in, rank);@@ -566,7 +543,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -577,7 +553,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );
@@ -23,7 +23,6 @@
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank);@@ -76,7 +75,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -87,7 +85,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -130,7 +127,6 @@ let rows: usize = (log_k_rlwe + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_grlwe: GLWESwitchingKey<Vec<u8>, FFT64> = GLWESwitchingKey::new(&module, log_base2k, log_k_grlwe, rows, rank, rank);@@ -175,7 +171,6 @@ &sk1_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -186,7 +181,6 @@ &sk0_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -230,7 +224,6 @@ let rows: usize = (log_k_rlwe_in + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_grlwe, rows, rank); let mut ct_rlwe_in: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, log_base2k, log_k_rlwe_in, rank);@@ -283,7 +276,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -294,7 +286,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -349,7 +340,6 @@ let rows: usize = (log_k_rlwe_in + log_base2k - 1) / log_base2k;
let rank: usize = 1; let sigma: f64 = 3.2; - let bound: f64 = sigma * 6.0; let mut ct_rgsw: GGSWCiphertext<Vec<u8>, FFT64> = GGSWCiphertext::new(&module, log_base2k, log_k_grlwe, rows, rank); let mut ct_rlwe: GLWECiphertext<Vec<u8>> = GLWECiphertext::new(&module, log_base2k, log_k_rlwe_in, rank);@@ -394,7 +384,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );@@ -405,7 +394,6 @@ &sk_dft,
&mut source_xa, &mut source_xe, sigma, - bound, scratch.borrow(), );