Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fixed a bug with parameter selection #893

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/pke/lib/scheme/bgvrns/bgvrns-parametergeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ bool ParameterGenerationBGVRNS::ParamsGenBGVRNS(std::shared_ptr<CryptoParameters
qBound += cryptoParamsBGVRNS->EstimateMultipartyFloodingLogQ();

// we add an extra bit to account for the special logic of selecting the RNS moduli in BGV
qBound++;
// ignore the case when there is only one max size modulus
if (qBound != static_cast<double>(auxBits))
dsuponitskiy marked this conversation as resolved.
Show resolved Hide resolved
qBound++;

uint32_t auxTowers = 0;
if (ksTech == HYBRID) {
Expand Down Expand Up @@ -482,7 +484,7 @@ bool ParameterGenerationBGVRNS::ParamsGenBGVRNS(std::shared_ptr<CryptoParameters
numPartQ, std::log2(moduliQ[0].ConvertToDouble()),
(moduliQ.size() > 1) ? std::log2(moduliQ[1].ConvertToDouble()) : 0,
(scalTech == FLEXIBLEAUTOEXT) ? std::log2(moduliQ[moduliQ.size() - 1].ConvertToDouble()) : 0,
(scalTech == FLEXIBLEAUTOEXT) ? moduliQ.size() - 1 : moduliQ.size(), auxBits, true);
(scalTech == FLEXIBLEAUTOEXT) ? moduliQ.size() - 1 : moduliQ.size(), auxBits, false);
newQBound += std::get<0>(hybridKSInfo);
}
} while (qBound < newQBound);
Expand Down
4 changes: 3 additions & 1 deletion src/pke/lib/scheme/ckksrns/ckksrns-parametergeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ bool ParameterGenerationCKKSRNS::ParamsGenCKKSRNS(std::shared_ptr<CryptoParamete
uint32_t qBound = firstModSize + (numPrimes - 1) * scalingModSize + extraModSize;

// we add an extra bit to account for the alternating logic of selecting the RNS moduli in CKKS
qBound++;
// ignore the case when there is only one max size modulus
if (qBound != static_cast<double>(auxBits))
dsuponitskiy marked this conversation as resolved.
Show resolved Hide resolved
qBound++;

// Estimate ciphertext modulus Q*P bound (in case of HYBRID P*Q)
if (ksTech == HYBRID) {
Expand Down
5 changes: 3 additions & 2 deletions src/pke/lib/schemerns/rns-cryptoparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,9 @@ std::pair<double, uint32_t> CryptoParametersRNS::EstimateLogP(uint32_t numPartQ,
maxBits = bits;
}

// we add an extra bit to account for for the special moduli selection logic in BGV and CKKS
if (addOne)
// we add an extra bit to account for the special moduli selection logic in BGV and CKKS
// ignore the case when there is only one max size modulus
if ((addOne) && (maxBits != static_cast<double>(auxBits)))
dsuponitskiy marked this conversation as resolved.
Show resolved Hide resolved
maxBits++;

// Select number of primes in auxiliary CRT basis
Expand Down