From 55e9590c4b74e20ed910c4acb5b62e8c415cf18c Mon Sep 17 00:00:00 2001 From: andreea-alexandru <31080521+andreea-alexandru@users.noreply.github.com> Date: Sun, 19 May 2024 23:37:39 -0400 Subject: [PATCH] 769 fix bug in evalchebyshevseriesps (#772) * fixed issue for n=6 * more necessary clones --- .../lib/scheme/ckksrns/ckksrns-advancedshe.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pke/lib/scheme/ckksrns/ckksrns-advancedshe.cpp b/src/pke/lib/scheme/ckksrns/ckksrns-advancedshe.cpp index 117f84e38..9d0f2ff09 100644 --- a/src/pke/lib/scheme/ckksrns/ckksrns-advancedshe.cpp +++ b/src/pke/lib/scheme/ckksrns/ckksrns-advancedshe.cpp @@ -773,7 +773,7 @@ Ciphertext AdvancedSHECKKSRNS::InnerEvalChebyshevPS(ConstCiphertextModReduceInPlace(cu); } else { - cu = T.front(); + cu = T.front()->Clone(); } } else { @@ -820,14 +820,14 @@ Ciphertext AdvancedSHECKKSRNS::InnerEvalChebyshevPS(ConstCiphertextEvalLinearWSumMutable(ctxs, weights); // the highest order coefficient will always be a power of two up to 2^{m-1} because q is "monic" but the Chebyshev rule adds a factor of 2 // we don't need to increase the depth by multiplying the highest order coefficient, but instead checking and summing, since we work with m <= 4. - Ciphertext sum = T[k - 1]; + Ciphertext sum = T[k - 1]->Clone(); for (uint32_t i = 0; i < log2(divqr->q.back()); i++) { sum = cc->EvalAdd(sum, sum); } cc->EvalAddInPlace(qu, sum); } else { - Ciphertext sum = T[k - 1]; + Ciphertext sum = T[k - 1]->Clone(); for (uint32_t i = 0; i < log2(divqr->q.back()); i++) { sum = cc->EvalAdd(sum, sum); } @@ -864,7 +864,7 @@ Ciphertext AdvancedSHECKKSRNS::InnerEvalChebyshevPS(ConstCiphertextEvalAddInPlace(su, T[k - 1]); } else { - su = T[k - 1]; + su = T[k - 1]->Clone(); } // adds the free term (at x^0) @@ -906,7 +906,7 @@ Ciphertext AdvancedSHECKKSRNS::EvalChebyshevSeriesPS(ConstCiphertext