Skip to content

Commit

Permalink
remove the extra keys in homomorphic decode (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreea-alexandru authored Oct 23, 2024
1 parent 2c05c4b commit 651a244
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pke/lib/scheme/ckksrns/ckksrns-fhe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ std::vector<int32_t> FHECKKSRNS::FindSlotsToCoeffsRotationIndices(uint32_t slots
// Computing all indices for baby-step giant-step procedure for encoding and decoding
indexList.reserve(b + g - 2 + bRem + gRem - 2 + 1 + M);

for (int32_t s = 0; s < int32_t(levelBudget); s++) {
for (int32_t s = 0; s < int32_t(levelBudget) - flagRem; s++) {
for (int32_t j = 0; j < g; j++) {
indexList.emplace_back(
ReduceRotation((j - (numRotations + 1) / 2 + 1) * (1 << (s * layersCollapse)), M / 4));
Expand Down Expand Up @@ -2337,8 +2337,8 @@ Plaintext FHECKKSRNS::MakeAuxPlaintext(const CryptoContextImpl<DCRTPoly>& cc, co
if (logc < 0) {
OPENFHE_THROW("Too small scaling factor");
}
int32_t logValid = (logc <= MAX_BITS_IN_WORD) ? logc : MAX_BITS_IN_WORD;
int32_t logApprox = logc - logValid;
int32_t logValid = (logc <= MAX_BITS_IN_WORD) ? logc : MAX_BITS_IN_WORD;
int32_t logApprox = logc - logValid;
double approxFactor = pow(2, logApprox);

std::vector<int64_t> temp(2 * slots);
Expand Down Expand Up @@ -2369,11 +2369,11 @@ Plaintext FHECKKSRNS::MakeAuxPlaintext(const CryptoContextImpl<DCRTPoly>& cc, co
double imagVal = prodFactor.imag();

if (realVal > realMax) {
realMax = realVal;
realMax = realVal;
realMaxIdx = idx;
}
if (imagVal > imagMax) {
imagMax = imagVal;
imagMax = imagVal;
imagMaxIdx = idx;
}
}
Expand All @@ -2396,11 +2396,11 @@ Plaintext FHECKKSRNS::MakeAuxPlaintext(const CryptoContextImpl<DCRTPoly>& cc, co
int64_t re = std::llround(dre);
int64_t im = std::llround(dim);

temp[i] = (re < 0) ? Max64BitValue() + re : re;
temp[i] = (re < 0) ? Max64BitValue() + re : re;
temp[i + slots] = (im < 0) ? Max64BitValue() + im : im;
}

const std::shared_ptr<ILDCRTParams<BigInteger>> bigParams = plainElement.GetParams();
const std::shared_ptr<ILDCRTParams<BigInteger>> bigParams = plainElement.GetParams();
const std::vector<std::shared_ptr<ILNativeParams>>& nativeParams = bigParams->GetParams();

for (size_t i = 0; i < nativeParams.size(); i++) {
Expand Down Expand Up @@ -2436,7 +2436,7 @@ Plaintext FHECKKSRNS::MakeAuxPlaintext(const CryptoContextImpl<DCRTPoly>& cc, co
// Scale back up by the approxFactor to get the correct encoding.
if (logApprox > 0) {
int32_t logStep = (logApprox <= MAX_LOG_STEP) ? logApprox : MAX_LOG_STEP;
auto intStep = DCRTPoly::Integer(uint64_t(1) << logStep);
auto intStep = DCRTPoly::Integer(uint64_t(1) << logStep);
std::vector<DCRTPoly::Integer> crtApprox(numTowers, intStep);
logApprox -= logStep;

Expand Down

0 comments on commit 651a244

Please sign in to comment.