Skip to content

Commit

Permalink
Validate multDepth as a cryptocontext parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuponitskiy-duality committed Dec 5, 2023
1 parent 1211f2e commit 6a56bfa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/pke/include/scheme/gen-cryptocontext-params.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class Params {
void SetToDefaults(SCHEME scheme);

void ValidateRingDim(usint ringDim);
void ValidateMultiplicativeDepth(usint multiplicativeDepth);

public:
explicit Params(SCHEME scheme0 = INVALID_SCHEME) {
Expand Down Expand Up @@ -387,6 +388,9 @@ class Params {
numLargeDigits = numLargeDigits0;
}
void SetMultiplicativeDepth(usint multiplicativeDepth0) {
// TODO (dsuponit): move the check below ValidateMultiplicativeDepth() to a separate validating function. see
// https://github.com/openfheorg/openfhe-development/issues/400
ValidateMultiplicativeDepth(multiplicativeDepth0);
multiplicativeDepth = multiplicativeDepth0;
}
void SetScalingModSize(usint scalingModSize0) {
Expand Down
10 changes: 10 additions & 0 deletions src/pke/lib/scheme/gen-cryptocontext-params-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ void Params::ValidateRingDim(usint ringDim) {
}
}
//====================================================================================================================
void Params::ValidateMultiplicativeDepth(usint multiplicativeDepth) {
constexpr usint maxMultiplicativeDepthValue = 1000;
if (multiplicativeDepth > maxMultiplicativeDepthValue) {
std::string errorMsg(std::string("Invalid multiplicativeDepth [") + std::to_string(multiplicativeDepth) +
"]. MultiplicativeDepth value must be between 0 and " +
std::to_string(maxMultiplicativeDepthValue) + ".");
OPENFHE_THROW(config_error, errorMsg);
}
}
//====================================================================================================================
Params::Params(const std::vector<std::string>& vals) {
if (getAllParamsDataMembers().size() != vals.size()) {
std::string errMsg(std::string("The number of data members and the number of values do not match: ") +
Expand Down

0 comments on commit 6a56bfa

Please sign in to comment.