Skip to content

Commit

Permalink
Validate digitSize for all schemes, including CKKS
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuponitskiy-duality committed Dec 6, 2024
1 parent 22f701f commit 761c17b
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/pke/lib/scheme/gen-cryptocontext-params-validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ void validateParametersForCryptocontext(const Params& parameters) {
}
}
else if (isBFVRNS(scheme)) {
if(BV == parameters.GetKeySwitchTechnique()) {
const uint32_t maxDigitSize = uint32_t(std::ceil(MAX_MODULUS_SIZE/2));
if(maxDigitSize < parameters.GetDigitSize()) {
OPENFHE_THROW("digitSize should not be greater than " + std::to_string(maxDigitSize) +
" for keySwitchTechnique == BV");
}
}
if (0 == parameters.GetPlaintextModulus()) {
OPENFHE_THROW("PlaintextModulus is not set. It should be set to a non-zero value");
}
Expand All @@ -76,13 +69,6 @@ void validateParametersForCryptocontext(const Params& parameters) {
}
}
else if (isBGVRNS(scheme)) {
if(BV == parameters.GetKeySwitchTechnique()) {
const uint32_t maxDigitSize = uint32_t(std::ceil(MAX_MODULUS_SIZE/2));
if(maxDigitSize < parameters.GetDigitSize()) {
OPENFHE_THROW("digitSize should not be greater than " + std::to_string(maxDigitSize) +
" for keySwitchTechnique == BV");
}
}
if (0 == parameters.GetPlaintextModulus()) {
OPENFHE_THROW("PlaintextModulus is not set. It should be set to a non-zero value");
}
Expand Down Expand Up @@ -147,6 +133,13 @@ void validateParametersForCryptocontext(const Params& parameters) {
"]. Ring dimension must be a power of 2.");
OPENFHE_THROW(errorMsg);
}
if (BV == parameters.GetKeySwitchTechnique()) {
const uint32_t maxDigitSize = uint32_t(std::ceil(MAX_MODULUS_SIZE / 2));
if (maxDigitSize < parameters.GetDigitSize()) {
OPENFHE_THROW("digitSize should not be greater than " + std::to_string(maxDigitSize) +
" for keySwitchTechnique == BV");
}
}
//====================================================================================================================
constexpr usint maxMultiplicativeDepthValue = 1000;
if (parameters.GetMultiplicativeDepth() > maxMultiplicativeDepthValue) {
Expand Down

0 comments on commit 761c17b

Please sign in to comment.