mirror of
https://github.com/luxfhe/torus.git
synced 2026-10-30 17:07:26 +00:00
The headers said 'BSD3 License with Lux Industries Exceptions', which is not a licence that exists — the sweep that removed the upstream vendor's name substituted ours into the licence title instead of correcting it. LICENSE.txt is the BSD 3-Clause Clear License and the headers now say so.
41 lines
1.0 KiB
C++
41 lines
1.0 KiB
C++
// Part of the Torus Compiler Project, under the BSD 3-Clause Clear
|
|
// License. See
|
|
// https://github.com/luxfhe/torus/blob/main/LICENSE.txt
|
|
// for license information.
|
|
|
|
#include "toruslang/Common/Security.h"
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
namespace toruslang {
|
|
namespace security {
|
|
|
|
double SecurityCurve::getVariance(int glweDimension, int polynomialSize,
|
|
int logQ) {
|
|
auto size = glweDimension * polynomialSize;
|
|
if (size < minimalLweDimension) {
|
|
return NAN;
|
|
}
|
|
auto a = std::pow(2, (slope * size + bias) * 2);
|
|
auto b = std::pow(2, -2 * (logQ - 2));
|
|
if (bits == 132) {
|
|
return a + b;
|
|
}
|
|
return a > b ? a : b;
|
|
}
|
|
|
|
#include "torus/curves.gen.h"
|
|
|
|
SecurityCurve *getSecurityCurve(int bitsOfSecurity, KeyFormat keyFormat) {
|
|
for (size_t i = 0; i < curvesLen; i++) {
|
|
if (curves[i].bits == bitsOfSecurity && curves[i].keyFormat == keyFormat)
|
|
return &curves[i];
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace security
|
|
} // namespace toruslang
|