# Polynomial mismatch doing switching format when \`n\` is set to 2

**URL:** <https://openfhe.discourse.group/t/polynomial-mismatch-doing-switching-format-when-n-is-set-to-2/1918>\
**Category:** Library Questions\
**Created:** [March 9, 2025, 4:20pm UTC](https://openfhe.discourse.group/t/polynomial-mismatch-doing-switching-format-when-n-is-set-to-2/1918 "2025-03-09T16:20:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![enricobottazzi](https://avatars.discourse-cdn.com/v4/letter/e/91b2a8/32.png) [@enricobottazzi](https://openfhe.discourse.group/u/enricobottazzi)\
**Post date:** [March 9, 2025, 4:20pm UTC](https://openfhe.discourse.group/t/polynomial-mismatch-doing-switching-format-when-n-is-set-to-2/1918/1 "2025-03-09T16:20:19Z")

</div>

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.

```auto
    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!

```

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [March 10, 2025, 6:49pm UTC](https://openfhe.discourse.group/t/polynomial-mismatch-doing-switching-format-when-n-is-set-to-2/1918/2 "2025-03-10T18:49:27Z")

</div>

The issue is confirmed. INTT has a problem when the ring dimension is 2. We created an issue [here](https://github.com/openfheorg/openfhe-development/issues/942), and it will be fixed in the upcoming release. In fact, a PR has already been created [here](https://github.com/openfheorg/openfhe-development/pull/943).

Thank you for reporting this problem.

Note that the case where the ring dimension is set to 2 is unlikely to be encountered in practice as the ring dimension for secure instantiations of FHE schemes would be much larger.
