Skip to content

Commit

Permalink
Merge pull request #5 from fairmath/slots_for_string_encoding
Browse files Browse the repository at this point in the history
Check regarding slots parameter for string encoding
  • Loading branch information
g-arakelov authored Nov 29, 2024
2 parents 34645d3 + ae000ce commit f6865b2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/fairmathCli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,19 @@ int main(int argc, char *argv[]) try
std::shared_ptr<lbcrypto::PlaintextImpl> plaintext;
cc->Decrypt(ciphertext, privateKey, &plaintext);

plaintext->SetLength(variablesMap["slots"].as<int>());
if (dynamic_cast<const lbcrypto::StringEncoding*>(plaintext.get()))
{
if (std::find_if(parsed.options.begin(), parsed.options.end(),
[](const po::option& option) { return option.string_key == "slots"; })
!= parsed.options.end())
{
throw std::runtime_error("Slots are unavailable for string encoding");
}
}
else
{
plaintext->SetLength(variablesMap["slots"].as<int>());
}

std::ofstream ofsOutputDecryption(variablesMap["output"].as<const std::string&>(), std::ios::out);
if (!ofsOutputDecryption.is_open()) { throw std::runtime_error("Unable to open" + variablesMap["output"].as<const std::string&>()); }
Expand Down

0 comments on commit f6865b2

Please sign in to comment.