Skip to content

Commit

Permalink
fixed type
Browse files Browse the repository at this point in the history
  • Loading branch information
nindanaoto committed Apr 10, 2024
1 parent c926371 commit 793b35a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion include/gate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ inline void HomGate(TLWE<typename iksP::targetP> &res,
res[brP::domainP::k * brP::domainP::n] += offset;
GateBootstrapping<brP, μ, iksP>(res, res, ek);
}

template <class iksP, class brP, typename brP::targetP::T μ, int casign,
int cbsign, typename iksP::domainP::T offset>
int cbsign, std::make_signed_t<typename iksP::domainP::T> offset>
inline void HomGate(TLWE<typename brP::targetP> &res,
const TLWE<typename iksP::domainP> &ca,
const TLWE<typename iksP::domainP> &cb, const EvalKey &ek)
Expand Down
6 changes: 3 additions & 3 deletions include/params/128bit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct lvl0param {
ErrorDistribution::ModularGaussian;
static const inline double α = 0.000'092'511'997'467'675'6; // fresh noise
using T = uint16_t; // Torus representation
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1LL << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -36,7 +36,7 @@ struct lvl1param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -25); // fresh noise
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << 29;
static constexpr std::make_signed_t<T> μ = 1 << 29;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -57,7 +57,7 @@ struct lvl2param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -47); // fresh noise
using T = uint64_t; // Torus representation
static constexpr T μ = 1ULL << 61;
static constexpr std::make_signed_t<T> μ = 1LL << 61;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast<double>(1ULL << (std::numeric_limits<T>::digits - 4));
Expand Down
6 changes: 3 additions & 3 deletions include/params/compress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct lvl0param {
static constexpr inline double α =
0.000'092'511'997'467'675'6; // fresh noise, 2^{-13.4}
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -41,7 +41,7 @@ struct lvl1param {
using T = uint32_t; // Torus representation
static constexpr T q = 40960001;
static constexpr uint qbit = 27;
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -64,7 +64,7 @@ struct lvl2param {
using T = uint64_t; // Torus representation
static constexpr T q = 1ULL << 48;
static constexpr uint qbit = 48;
static constexpr T μ = q / 8;
static constexpr std::make_signed_t<T> μ = q / 8;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ = μ;
};
Expand Down
4 changes: 2 additions & 2 deletions include/params/concrete.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct lvl0param {
static constexpr inline double α =
0.000'092'511'997'467'675'6; // fresh noise, 2^{-13.4}
using T = uint16_t; // Torus representation
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1 << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -42,7 +42,7 @@ struct lvl1param {
static const inline double α =
0.0000000342338787018369; // fresh noise, 2^{-24.8...}
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << 29;
static constexpr std::make_signed_t<T> μ = 1 << 29;
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand Down
6 changes: 3 additions & 3 deletions include/params/ternary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct lvl0param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -15); // fresh noise
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1 << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -36,7 +36,7 @@ struct lvl1param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -25); // fresh noise
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << 29;
static constexpr std::make_signed_t<T> μ = 1 << 29;
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -57,7 +57,7 @@ struct lvl2param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -44); // fresh noise
using T = uint64_t; // Torus representation
static constexpr T μ = 1ULL << 61;
static constexpr std::make_signed_t<T> μ = 1LL << 61;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ = μ;
};
Expand Down
6 changes: 3 additions & 3 deletions include/params/tfhe-rs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct lvl0param {
static constexpr double α =
5.033523219195911e-06; // fresh noise, 2^{-17.6}
using T = uint32_t; // Torus representation
static constexpr T μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr std::make_signed_t<T> μ = 1U << (std::numeric_limits<T>::digits - 3);
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
static_cast<double>(1ULL << std::numeric_limits<T>::digits) /
Expand All @@ -42,7 +42,7 @@ struct lvl1param {
static const inline double α =
0.0000000000034525330484572114; // fresh noise, 2^{-24.8...}
using T = uint64_t; // Torus representation
static constexpr T μ = 1ULL << 61;
static constexpr std::make_signed_t<T> μ = 1LL << 61;
static constexpr uint32_t plain_modulus = 2;
static constexpr double Δ =
2 * static_cast<double>(1ULL << (std::numeric_limits<T>::digits - 1)) /
Expand All @@ -63,7 +63,7 @@ struct lvl2param {
ErrorDistribution::ModularGaussian;
static const inline double α = std::pow(2.0, -44); // fresh noise
using T = uint64_t; // Torus representation
static constexpr T μ = 1ULL << 61;
static constexpr std::make_signed_t<T> μ = 1LL << 61;
static constexpr uint32_t plain_modulus = 8;
static constexpr double Δ = μ;
};
Expand Down

0 comments on commit 793b35a

Please sign in to comment.