# Incorrect Result when using NORESCALE Scaling Technique in CKKS Scheme

**URL:** https://openfhe.discourse.group/t/incorrect-result-when-using-norescale-scaling-technique-in-ckks-scheme/1119
**Category:** Library Questions
**Tags:** questions, bugs
**Created:** [March 11, 2024, 4:36pm UTC](https://openfhe.discourse.group/t/incorrect-result-when-using-norescale-scaling-technique-in-ckks-scheme/1119 "2024-03-11T16:36:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Maokami](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/maokami/32/180_2.png) [@Maokami](https://openfhe.discourse.group/u/Maokami)
#### Post date: [March 11, 2024, 4:36pm UTC](https://openfhe.discourse.group/t/incorrect-result-when-using-norescale-scaling-technique-in-ckks-scheme/1119/1 "2024-03-11T16:36:40Z")

</div>

Hello OpenFHE Team,

I’ve encountered an incorrect result in the library and wanted to report it.  
Here is a minimal snippet of the code that reproduces the issue:

```auto
#include "openfhe.h"
using namespace lbcrypto;
using namespace std;

int main(void)
{
  CCParams<CryptoContextCKKSRNS> parameters;
  parameters.SetScalingTechnique(NORESCALE);

  CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
  cc->Enable(PKE);
  cc->Enable(LEVELEDSHE);
  KeyPair<DCRTPoly> keyPair;
  keyPair = cc->KeyGen();
  cc->EvalMultKeyGen(keyPair.secretKey);
  size_t slots(8);
  vector<complex<double>> tmp_vec_(8);
  Plaintext tmp;

  Ciphertext<DCRTPoly> x;
  double yP;
  int c;
  vector<double> tmp_vec_1 = {0.2, 0.4, 0.6, 0.8, 1.0};
  tmp = cc->MakeCKKSPackedPlaintext(tmp_vec_1);
  x = cc->Encrypt(keyPair.publicKey, tmp);

  // After this multiplication, the following addition doesn't work
  x = cc->EvalMult(x, tmp);

  // Result : x = 0.04000 0.16000 0.36000 0.64000 1.00000
  cc->Decrypt(keyPair.secretKey, x, &tmp);
  tmp_vec_ = tmp->GetCKKSPackedValue();
  for (int64_t tmp_i = 0; tmp_i < 5; ++tmp_i)
  {
    cout << fixed << setprecision(5) << real(tmp_vec_[tmp_i]) << " ";
  }
  cout << endl;

  vector<double> tmp_vec_5(slots, 1.0);
  tmp = cc->MakeCKKSPackedPlaintext(tmp_vec_5);
  x = cc->EvalAdd(x, tmp);

  // Result : x = 0.04000 0.16000 0.36000 0.64000 1.00000
  cc->Decrypt(keyPair.secretKey, x, &tmp);
  tmp_vec_ = tmp->GetCKKSPackedValue();
  for (int64_t tmp_i = 0; tmp_i < 5; ++tmp_i)
  {
    cout << fixed << setprecision(5) << real(tmp_vec_[tmp_i]) << " ";
  }
  cout << endl;
  return 0;
}

```

When executed on the latest version ( OpenFHE v1.1.4), the result is following:

```auto
0.04000 0.16000 0.36000 0.64000 1.00000 
0.04000 0.16000 0.36000 0.64000 1.00000 <- this is weird

```

It looks like EvalAdd doesn’t work after EvalMult.

I guess the problem lies in using the NORESCALE scaling technique in CKKS, which does make sense to me because rescaling is a core operation in CKKS.

However, if I understood correctly, I gently suggest that prohibiting the use of NORESCALE mode in the CKKS scheme might be better.

Thank you!

---

<div class="post-metadata">

### Author: ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)
#### Post date: [March 12, 2024, 6:06pm UTC](https://openfhe.discourse.group/t/incorrect-result-when-using-norescale-scaling-technique-in-ckks-scheme/1119/2 "2024-03-12T18:06:50Z")

</div>

Thank you for pointing this out. As you remarked, NORESCALE should not be used in CKKS. The OpenFHE design document [https://eprint.iacr.org/2022/915.pdf](https://eprint.iacr.org/2022/915.pdf) specifies which scaling techniques should be used for CKKS (all the other four). Currently, cryptocontext parameters do not check which scheme they are called for. I opened an issue [Check that the parameters input to the cryptocontext are scheme-specific · Issue #713 · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/issues/713).
