server.rs 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. #[cfg(target_feature = "avx2")]
  2. use std::arch::x86_64::*;
  3. use std::fs::File;
  4. use std::io::BufReader;
  5. use std::io::Read;
  6. use std::io::Seek;
  7. use std::io::SeekFrom;
  8. use crate::aligned_memory::*;
  9. use crate::arith::*;
  10. use crate::client::PublicParameters;
  11. use crate::client::Query;
  12. use crate::gadget::*;
  13. use crate::params::*;
  14. use crate::poly::*;
  15. use crate::util::*;
  16. use rayon::prelude::*;
  17. pub fn coefficient_expansion(
  18. v: &mut Vec<PolyMatrixNTT>,
  19. g: usize,
  20. stop_round: usize,
  21. params: &Params,
  22. v_w_left: &Vec<PolyMatrixNTT>,
  23. v_w_right: &Vec<PolyMatrixNTT>,
  24. v_neg1: &Vec<PolyMatrixNTT>,
  25. max_bits_to_gen_right: usize,
  26. ) {
  27. let poly_len = params.poly_len;
  28. for r in 0..g {
  29. let num_in = 1 << r;
  30. let num_out = 2 * num_in;
  31. let t = (poly_len / (1 << r)) + 1;
  32. let neg1 = &v_neg1[r];
  33. let action_expand = |(i, v_i): (usize, &mut PolyMatrixNTT)| {
  34. if (stop_round > 0 && r > stop_round && (i % 2) == 1)
  35. || (stop_round > 0
  36. && r == stop_round
  37. && (i % 2) == 1
  38. && (i / 2) >= max_bits_to_gen_right)
  39. {
  40. return;
  41. }
  42. let mut ct = PolyMatrixRaw::zero(params, 2, 1);
  43. let mut ct_auto = PolyMatrixRaw::zero(params, 2, 1);
  44. let mut ct_auto_1 = PolyMatrixRaw::zero(params, 1, 1);
  45. let mut ct_auto_1_ntt = PolyMatrixNTT::zero(params, 1, 1);
  46. let mut w_times_ginv_ct = PolyMatrixNTT::zero(params, 2, 1);
  47. let mut ginv_ct_left = PolyMatrixRaw::zero(params, params.t_exp_left, 1);
  48. let mut ginv_ct_left_ntt = PolyMatrixNTT::zero(params, params.t_exp_left, 1);
  49. let mut ginv_ct_right = PolyMatrixRaw::zero(params, params.t_exp_right, 1);
  50. let mut ginv_ct_right_ntt = PolyMatrixNTT::zero(params, params.t_exp_right, 1);
  51. let (w, _gadget_dim, gi_ct, gi_ct_ntt) = match (r != 0) && (i % 2 == 0) {
  52. true => (
  53. &v_w_left[r],
  54. params.t_exp_left,
  55. &mut ginv_ct_left,
  56. &mut ginv_ct_left_ntt,
  57. ),
  58. false => (
  59. &v_w_right[r],
  60. params.t_exp_right,
  61. &mut ginv_ct_right,
  62. &mut ginv_ct_right_ntt,
  63. ),
  64. };
  65. // if i < num_in {
  66. // let (src, dest) = v.split_at_mut(num_in);
  67. // scalar_multiply(&mut dest[i], neg1, &src[i]);
  68. // }
  69. from_ntt(&mut ct, &v_i);
  70. automorph(&mut ct_auto, &ct, t);
  71. gadget_invert_rdim(gi_ct, &ct_auto, 1);
  72. to_ntt_no_reduce(gi_ct_ntt, &gi_ct);
  73. ct_auto_1
  74. .data
  75. .as_mut_slice()
  76. .copy_from_slice(ct_auto.get_poly(1, 0));
  77. to_ntt(&mut ct_auto_1_ntt, &ct_auto_1);
  78. multiply(&mut w_times_ginv_ct, w, &gi_ct_ntt);
  79. let mut idx = 0;
  80. for j in 0..2 {
  81. for n in 0..params.crt_count {
  82. for z in 0..poly_len {
  83. let sum = (*v_i).data[idx]
  84. + w_times_ginv_ct.data[idx]
  85. + j * ct_auto_1_ntt.data[n * poly_len + z];
  86. (*v_i).data[idx] = barrett_coeff_u64(params, sum, n);
  87. idx += 1;
  88. }
  89. }
  90. }
  91. };
  92. let (src, dest) = v.split_at_mut(num_in);
  93. src.par_iter_mut()
  94. .zip(dest.par_iter_mut())
  95. .for_each(|(s, d)| {
  96. scalar_multiply(d, neg1, s);
  97. });
  98. v[0..num_in]
  99. .par_iter_mut()
  100. .enumerate()
  101. .for_each(action_expand);
  102. v[num_in..num_out]
  103. .par_iter_mut()
  104. .enumerate()
  105. .for_each(action_expand);
  106. }
  107. }
  108. pub fn regev_to_gsw<'a>(
  109. v_gsw: &mut Vec<PolyMatrixNTT<'a>>,
  110. v_inp: &Vec<PolyMatrixNTT<'a>>,
  111. v: &PolyMatrixNTT<'a>,
  112. params: &'a Params,
  113. idx_factor: usize,
  114. idx_offset: usize,
  115. ) {
  116. assert!(v.rows == 2);
  117. assert!(v.cols == 2 * params.t_conv);
  118. v_gsw.par_iter_mut().enumerate().for_each(|(i, ct)| {
  119. let mut ginv_c_inp = PolyMatrixRaw::zero(params, 2 * params.t_conv, 1);
  120. let mut ginv_c_inp_ntt = PolyMatrixNTT::zero(params, 2 * params.t_conv, 1);
  121. let mut tmp_ct_raw = PolyMatrixRaw::zero(params, 2, 1);
  122. let mut tmp_ct = PolyMatrixNTT::zero(params, 2, 1);
  123. for j in 0..params.t_gsw {
  124. let idx_ct = i * params.t_gsw + j;
  125. let idx_inp = idx_factor * (idx_ct) + idx_offset;
  126. ct.copy_into(&v_inp[idx_inp], 0, 2 * j + 1);
  127. from_ntt(&mut tmp_ct_raw, &v_inp[idx_inp]);
  128. gadget_invert(&mut ginv_c_inp, &tmp_ct_raw);
  129. to_ntt(&mut ginv_c_inp_ntt, &ginv_c_inp);
  130. multiply(&mut tmp_ct, v, &ginv_c_inp_ntt);
  131. ct.copy_into(&tmp_ct, 0, 2 * j);
  132. }
  133. });
  134. }
  135. pub const MAX_SUMMED: usize = 1 << 6;
  136. pub const PACKED_OFFSET_2: i32 = 32;
  137. #[cfg(target_feature = "avx2")]
  138. pub fn multiply_reg_by_database(
  139. out: &mut Vec<PolyMatrixNTT>,
  140. db: &[u64],
  141. v_firstdim: &[u64],
  142. params: &Params,
  143. dim0: usize,
  144. num_per: usize,
  145. ) {
  146. let ct_rows = 2;
  147. let ct_cols = 1;
  148. let pt_rows = 1;
  149. let pt_cols = 1;
  150. // assert!(dim0 * ct_rows >= MAX_SUMMED);
  151. let mut sums_out_n0_u64 = AlignedMemory64::new(4);
  152. let mut sums_out_n2_u64 = AlignedMemory64::new(4);
  153. for z in 0..params.poly_len {
  154. let idx_a_base = z * (ct_cols * dim0 * ct_rows);
  155. let mut idx_b_base = z * (num_per * pt_cols * dim0 * pt_rows);
  156. for i in 0..num_per {
  157. for c in 0..pt_cols {
  158. let mut inner_limit = MAX_SUMMED;
  159. let mut outer_limit = dim0 * ct_rows / inner_limit;
  160. if MAX_SUMMED > dim0 * ct_rows {
  161. inner_limit = dim0 * ct_rows;
  162. outer_limit = 1;
  163. }
  164. let mut sums_out_n0_u64_acc = [0u64, 0, 0, 0];
  165. let mut sums_out_n2_u64_acc = [0u64, 0, 0, 0];
  166. for o_jm in 0..outer_limit {
  167. unsafe {
  168. let mut sums_out_n0 = _mm256_setzero_si256();
  169. let mut sums_out_n2 = _mm256_setzero_si256();
  170. for i_jm in 0..inner_limit / 4 {
  171. let jm = o_jm * inner_limit + (4 * i_jm);
  172. let b_inp_1 = *db.get_unchecked(idx_b_base) as i64;
  173. idx_b_base += 1;
  174. let b_inp_2 = *db.get_unchecked(idx_b_base) as i64;
  175. idx_b_base += 1;
  176. let b = _mm256_set_epi64x(b_inp_2, b_inp_2, b_inp_1, b_inp_1);
  177. let v_a = v_firstdim.get_unchecked(idx_a_base + jm) as *const u64;
  178. let a = _mm256_load_si256(v_a as *const __m256i);
  179. let a_lo = a;
  180. let a_hi_hi = _mm256_srli_epi64(a, PACKED_OFFSET_2);
  181. let b_lo = b;
  182. let b_hi_hi = _mm256_srli_epi64(b, PACKED_OFFSET_2);
  183. sums_out_n0 =
  184. _mm256_add_epi64(sums_out_n0, _mm256_mul_epu32(a_lo, b_lo));
  185. sums_out_n2 =
  186. _mm256_add_epi64(sums_out_n2, _mm256_mul_epu32(a_hi_hi, b_hi_hi));
  187. }
  188. // reduce here, otherwise we will overflow
  189. _mm256_store_si256(
  190. sums_out_n0_u64.as_mut_ptr() as *mut __m256i,
  191. sums_out_n0,
  192. );
  193. _mm256_store_si256(
  194. sums_out_n2_u64.as_mut_ptr() as *mut __m256i,
  195. sums_out_n2,
  196. );
  197. for idx in 0..4 {
  198. let val = sums_out_n0_u64[idx];
  199. sums_out_n0_u64_acc[idx] =
  200. barrett_coeff_u64(params, val + sums_out_n0_u64_acc[idx], 0);
  201. }
  202. for idx in 0..4 {
  203. let val = sums_out_n2_u64[idx];
  204. sums_out_n2_u64_acc[idx] =
  205. barrett_coeff_u64(params, val + sums_out_n2_u64_acc[idx], 1);
  206. }
  207. }
  208. }
  209. for idx in 0..4 {
  210. sums_out_n0_u64_acc[idx] =
  211. barrett_coeff_u64(params, sums_out_n0_u64_acc[idx], 0);
  212. sums_out_n2_u64_acc[idx] =
  213. barrett_coeff_u64(params, sums_out_n2_u64_acc[idx], 1);
  214. }
  215. // output n0
  216. let (crt_count, poly_len) = (params.crt_count, params.poly_len);
  217. let mut n = 0;
  218. let mut idx_c = c * (crt_count * poly_len) + n * (poly_len) + z;
  219. out[i].data[idx_c] =
  220. barrett_coeff_u64(params, sums_out_n0_u64_acc[0] + sums_out_n0_u64_acc[2], 0);
  221. idx_c += pt_cols * crt_count * poly_len;
  222. out[i].data[idx_c] =
  223. barrett_coeff_u64(params, sums_out_n0_u64_acc[1] + sums_out_n0_u64_acc[3], 0);
  224. // output n1
  225. n = 1;
  226. idx_c = c * (crt_count * poly_len) + n * (poly_len) + z;
  227. out[i].data[idx_c] =
  228. barrett_coeff_u64(params, sums_out_n2_u64_acc[0] + sums_out_n2_u64_acc[2], 1);
  229. idx_c += pt_cols * crt_count * poly_len;
  230. out[i].data[idx_c] =
  231. barrett_coeff_u64(params, sums_out_n2_u64_acc[1] + sums_out_n2_u64_acc[3], 1);
  232. }
  233. }
  234. }
  235. }
  236. #[cfg(not(target_feature = "avx2"))]
  237. pub fn multiply_reg_by_database(
  238. out: &mut Vec<PolyMatrixNTT>,
  239. db: &[u64],
  240. v_firstdim: &[u64],
  241. params: &Params,
  242. dim0: usize,
  243. num_per: usize,
  244. ) {
  245. let ct_rows = 2;
  246. let ct_cols = 1;
  247. let pt_rows = 1;
  248. let pt_cols = 1;
  249. for z in 0..params.poly_len {
  250. let idx_a_base = z * (ct_cols * dim0 * ct_rows);
  251. let mut idx_b_base = z * (num_per * pt_cols * dim0 * pt_rows);
  252. for i in 0..num_per {
  253. for c in 0..pt_cols {
  254. let mut sums_out_n0_0 = 0u128;
  255. let mut sums_out_n0_1 = 0u128;
  256. let mut sums_out_n1_0 = 0u128;
  257. let mut sums_out_n1_1 = 0u128;
  258. for jm in 0..(dim0 * pt_rows) {
  259. let b = db[idx_b_base];
  260. idx_b_base += 1;
  261. let v_a0 = v_firstdim[idx_a_base + jm * ct_rows];
  262. let v_a1 = v_firstdim[idx_a_base + jm * ct_rows + 1];
  263. let b_lo = b as u32;
  264. let b_hi = (b >> 32) as u32;
  265. let v_a0_lo = v_a0 as u32;
  266. let v_a0_hi = (v_a0 >> 32) as u32;
  267. let v_a1_lo = v_a1 as u32;
  268. let v_a1_hi = (v_a1 >> 32) as u32;
  269. // do n0
  270. sums_out_n0_0 += ((v_a0_lo as u64) * (b_lo as u64)) as u128;
  271. sums_out_n0_1 += ((v_a1_lo as u64) * (b_lo as u64)) as u128;
  272. // do n1
  273. sums_out_n1_0 += ((v_a0_hi as u64) * (b_hi as u64)) as u128;
  274. sums_out_n1_1 += ((v_a1_hi as u64) * (b_hi as u64)) as u128;
  275. }
  276. // output n0
  277. let (crt_count, poly_len) = (params.crt_count, params.poly_len);
  278. let mut n = 0;
  279. let mut idx_c = c * (crt_count * poly_len) + n * (poly_len) + z;
  280. out[i].data[idx_c] = (sums_out_n0_0 % (params.moduli[0] as u128)) as u64;
  281. idx_c += pt_cols * crt_count * poly_len;
  282. out[i].data[idx_c] = (sums_out_n0_1 % (params.moduli[0] as u128)) as u64;
  283. // output n1
  284. n = 1;
  285. idx_c = c * (crt_count * poly_len) + n * (poly_len) + z;
  286. out[i].data[idx_c] = (sums_out_n1_0 % (params.moduli[1] as u128)) as u64;
  287. idx_c += pt_cols * crt_count * poly_len;
  288. out[i].data[idx_c] = (sums_out_n1_1 % (params.moduli[1] as u128)) as u64;
  289. }
  290. }
  291. }
  292. }
  293. pub fn generate_random_db_and_get_item<'a>(
  294. params: &'a Params,
  295. item_idx: usize,
  296. ) -> (PolyMatrixRaw<'a>, AlignedMemory64) {
  297. let mut rng = get_seeded_rng();
  298. let instances = params.instances;
  299. let trials = params.n * params.n;
  300. let dim0 = 1 << params.db_dim_1;
  301. let num_per = 1 << params.db_dim_2;
  302. let num_items = dim0 * num_per;
  303. let db_size_words = instances * trials * num_items * params.poly_len;
  304. let mut v = AlignedMemory64::new(db_size_words);
  305. let mut item = PolyMatrixRaw::zero(params, params.instances * params.n, params.n);
  306. for instance in 0..instances {
  307. for trial in 0..trials {
  308. for i in 0..num_items {
  309. let ii = i % num_per;
  310. let j = i / num_per;
  311. let mut db_item = PolyMatrixRaw::random_rng(params, 1, 1, &mut rng);
  312. db_item.reduce_mod(params.pt_modulus);
  313. if i == item_idx {
  314. item.copy_into(
  315. &db_item,
  316. instance * params.n + trial / params.n,
  317. trial % params.n,
  318. );
  319. }
  320. for z in 0..params.poly_len {
  321. db_item.data[z] =
  322. recenter_mod(db_item.data[z], params.pt_modulus, params.modulus);
  323. }
  324. let db_item_ntt = db_item.ntt();
  325. for z in 0..params.poly_len {
  326. let idx_dst = calc_index(
  327. &[instance, trial, z, ii, j],
  328. &[instances, trials, params.poly_len, num_per, dim0],
  329. );
  330. v[idx_dst] = db_item_ntt.data[z]
  331. | (db_item_ntt.data[params.poly_len + z] << PACKED_OFFSET_2);
  332. }
  333. }
  334. }
  335. }
  336. (item, v)
  337. }
  338. pub fn load_item_from_seek<'a, T: Seek + Read>(
  339. params: &'a Params,
  340. seekable: &mut T,
  341. instance: usize,
  342. trial: usize,
  343. item_idx: usize,
  344. ) -> PolyMatrixRaw<'a> {
  345. let db_item_size = params.db_item_size;
  346. let instances = params.instances;
  347. let trials = params.n * params.n;
  348. let chunks = instances * trials;
  349. let bytes_per_chunk = f64::ceil(db_item_size as f64 / chunks as f64) as usize;
  350. let logp = f64::ceil(f64::log2(params.pt_modulus as f64)) as usize;
  351. let modp_words_per_chunk = f64::ceil((bytes_per_chunk * 8) as f64 / logp as f64) as usize;
  352. assert!(modp_words_per_chunk <= params.poly_len);
  353. let idx_item_in_file = item_idx * db_item_size;
  354. let idx_chunk = instance * trials + trial;
  355. let idx_poly_in_file = idx_item_in_file + idx_chunk * bytes_per_chunk;
  356. let mut out = PolyMatrixRaw::zero(params, 1, 1);
  357. let seek_result = seekable.seek(SeekFrom::Start(idx_poly_in_file as u64));
  358. if seek_result.is_err() {
  359. return out;
  360. }
  361. let mut data = vec![0u8; 2 * bytes_per_chunk];
  362. let bytes_read = seekable
  363. .read(&mut data.as_mut_slice()[0..bytes_per_chunk])
  364. .unwrap();
  365. let modp_words_read = f64::ceil((bytes_read * 8) as f64 / logp as f64) as usize;
  366. assert!(modp_words_read <= params.poly_len);
  367. for i in 0..modp_words_read {
  368. out.data[i] = read_arbitrary_bits(&data, i * logp, logp);
  369. assert!(out.data[i] <= params.pt_modulus);
  370. }
  371. out
  372. }
  373. pub fn load_db_from_seek<T: Seek + Read>(params: &Params, seekable: &mut T) -> AlignedMemory64 {
  374. let instances = params.instances;
  375. let trials = params.n * params.n;
  376. let dim0 = 1 << params.db_dim_1;
  377. let num_per = 1 << params.db_dim_2;
  378. let num_items = dim0 * num_per;
  379. let db_size_words = instances * trials * num_items * params.poly_len;
  380. let mut v = AlignedMemory64::new(db_size_words);
  381. for instance in 0..instances {
  382. for trial in 0..trials {
  383. for i in 0..num_items {
  384. let ii = i % num_per;
  385. let j = i / num_per;
  386. let mut db_item = load_item_from_seek(params, seekable, instance, trial, i);
  387. // db_item.reduce_mod(params.pt_modulus);
  388. for z in 0..params.poly_len {
  389. db_item.data[z] =
  390. recenter_mod(db_item.data[z], params.pt_modulus, params.modulus);
  391. }
  392. let db_item_ntt = db_item.ntt();
  393. for z in 0..params.poly_len {
  394. let idx_dst = calc_index(
  395. &[instance, trial, z, ii, j],
  396. &[instances, trials, params.poly_len, num_per, dim0],
  397. );
  398. v[idx_dst] = db_item_ntt.data[z]
  399. | (db_item_ntt.data[params.poly_len + z] << PACKED_OFFSET_2);
  400. }
  401. }
  402. }
  403. }
  404. v
  405. }
  406. pub fn load_file_unsafe(data: &mut [u64], file: &mut File) {
  407. let data_as_u8_mut = unsafe { data.align_to_mut::<u8>().1 };
  408. file.read_exact(data_as_u8_mut).unwrap();
  409. }
  410. pub fn load_file(data: &mut [u64], file: &mut File) {
  411. let mut reader = BufReader::with_capacity(1 << 24, file);
  412. let mut buf = [0u8; 8];
  413. for i in 0..data.len() {
  414. reader.read(&mut buf).unwrap();
  415. data[i] = u64::from_ne_bytes(buf);
  416. }
  417. }
  418. pub fn load_preprocessed_db_from_file(params: &Params, file: &mut File) -> AlignedMemory64 {
  419. let instances = params.instances;
  420. let trials = params.n * params.n;
  421. let dim0 = 1 << params.db_dim_1;
  422. let num_per = 1 << params.db_dim_2;
  423. let num_items = dim0 * num_per;
  424. let db_size_words = instances * trials * num_items * params.poly_len;
  425. let mut v = AlignedMemory64::new(db_size_words);
  426. let v_mut_slice = v.as_mut_slice();
  427. load_file(v_mut_slice, file);
  428. v
  429. }
  430. pub fn fold_ciphertexts(
  431. params: &Params,
  432. v_cts: &mut Vec<PolyMatrixRaw>,
  433. v_folding: &Vec<PolyMatrixNTT>,
  434. v_folding_neg: &Vec<PolyMatrixNTT>,
  435. ) {
  436. if v_cts.len() == 1 {
  437. return;
  438. }
  439. let further_dims = log2(v_cts.len() as u64) as usize;
  440. let ell = v_folding[0].cols / 2;
  441. let mut ginv_c = PolyMatrixRaw::zero(&params, 2 * ell, 1);
  442. let mut ginv_c_ntt = PolyMatrixNTT::zero(&params, 2 * ell, 1);
  443. let mut prod = PolyMatrixNTT::zero(&params, 2, 1);
  444. let mut sum = PolyMatrixNTT::zero(&params, 2, 1);
  445. let mut num_per = v_cts.len();
  446. for cur_dim in 0..further_dims {
  447. num_per = num_per / 2;
  448. for i in 0..num_per {
  449. gadget_invert(&mut ginv_c, &v_cts[i]);
  450. to_ntt(&mut ginv_c_ntt, &ginv_c);
  451. multiply(
  452. &mut prod,
  453. &v_folding_neg[further_dims - 1 - cur_dim],
  454. &ginv_c_ntt,
  455. );
  456. gadget_invert(&mut ginv_c, &v_cts[num_per + i]);
  457. to_ntt(&mut ginv_c_ntt, &ginv_c);
  458. multiply(
  459. &mut sum,
  460. &v_folding[further_dims - 1 - cur_dim],
  461. &ginv_c_ntt,
  462. );
  463. add_into(&mut sum, &prod);
  464. from_ntt(&mut v_cts[i], &sum);
  465. }
  466. }
  467. }
  468. pub fn pack<'a>(
  469. params: &'a Params,
  470. v_ct: &Vec<PolyMatrixRaw>,
  471. v_w: &Vec<PolyMatrixNTT>,
  472. ) -> PolyMatrixNTT<'a> {
  473. assert!(v_ct.len() >= params.n * params.n);
  474. assert!(v_w.len() == params.n);
  475. assert!(v_ct[0].rows == 2);
  476. assert!(v_ct[0].cols == 1);
  477. assert!(v_w[0].rows == (params.n + 1));
  478. assert!(v_w[0].cols == params.t_conv);
  479. let mut result = PolyMatrixNTT::zero(params, params.n + 1, params.n);
  480. let mut ginv = PolyMatrixRaw::zero(params, params.t_conv, 1);
  481. let mut ginv_nttd = PolyMatrixNTT::zero(params, params.t_conv, 1);
  482. let mut prod = PolyMatrixNTT::zero(params, params.n + 1, 1);
  483. let mut ct_1 = PolyMatrixRaw::zero(params, 1, 1);
  484. let mut ct_2 = PolyMatrixRaw::zero(params, 1, 1);
  485. let mut ct_2_ntt = PolyMatrixNTT::zero(params, 1, 1);
  486. for c in 0..params.n {
  487. let mut v_int = PolyMatrixNTT::zero(&params, params.n + 1, 1);
  488. for r in 0..params.n {
  489. let w = &v_w[r];
  490. let ct = &v_ct[r * params.n + c];
  491. ct_1.get_poly_mut(0, 0).copy_from_slice(ct.get_poly(0, 0));
  492. ct_2.get_poly_mut(0, 0).copy_from_slice(ct.get_poly(1, 0));
  493. to_ntt(&mut ct_2_ntt, &ct_2);
  494. gadget_invert(&mut ginv, &ct_1);
  495. to_ntt(&mut ginv_nttd, &ginv);
  496. multiply(&mut prod, &w, &ginv_nttd);
  497. add_into_at(&mut v_int, &ct_2_ntt, 1 + r, 0);
  498. add_into(&mut v_int, &prod);
  499. }
  500. result.copy_into(&v_int, 0, c);
  501. }
  502. result
  503. }
  504. pub fn encode(params: &Params, v_packed_ct: &Vec<PolyMatrixRaw>) -> Vec<u8> {
  505. let q1 = 4 * params.pt_modulus;
  506. let q1_bits = log2_ceil(q1) as usize;
  507. let q2 = Q2_VALUES[params.q2_bits as usize];
  508. let q2_bits = params.q2_bits as usize;
  509. let num_bits = params.instances
  510. * ((q2_bits * params.n * params.poly_len)
  511. + (q1_bits * params.n * params.n * params.poly_len));
  512. let round_to = 64;
  513. let num_bytes_rounded_up = ((num_bits + round_to - 1) / round_to) * round_to / 8;
  514. let mut result = vec![0u8; num_bytes_rounded_up];
  515. let mut bit_offs = 0;
  516. for instance in 0..params.instances {
  517. let packed_ct = &v_packed_ct[instance];
  518. let mut first_row = packed_ct.submatrix(0, 0, 1, packed_ct.cols);
  519. let mut rest_rows = packed_ct.submatrix(1, 0, packed_ct.rows - 1, packed_ct.cols);
  520. first_row.apply_func(|x| rescale(x, params.modulus, q2));
  521. rest_rows.apply_func(|x| rescale(x, params.modulus, q1));
  522. let data = result.as_mut_slice();
  523. for i in 0..params.n * params.poly_len {
  524. write_arbitrary_bits(data, first_row.data[i], bit_offs, q2_bits);
  525. bit_offs += q2_bits;
  526. }
  527. for i in 0..params.n * params.n * params.poly_len {
  528. write_arbitrary_bits(data, rest_rows.data[i], bit_offs, q1_bits);
  529. bit_offs += q1_bits;
  530. }
  531. }
  532. result
  533. }
  534. pub fn get_v_folding_neg<'a>(
  535. params: &'a Params,
  536. v_folding: &Vec<PolyMatrixNTT<'a>>,
  537. ) -> Vec<PolyMatrixNTT<'a>> {
  538. let gadget_ntt = build_gadget(params, 2, 2 * params.t_gsw).ntt(); // TODO: make this better
  539. let v_folding_neg = (0..params.db_dim_2)
  540. .into_par_iter()
  541. .map(|i| {
  542. let mut ct_gsw_inv = PolyMatrixRaw::zero(params, 2, 2 * params.t_gsw);
  543. invert(&mut ct_gsw_inv, &v_folding[i].raw());
  544. let mut ct_gsw_neg = PolyMatrixNTT::zero(params, 2, 2 * params.t_gsw);
  545. add(&mut ct_gsw_neg, &gadget_ntt, &ct_gsw_inv.ntt());
  546. ct_gsw_neg
  547. })
  548. .collect();
  549. v_folding_neg
  550. }
  551. pub fn expand_query<'a>(
  552. params: &'a Params,
  553. public_params: &PublicParameters<'a>,
  554. query: &Query<'a>,
  555. ) -> (AlignedMemory64, Vec<PolyMatrixNTT<'a>>) {
  556. let dim0 = 1 << params.db_dim_1;
  557. let further_dims = params.db_dim_2;
  558. let mut v_reg_reoriented;
  559. let mut v_folding;
  560. let num_bits_to_gen = params.t_gsw * further_dims + dim0;
  561. let g = log2_ceil_usize(num_bits_to_gen);
  562. let right_expanded = params.t_gsw * further_dims;
  563. let stop_round = log2_ceil_usize(right_expanded);
  564. let mut v = Vec::new();
  565. for _ in 0..(1 << g) {
  566. v.push(PolyMatrixNTT::zero(params, 2, 1));
  567. }
  568. v[0].copy_into(&query.ct.as_ref().unwrap().ntt(), 0, 0);
  569. let v_conversion = &public_params.v_conversion.as_ref().unwrap()[0];
  570. let v_w_left = public_params.v_expansion_left.as_ref().unwrap();
  571. let v_w_right = public_params.v_expansion_right.as_ref().unwrap();
  572. let v_neg1 = params.get_v_neg1();
  573. let mut v_reg_inp = Vec::with_capacity(dim0);
  574. let mut v_gsw_inp = Vec::with_capacity(right_expanded);
  575. if further_dims > 0 {
  576. coefficient_expansion(
  577. &mut v,
  578. g,
  579. stop_round,
  580. params,
  581. &v_w_left,
  582. &v_w_right,
  583. &v_neg1,
  584. params.t_gsw * params.db_dim_2,
  585. );
  586. for i in 0..dim0 {
  587. v_reg_inp.push(v[2 * i].clone());
  588. }
  589. for i in 0..right_expanded {
  590. v_gsw_inp.push(v[2 * i + 1].clone());
  591. }
  592. } else {
  593. coefficient_expansion(&mut v, g, 0, params, &v_w_left, &v_w_left, &v_neg1, 0);
  594. for i in 0..dim0 {
  595. v_reg_inp.push(v[i].clone());
  596. }
  597. }
  598. let v_reg_sz = dim0 * 2 * params.poly_len;
  599. v_reg_reoriented = AlignedMemory64::new(v_reg_sz);
  600. reorient_reg_ciphertexts(params, v_reg_reoriented.as_mut_slice(), &v_reg_inp);
  601. v_folding = Vec::new();
  602. for _ in 0..params.db_dim_2 {
  603. v_folding.push(PolyMatrixNTT::zero(params, 2, 2 * params.t_gsw));
  604. }
  605. regev_to_gsw(&mut v_folding, &v_gsw_inp, &v_conversion, params, 1, 0);
  606. (v_reg_reoriented, v_folding)
  607. }
  608. pub fn process_query(
  609. params: &Params,
  610. public_params: &PublicParameters,
  611. query: &Query,
  612. db: &[u64],
  613. ) -> Vec<u8> {
  614. let dim0 = 1 << params.db_dim_1;
  615. let num_per = 1 << params.db_dim_2;
  616. let db_slice_sz = dim0 * num_per * params.poly_len;
  617. let v_packing = public_params.v_packing.as_ref();
  618. let mut v_reg_reoriented;
  619. let v_folding;
  620. if params.expand_queries {
  621. (v_reg_reoriented, v_folding) = expand_query(params, public_params, query);
  622. } else {
  623. v_reg_reoriented = AlignedMemory64::new(query.v_buf.as_ref().unwrap().len());
  624. v_reg_reoriented
  625. .as_mut_slice()
  626. .copy_from_slice(query.v_buf.as_ref().unwrap());
  627. v_folding = query
  628. .v_ct
  629. .as_ref()
  630. .unwrap()
  631. .iter()
  632. .map(|x| x.ntt())
  633. .collect();
  634. }
  635. let v_folding_neg = get_v_folding_neg(params, &v_folding);
  636. let v_packed_ct = (0..params.instances)
  637. .into_par_iter()
  638. .map(|instance| {
  639. let mut intermediate = Vec::with_capacity(num_per);
  640. let mut intermediate_raw = Vec::with_capacity(num_per);
  641. for _ in 0..num_per {
  642. intermediate.push(PolyMatrixNTT::zero(params, 2, 1));
  643. intermediate_raw.push(PolyMatrixRaw::zero(params, 2, 1));
  644. }
  645. let mut v_ct = Vec::new();
  646. for trial in 0..(params.n * params.n) {
  647. let idx = (instance * (params.n * params.n) + trial) * db_slice_sz;
  648. let cur_db = &db[idx..(idx + db_slice_sz)];
  649. multiply_reg_by_database(
  650. &mut intermediate,
  651. cur_db,
  652. v_reg_reoriented.as_slice(),
  653. params,
  654. dim0,
  655. num_per,
  656. );
  657. for i in 0..intermediate.len() {
  658. from_ntt(&mut intermediate_raw[i], &intermediate[i]);
  659. }
  660. fold_ciphertexts(params, &mut intermediate_raw, &v_folding, &v_folding_neg);
  661. v_ct.push(intermediate_raw[0].clone());
  662. }
  663. let packed_ct = pack(params, &v_ct, &v_packing);
  664. packed_ct.raw()
  665. })
  666. .collect();
  667. encode(params, &v_packed_ct)
  668. }
  669. #[cfg(test)]
  670. mod test {
  671. use super::*;
  672. use crate::client::*;
  673. use rand::{Rng, SeedableRng};
  674. use rand_chacha::ChaCha20Rng;
  675. const TEST_PREPROCESSED_DB_PATH: &'static str = "/home/samir/wiki/enwiki-20220320.dbp";
  676. fn get_params() -> Params {
  677. get_fast_expansion_testing_params()
  678. }
  679. fn dec_reg<'a>(
  680. params: &'a Params,
  681. ct: &PolyMatrixNTT<'a>,
  682. client: &mut Client<'a>,
  683. scale_k: u64,
  684. ) -> u64 {
  685. let dec = client.decrypt_matrix_reg(ct).raw();
  686. let mut val = dec.data[0] as i64;
  687. if val >= (params.modulus / 2) as i64 {
  688. val -= params.modulus as i64;
  689. }
  690. let val_rounded = f64::round(val as f64 / scale_k as f64) as i64;
  691. if val_rounded == 0 {
  692. 0
  693. } else {
  694. 1
  695. }
  696. }
  697. fn dec_gsw<'a>(params: &'a Params, ct: &PolyMatrixNTT<'a>, client: &mut Client<'a>) -> u64 {
  698. let dec = client.decrypt_matrix_reg(ct).raw();
  699. let idx = 2 * (params.t_gsw - 1) * params.poly_len + params.poly_len; // this offset should encode a large value
  700. let mut val = dec.data[idx] as i64;
  701. if val >= (params.modulus / 2) as i64 {
  702. val -= params.modulus as i64;
  703. }
  704. if i64::abs(val) < (1i64 << 10) {
  705. 0
  706. } else {
  707. 1
  708. }
  709. }
  710. #[test]
  711. fn coefficient_expansion_is_correct() {
  712. let params = get_params();
  713. let v_neg1 = params.get_v_neg1();
  714. let mut rng = ChaCha20Rng::from_entropy();
  715. let mut rng_pub = ChaCha20Rng::from_entropy();
  716. let mut client = Client::init(&params);
  717. let public_params = client.generate_keys();
  718. let mut v = Vec::new();
  719. for _ in 0..(1 << (params.db_dim_1 + 1)) {
  720. v.push(PolyMatrixNTT::zero(&params, 2, 1));
  721. }
  722. let target = 7;
  723. let scale_k = params.modulus / params.pt_modulus;
  724. let mut sigma = PolyMatrixRaw::zero(&params, 1, 1);
  725. sigma.data[target] = scale_k;
  726. v[0] = client.encrypt_matrix_reg(&sigma.ntt(), &mut rng, &mut rng_pub);
  727. let test_ct = client.encrypt_matrix_reg(&sigma.ntt(), &mut rng, &mut rng_pub);
  728. let v_w_left = public_params.v_expansion_left.unwrap();
  729. let v_w_right = public_params.v_expansion_right.unwrap();
  730. coefficient_expansion(
  731. &mut v,
  732. params.g(),
  733. params.stop_round(),
  734. &params,
  735. &v_w_left,
  736. &v_w_right,
  737. &v_neg1,
  738. params.t_gsw * params.db_dim_2,
  739. );
  740. assert_eq!(dec_reg(&params, &test_ct, &mut client, scale_k), 0);
  741. for i in 0..v.len() {
  742. if i == target {
  743. assert_eq!(dec_reg(&params, &v[i], &mut client, scale_k), 1);
  744. } else {
  745. assert_eq!(dec_reg(&params, &v[i], &mut client, scale_k), 0);
  746. }
  747. }
  748. }
  749. #[test]
  750. fn regev_to_gsw_is_correct() {
  751. let mut params = get_params();
  752. params.db_dim_2 = 1;
  753. let mut rng = ChaCha20Rng::from_entropy();
  754. let mut rng_pub = ChaCha20Rng::from_entropy();
  755. let mut client = Client::init(&params);
  756. let public_params = client.generate_keys();
  757. let mut enc_constant = |val| {
  758. let mut sigma = PolyMatrixRaw::zero(&params, 1, 1);
  759. sigma.data[0] = val;
  760. client.encrypt_matrix_reg(&sigma.ntt(), &mut rng, &mut rng_pub)
  761. };
  762. let v = &public_params.v_conversion.unwrap()[0];
  763. let bits_per = get_bits_per(&params, params.t_gsw);
  764. let mut v_inp_1 = Vec::new();
  765. let mut v_inp_0 = Vec::new();
  766. for i in 0..params.t_gsw {
  767. let val = 1u64 << (bits_per * i);
  768. v_inp_1.push(enc_constant(val));
  769. v_inp_0.push(enc_constant(0));
  770. }
  771. let mut v_gsw = Vec::new();
  772. v_gsw.push(PolyMatrixNTT::zero(&params, 2, 2 * params.t_gsw));
  773. regev_to_gsw(&mut v_gsw, &v_inp_1, v, &params, 1, 0);
  774. assert_eq!(dec_gsw(&params, &v_gsw[0], &mut client), 1);
  775. regev_to_gsw(&mut v_gsw, &v_inp_0, v, &params, 1, 0);
  776. assert_eq!(dec_gsw(&params, &v_gsw[0], &mut client), 0);
  777. }
  778. #[test]
  779. fn multiply_reg_by_database_is_correct() {
  780. let params = get_params();
  781. let mut seeded_rng = get_seeded_rng();
  782. let mut rng = ChaCha20Rng::from_entropy();
  783. let mut rng_pub = ChaCha20Rng::from_entropy();
  784. let dim0 = 1 << params.db_dim_1;
  785. let num_per = 1 << params.db_dim_2;
  786. let scale_k = params.modulus / params.pt_modulus;
  787. let target_idx = seeded_rng.gen::<usize>() % (dim0 * num_per);
  788. let target_idx_dim0 = target_idx / num_per;
  789. let target_idx_num_per = target_idx % num_per;
  790. let mut client = Client::init(&params);
  791. _ = client.generate_keys();
  792. let (corr_item, db) = generate_random_db_and_get_item(&params, target_idx);
  793. let mut v_reg = Vec::new();
  794. for i in 0..dim0 {
  795. let val = if i == target_idx_dim0 { scale_k } else { 0 };
  796. let sigma = PolyMatrixRaw::single_value(&params, val).ntt();
  797. v_reg.push(client.encrypt_matrix_reg(&sigma, &mut rng, &mut rng_pub));
  798. }
  799. let v_reg_sz = dim0 * 2 * params.poly_len;
  800. let mut v_reg_reoriented = AlignedMemory64::new(v_reg_sz);
  801. reorient_reg_ciphertexts(&params, v_reg_reoriented.as_mut_slice(), &v_reg);
  802. let mut out = Vec::with_capacity(num_per);
  803. for _ in 0..dim0 {
  804. out.push(PolyMatrixNTT::zero(&params, 2, 1));
  805. }
  806. multiply_reg_by_database(
  807. &mut out,
  808. db.as_slice(),
  809. v_reg_reoriented.as_slice(),
  810. &params,
  811. dim0,
  812. num_per,
  813. );
  814. // decrypt
  815. let dec = client.decrypt_matrix_reg(&out[target_idx_num_per]).raw();
  816. let mut dec_rescaled = PolyMatrixRaw::zero(&params, 1, 1);
  817. for z in 0..params.poly_len {
  818. dec_rescaled.data[z] = rescale(dec.data[z], params.modulus, params.pt_modulus);
  819. }
  820. for z in 0..params.poly_len {
  821. // println!("{:?} {:?}", dec_rescaled.data[z], corr_item.data[z]);
  822. assert_eq!(dec_rescaled.data[z], corr_item.data[z]);
  823. }
  824. }
  825. #[test]
  826. fn fold_ciphertexts_is_correct() {
  827. let params = get_params();
  828. let mut seeded_rng = get_seeded_rng();
  829. let mut rng = ChaCha20Rng::from_entropy();
  830. let mut rng_pub = ChaCha20Rng::from_entropy();
  831. let dim0 = 1 << params.db_dim_1;
  832. let num_per = 1 << params.db_dim_2;
  833. let scale_k = params.modulus / params.pt_modulus;
  834. let target_idx = seeded_rng.gen::<usize>() % (dim0 * num_per);
  835. let target_idx_num_per = target_idx % num_per;
  836. let mut client = Client::init(&params);
  837. _ = client.generate_keys();
  838. let mut v_reg = Vec::new();
  839. for i in 0..num_per {
  840. let val = if i == target_idx_num_per { scale_k } else { 0 };
  841. let sigma = PolyMatrixRaw::single_value(&params, val).ntt();
  842. v_reg.push(client.encrypt_matrix_reg(&sigma, &mut rng, &mut rng_pub));
  843. }
  844. let mut v_reg_raw = Vec::new();
  845. for i in 0..num_per {
  846. v_reg_raw.push(v_reg[i].raw());
  847. }
  848. let bits_per = get_bits_per(&params, params.t_gsw);
  849. let mut v_folding = Vec::new();
  850. for i in 0..params.db_dim_2 {
  851. let bit = ((target_idx_num_per as u64) & (1 << (i as u64))) >> (i as u64);
  852. let mut ct_gsw = PolyMatrixNTT::zero(&params, 2, 2 * params.t_gsw);
  853. for j in 0..params.t_gsw {
  854. let value = (1u64 << (bits_per * j)) * bit;
  855. let sigma = PolyMatrixRaw::single_value(&params, value);
  856. let sigma_ntt = to_ntt_alloc(&sigma);
  857. let ct = client.encrypt_matrix_reg(&sigma_ntt, &mut rng, &mut rng_pub);
  858. ct_gsw.copy_into(&ct, 0, 2 * j + 1);
  859. let prod = &to_ntt_alloc(client.get_sk_reg()) * &sigma_ntt;
  860. let ct = &client.encrypt_matrix_reg(&prod, &mut rng, &mut rng_pub);
  861. ct_gsw.copy_into(&ct, 0, 2 * j);
  862. }
  863. v_folding.push(ct_gsw);
  864. }
  865. let gadget_ntt = build_gadget(&params, 2, 2 * params.t_gsw).ntt();
  866. let mut v_folding_neg = Vec::new();
  867. let mut ct_gsw_inv = PolyMatrixRaw::zero(&params, 2, 2 * params.t_gsw);
  868. for i in 0..params.db_dim_2 {
  869. invert(&mut ct_gsw_inv, &v_folding[i].raw());
  870. let mut ct_gsw_neg = PolyMatrixNTT::zero(&params, 2, 2 * params.t_gsw);
  871. add(&mut ct_gsw_neg, &gadget_ntt, &ct_gsw_inv.ntt());
  872. v_folding_neg.push(ct_gsw_neg);
  873. }
  874. fold_ciphertexts(&params, &mut v_reg_raw, &v_folding, &v_folding_neg);
  875. // decrypt
  876. assert_eq!(
  877. dec_reg(&params, &v_reg_raw[0].ntt(), &mut client, scale_k),
  878. 1
  879. );
  880. }
  881. fn full_protocol_is_correct_for_params(params: &Params) {
  882. let mut seeded_rng = get_seeded_rng();
  883. let target_idx = seeded_rng.gen::<usize>() % (params.db_dim_1 + params.db_dim_2);
  884. let mut client = Client::init(&params);
  885. let public_params = client.generate_keys();
  886. let query = client.generate_query(target_idx);
  887. let (corr_item, db) = generate_random_db_and_get_item(params, target_idx);
  888. let response = process_query(params, &public_params, &query, db.as_slice());
  889. let result = client.decode_response(response.as_slice());
  890. let p_bits = log2_ceil(params.pt_modulus) as usize;
  891. let corr_result = corr_item.to_vec(p_bits, params.modp_words_per_chunk());
  892. assert_eq!(result.len(), corr_result.len());
  893. for z in 0..corr_result.len() {
  894. assert_eq!(result[z], corr_result[z], "at {:?}", z);
  895. }
  896. }
  897. fn full_protocol_is_correct_for_params_real_db(params: &Params) {
  898. let mut seeded_rng = get_seeded_rng();
  899. let target_idx = seeded_rng.gen::<usize>() % (params.db_dim_1 + params.db_dim_2);
  900. let mut client = Client::init(&params);
  901. let public_params = client.generate_keys();
  902. let query = client.generate_query(target_idx);
  903. let mut file = File::open(TEST_PREPROCESSED_DB_PATH).unwrap();
  904. let db = load_preprocessed_db_from_file(params, &mut file);
  905. let response = process_query(params, &public_params, &query, db.as_slice());
  906. let result = client.decode_response(response.as_slice());
  907. let corr_result = vec![0x42, 0x5a, 0x68];
  908. for z in 0..corr_result.len() {
  909. assert_eq!(result[z], corr_result[z]);
  910. }
  911. }
  912. #[test]
  913. fn full_protocol_is_correct() {
  914. full_protocol_is_correct_for_params(&get_params());
  915. }
  916. #[test]
  917. #[ignore]
  918. fn larger_full_protocol_is_correct() {
  919. let cfg_expand = r#"
  920. {
  921. 'n': 2,
  922. 'nu_1': 10,
  923. 'nu_2': 6,
  924. 'p': 512,
  925. 'q2_bits': 21,
  926. 's_e': 85.83255142749422,
  927. 't_gsw': 10,
  928. 't_conv': 4,
  929. 't_exp_left': 16,
  930. 't_exp_right': 56,
  931. 'instances': 1,
  932. 'db_item_size': 9000 }
  933. "#;
  934. let cfg = cfg_expand;
  935. let cfg = cfg.replace("'", "\"");
  936. let params = params_from_json(&cfg);
  937. full_protocol_is_correct_for_params(&params);
  938. full_protocol_is_correct_for_params_real_db(&params);
  939. }
  940. // #[test]
  941. // fn full_protocol_is_correct_20_256() {
  942. // full_protocol_is_correct_for_params(&params_from_json(&CFG_20_256.replace("'", "\"")));
  943. // }
  944. // #[test]
  945. // fn full_protocol_is_correct_16_100000() {
  946. // full_protocol_is_correct_for_params(&params_from_json(&CFG_16_100000.replace("'", "\"")));
  947. // }
  948. #[test]
  949. #[ignore]
  950. fn full_protocol_is_correct_real_db_16_100000() {
  951. full_protocol_is_correct_for_params_real_db(&params_from_json(
  952. &CFG_16_100000.replace("'", "\""),
  953. ));
  954. }
  955. }