Skip to content

Commit

Permalink
Added unit tests for larger plaintext moduli in BFV (#880)
Browse files Browse the repository at this point in the history
* added BFV unit tests for 45-bit plaintext moduli

* changed the comment from 45-bit to 46-bit plaintext modulus

---------

Co-authored-by: Yuriy Polyakov <ypolyakod@dualitytech.com>
  • Loading branch information
yspolyakov and Yuriy Polyakov authored Oct 21, 2024
1 parent 3f72724 commit 1d37679
Showing 1 changed file with 53 additions and 1 deletion.
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

0 comments on commit 1d37679

Please sign in to comment.