fix: getSecurityCurve

This commit is contained in:
Quentin Bourgerie
2023-01-16 17:10:56 +01:00
parent b14d11549f
commit b3898cca8f

View File

@@ -43,8 +43,7 @@ struct SecurityCurve {
/// @param logQ The log of q
/// @return The secure encryption variances
double getVariance(int glweDimension, int polynomialSize, int logQ) {
auto a = std::pow(
2, (slope * glweDimension * polynomialSize + bias) * 2);
auto a = std::pow(2, (slope * glweDimension * polynomialSize + bias) * 2);
auto b = std::pow(2, -2 * (logQ - 2));
return a > b ? a : b;
}
@@ -56,10 +55,12 @@ struct SecurityCurve {
/// @param bitsOfSecurity The number of bits of security
/// @param keyFormat The format of the key
/// @return The security curve or nullptr if the curve is not found.
SecurityCurve *getSecurtityCurve(int bitsOfSecurity, KeyFormat keyFormat) {
std::find_if(curves.begin(), curves.end(), [&](SecurityCurve c) {
return c.bits == bitsOfSecurity && c.keyFormat == keyFormat;
});
SecurityCurve *getSecurityCurve(int bitsOfSecurity, KeyFormat keyFormat) {
for (size_t i = 0; i < curves.size(); i++) {
if (curves[i].bits == bitsOfSecurity && curves[i].keyFormat == keyFormat)
return &curves[i];
}
return nullptr;
}
} // namespace concrete