The polynomial coefficient mismatch can be reproduced as follows. Note that the same issue doesn’t appear when n
is set to a higher power of two.
usint n = 2;
size_t kRes = 4;
size_t size = 1;
auto paramsTest = std::make_shared<ILDCRTParams<BigInteger>>(2 * n, size, kRes);
// create a vector of strings "1" and "1"
std::vector<std::string> coeffsTest = {"1", "1"};
// Create a BigVector
lbcrypto::BigVector bigVecTest(paramsTest->GetRingDimension(), paramsTest->GetModulus());
for (size_t i = 0; i < coeffsTest.size() && i < paramsTest->GetRingDimension(); ++i) {
bigVecTest[i] = BigInteger(coeffsTest[i]);
}
// Create a Poly that supports BigInteger coefficients
lbcrypto::PolyImpl<lbcrypto::BigVector> polyLargeTest(paramsTest, Format::COEFFICIENT);
polyLargeTest.SetValues(bigVecTest, Format::COEFFICIENT);
// Convert polyLarge to a DCRTPoly
lbcrypto::DCRTPoly dcrtPolyTest(polyLargeTest, paramsTest);
std::cout << "dcrtPolyTest before set to eval" << dcrtPolyTest << std::endl; // [1, 1] correct!
dcrtPolyTest.SetFormat(Format::EVALUATION);
std::cout << "dcrtPolyTest after set to eval " << dcrtPolyTest << std::endl; // [6, 9] correct!
dcrtPolyTest.SetFormat(Format::COEFFICIENT);
std::cout << "dcrtPolyTest after set back to coef" << dcrtPolyTest << std::endl; // [2, 0] wrong!