27 #ifndef LBCRYPTO_OBFMATH_DGSAMPLING_H 28 #define LBCRYPTO_OBFMATH_DGSAMPLING_H 33 #include "lattice/field2n.h" 34 #include "math/matrix.h" 35 #include "math/nbtheory.h" 41 const double DG_ERROR = 8.27181e-25;
44 const int32_t N_MAX = 16384;
48 const double SIGMA = std::sqrt(std::log(2 * N_MAX / DG_ERROR) / M_PI);
51 const double SPECTRAL_CONSTANT = 1.8;
52 const auto SPECTRAL_BOUND = [](uint64_t n, uint64_t k,
53 uint64_t base) ->
double {
54 return SPECTRAL_CONSTANT * (base + 1) * SIGMA * SIGMA *
55 (std::sqrt(n * k) + std::sqrt(2 * n) + 4.7);
60 const auto SPECTRAL_BOUND_D = [](uint64_t n, uint64_t k, uint64_t base,
61 uint64_t d) ->
double {
62 return SPECTRAL_CONSTANT * (base + 1) * SIGMA * SIGMA *
63 (std::sqrt(d * n * k) + std::sqrt(2 * n) + 4.7);
72 template <
class Element>
89 static void GaussSampGq(
const Element &u,
double stddev,
size_t k,
90 const typename Element::Integer &q, int64_t base,
108 const typename Element::Integer &q,
109 int64_t base,
typename Element::DggType &dgg,
125 const typename Element::DggType &dgg,
141 const typename Element::DggType &dgg,
153 static shared_ptr<Matrix<int64_t>>
ZSampleF(
154 const Field2n &f,
const Field2n &c,
const typename Element::DggType &dgg,
161 static void Perturb(
double sigma,
size_t k,
size_t n,
const vector<double> &l,
162 const vector<double> &h, int64_t base,
163 typename Element::DggType &dgg, vector<int64_t> *p);
168 static void PerturbFloat(
double sigma,
size_t k,
size_t n,
169 const vector<double> &l,
const vector<double> &h,
170 int64_t base,
typename Element::DggType &dgg,
175 static void SampleC(
const Matrix<double> &c,
size_t k,
size_t n,
double sigma,
static void GaussSampGq(const Element &u, double stddev, size_t k, const typename Element::Integer &q, int64_t base, typename Element::DggType &dgg, Matrix< int64_t > *z)
Definition: dgsampling.cpp:39
A class to represent field elements with power-of-2 dimension.
Definition: field2n.h:42
static void ZSampleSigma2x2(const Field2n &a, const Field2n &b, const Field2n &d, const Matrix< Field2n > &c, const typename Element::DggType &dgg, shared_ptr< Matrix< int64_t >> p)
Definition: dgsampling.cpp:272
static void SampleMat(const Matrix< Field2n > &A, const Matrix< Field2n > &B, const Matrix< Field2n > &D, const Matrix< Field2n > &C, const typename Element::DggType &dgg, shared_ptr< Matrix< int64_t >> p)
Definition: dgsampling.cpp:313
static void GaussSampGqArbBase(const Element &u, double stddev, size_t k, const typename Element::Integer &q, int64_t base, typename Element::DggType &dgg, Matrix< int64_t > *z)
Definition: dgsampling.cpp:120
static shared_ptr< Matrix< int64_t > > ZSampleF(const Field2n &f, const Field2n &c, const typename Element::DggType &dgg, size_t n)
Definition: dgsampling.cpp:450
Utility class containing operations needed for lattice sampling; Sources: https://eprint.iacr.org/2017/844.pdf and https://eprint.iacr.org/2017/308.pdf This construction is based on the hardness of Ring-LWE problem.
Definition: dgsampling.h:73
Definition: binfhecontext.h:36