From e306ac9fc626c80984ce87ae543ea92994b5781e Mon Sep 17 00:00:00 2001 From: huocun Date: Tue, 14 Jan 2025 19:22:24 +0800 Subject: [PATCH] repo-sync-2025-01-14T19:22:17+0800 --- psi/algorithm/spiral/spiral_pir_test.cc | 4 ++-- psi/algorithm/spiral/util.cc | 13 +++++++++++++ psi/algorithm/spiral/util.h | 3 +++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/psi/algorithm/spiral/spiral_pir_test.cc b/psi/algorithm/spiral/spiral_pir_test.cc index 4ff61ade..edf0a44b 100644 --- a/psi/algorithm/spiral/spiral_pir_test.cc +++ b/psi/algorithm/spiral/spiral_pir_test.cc @@ -75,7 +75,7 @@ TEST_P(SpiralPirTest, Works) { SPDLOG_INFO("GenRandomDatabase, time cost: {} ms", timer.CountMs()); // get a SpiralParams - auto spiral_params = util::GetPerformanceImproveParam(); + auto spiral_params = util::GetDefaultParam(); spiral_params.UpdateByDatabaseInfo(database_info); SPDLOG_INFO("MaxByteLenofPt: {}, MaxBitLenOfPt: {}", @@ -173,4 +173,4 @@ INSTANTIATE_TEST_SUITE_P(Works_Instances, SpiralPirTest, TestParams{10000, 8193, true}, TestParams{1000, 8192 * 10, true})); -} // namespace psi::spiral \ No newline at end of file +} // namespace psi::spiral diff --git a/psi/algorithm/spiral/util.cc b/psi/algorithm/spiral/util.cc index a74bff64..49c590ab 100644 --- a/psi/algorithm/spiral/util.cc +++ b/psi/algorithm/spiral/util.cc @@ -56,6 +56,19 @@ Params GetPerformanceImproveParam() { std::move(poly_matrix_params), std::move(query_params)); } +Params GetDefaultParam() { + std::size_t poly_len{2048}; + std::vector moduli{268369921, 249561089}; + + double noise_width{6.4}; + + PolyMatrixParams poly_matrix_params(2, 256, 21, 4, 8, 8, 6); + QueryParams query_params(9, 6, 1); + + return Params(poly_len, std::move(moduli), noise_width, + std::move(poly_matrix_params), std::move(query_params)); +} + Params GetFastExpansionTestingParam() { std::size_t poly_len{2048}; std::vector moduli{268369921, 249561089}; diff --git a/psi/algorithm/spiral/util.h b/psi/algorithm/spiral/util.h index 2213cd00..34583dc4 100644 --- a/psi/algorithm/spiral/util.h +++ b/psi/algorithm/spiral/util.h @@ -25,8 +25,11 @@ Params GetFastExpansionTestingParam(); Params GetTestParam(); +// this params has the best performance, but has smallest noise budget Params GetPerformanceImproveParam(); +Params GetDefaultParam(); + Params GetLargerParam(); // calc multi-dimension position in 1-deimension's position