Skip to content
New issue

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

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

Already on GitHub? # to your account

When the scaling method is set to FLEXIBLEAUTOEXT (Default), repeated additions produce incorrect result. #385

Closed
iquah1 opened this issue May 2, 2023 · 2 comments · Fixed by #436
Assignees
Labels
bug Something isn't working
Milestone

Comments

@iquah1
Copy link
Contributor

iquah1 commented May 2, 2023

Based off of [EvalAdd does not add in some cases](https://openfhe.discourse.group/t/evaladd-does-not-add-in-some-cases/517)

#include "openfhe.h"
#include <vector>
#include <iostream>

using namespace lbcrypto;
using namespace std;

int main(){

  uint32_t multDepth = 50;
  uint32_t scaleModSize = 59;
  CCParams<CryptoContextCKKSRNS> parameters;
  parameters.SetMultiplicativeDepth(multDepth);
  parameters.SetScalingModSize(scaleModSize);
  CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
  cc->Enable(PKE);
  cc->Enable(LEVELEDSHE);
  auto keys = cc->KeyGen();
  auto val = cc->Encrypt(keys.publicKey, cc->MakeCKKSPackedPlaintext(vector < double > {1}));
  for (int i = 0; i < 41; i++) {
    auto added = cc->EvalAdd(val, i);
    Plaintext p;
    cc->Decrypt(keys.secretKey, added, &p);
    p->SetLength(1);
    cout << "Added " << to_string(i) << ":\t" << p << endl;
  }
}

You'll see that after the first few iterations (which produce the correct result), we start encountering the wrong result

@yspolyakov yspolyakov changed the title When mult depth is high, repeated additions produces incorrect result. When the scaling method is set to FLEXIBLEAUTEXT (Default), repeated additions produces incorrect result. May 2, 2023
@yspolyakov
Copy link
Contributor

yspolyakov commented May 2, 2023

I verified that this example works (also for smaller depths and scaling factors) as long as the scaling mode is to FIXEDMANUAL, FIXEDAUTO, or FLEXIBLEAUTO.

@yspolyakov yspolyakov added the bug Something isn't working label May 2, 2023
@yspolyakov yspolyakov added this to the Release 1.0.4 milestone May 2, 2023
@yspolyakov yspolyakov changed the title When the scaling method is set to FLEXIBLEAUTEXT (Default), repeated additions produces incorrect result. When the scaling method is set to FLEXIBLEAUTOEXT (Default), repeated additions produce incorrect result. May 3, 2023
@yspolyakov yspolyakov self-assigned this May 24, 2023
@yspolyakov
Copy link
Contributor

Caused by the same bug as #393

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants