Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit tests for larger plaintext moduli in BFV #880

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion src/pke/unittest/UnitTestSHE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ constexpr usint BATCH = 16;
constexpr usint BATCH_LRG = 1 << 12;
constexpr usint PTM = 64;
constexpr usint PTM_LRG = 65537;
constexpr usint BV_DSIZE = 4;
// checks BFV for a 46-bit plaintext modulus
constexpr uint64_t PTM_XTR_LRG = 35184372744193;
constexpr usint BV_DSIZE = 4;
// clang-format off
static std::vector<TEST_CASE_UTGENERAL_SHE> testCases = {
// TestType, Descr, Scheme, RDim, MultDepth, SModSize, DSize, BatchSz, SecKeyDist, MaxRelinSkDeg, FModSize, SecLvl, KSTech, ScalTech, LDigits, PtMod, StdDev, EvalAddCt, KSCt, MultTech, EncTech, PREMode
Expand Down Expand Up @@ -271,6 +273,31 @@ static std::vector<TEST_CASE_UTGENERAL_SHE> testCases = {
{ MULT_PACKED, "38", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, EXTENDED, DFLT}, },
{ MULT_PACKED, "39", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "40", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "41", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, EXTENDED, DFLT}, },
{ MULT_PACKED, "42", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, EXTENDED, DFLT}, },
{ MULT_PACKED, "43", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, EXTENDED, DFLT}, },
{ MULT_PACKED, "44", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, EXTENDED, DFLT}, },
{ MULT_PACKED, "45", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "46", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "47", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, EXTENDED, DFLT}, },
{ MULT_PACKED, "48", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, EXTENDED, DFLT}, },
{ MULT_PACKED, "49", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, EXTENDED, DFLT}, },
{ MULT_PACKED, "50", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, EXTENDED, DFLT}, },
{ MULT_PACKED, "51", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "52", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ MULT_PACKED, "53", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, STANDARD, DFLT}, },
{ MULT_PACKED, "54", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, STANDARD, DFLT}, },
{ MULT_PACKED, "55", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, STANDARD, DFLT}, },
{ MULT_PACKED, "56", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, STANDARD, DFLT}, },
{ MULT_PACKED, "57", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ MULT_PACKED, "58", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ MULT_PACKED, "59", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, STANDARD, DFLT}, },
{ MULT_PACKED, "60", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPS, STANDARD, DFLT}, },
{ MULT_PACKED, "61", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, STANDARD, DFLT}, },
{ MULT_PACKED, "62", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQ, STANDARD, DFLT}, },
{ MULT_PACKED, "63", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ MULT_PACKED, "64", {BFVRNS_SCHEME, DFLT, DFLT, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, DFLT, HPSPOVERQLEVELED, STANDARD, DFLT}, },

// ==========================================
// TestType, Descr, Scheme, RDim, MultDepth, SModSize, DSize, BatchSz, SecKeyDist, MaxRelinSkDeg, FModSize, SecLvl, KSTech, ScalTech, LDigits, PtMod, StdDev, EvalAddCt, KSCt, MultTech, EncTech, PREMode
{ EVALATINDEX, "01", {BGVRNS_SCHEME, 256, 2, DFLT, BV_DSIZE, BATCH, UNIFORM_TERNARY, 1, 60, HEStd_NotSet, BV, FIXEDMANUAL, DFLT, PTM_LRG, DFLT, DFLT, DFLT, DFLT, STANDARD, DFLT}, },
Expand Down Expand Up @@ -313,6 +340,31 @@ static std::vector<TEST_CASE_UTGENERAL_SHE> testCases = {
{ EVALATINDEX, "38", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, 1, HPSPOVERQ, EXTENDED, DFLT}, },
{ EVALATINDEX, "39", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ EVALATINDEX, "40", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ EVALATINDEX, "41", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, STANDARD, DFLT}, },
{ EVALATINDEX, "42", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, STANDARD, DFLT}, },
{ EVALATINDEX, "43", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, STANDARD, DFLT}, },
{ EVALATINDEX, "44", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, STANDARD, DFLT}, },
{ EVALATINDEX, "45", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ EVALATINDEX, "46", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ EVALATINDEX, "47", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, STANDARD, DFLT}, },
{ EVALATINDEX, "48", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, STANDARD, DFLT}, },
{ EVALATINDEX, "49", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, STANDARD, DFLT}, },
{ EVALATINDEX, "50", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, STANDARD, DFLT}, },
{ EVALATINDEX, "51", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ EVALATINDEX, "52", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, STANDARD, DFLT}, },
{ EVALATINDEX, "53", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, EXTENDED, DFLT}, },
{ EVALATINDEX, "54", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, EXTENDED, DFLT}, },
{ EVALATINDEX, "55", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, EXTENDED, DFLT}, },
{ EVALATINDEX, "56", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, EXTENDED, DFLT}, },
{ EVALATINDEX, "57", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ EVALATINDEX, "58", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, BV, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ EVALATINDEX, "59", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, EXTENDED, DFLT}, },
{ EVALATINDEX, "60", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPS, EXTENDED, DFLT}, },
{ EVALATINDEX, "61", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, EXTENDED, DFLT}, },
{ EVALATINDEX, "62", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQ, EXTENDED, DFLT}, },
{ EVALATINDEX, "63", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, UNIFORM_TERNARY, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },
{ EVALATINDEX, "64", {BFVRNS_SCHEME, DFLT, 0, DFLT, 20, BATCH, GAUSSIAN, DFLT, DFLT, DFLT, HYBRID, DFLT, DFLT, PTM_XTR_LRG, DFLT, DFLT, 1, HPSPOVERQLEVELED, EXTENDED, DFLT}, },

// ==========================================
// TestType, Descr, Scheme, RDim, MultDepth, SModSize, DSize, BatchSz, SecKeyDist, MaxRelinSkDeg, FModSize, SecLvl, KSTech, ScalTech, LDigits, PtMod, StdDev, EvalAddCt, KSCt, MultTech EncTech, PREMode
{ EVALMERGE, "01", {BGVRNS_SCHEME, 256, 2, DFLT, BV_DSIZE, BATCH, UNIFORM_TERNARY, 1, 60, HEStd_NotSet, BV, FIXEDMANUAL, DFLT, PTM_LRG, DFLT, DFLT, DFLT, DFLT, STANDARD, DFLT}, },
Expand Down