DoubleCRT.h
A helper class to enforce consistency within an DoubleCRTHelper object.
Definition: DoubleCRT.h:34
virtual void init(NTL::vec_long &v)
the init method ensures that all rows have the same size
Definition: DoubleCRT.h:42
virtual IndexMapInit< NTL::vec_long > * clone() const
clone allocates a new object and copies the content
Definition: DoubleCRT.h:45
Implementing polynomials (elements in the ring R_Q) in double-CRT form.
Definition: DoubleCRT.h:76
void readJSON(std::istream &str)
In-place read from the str std::istream the serialized ciphertext (Ctxt) object.
Definition: DoubleCRT.cpp:1443
void Mul(const DoubleCRT &other, bool matchIndexSets=true)
Definition: DoubleCRT.h:349
void setPrimes(const IndexSet &s1)
@ brief make prime set equal to s1
Definition: DoubleCRT.h:277
DoubleCRT(const NTL::ZZ &num, const Context &context, const IndexSet &indexSet)
Definition: DoubleCRT.h:200
void scaleDownToSet(const IndexSet &s, long ptxtSpace, NTL::ZZX &delta)
Definition: DoubleCRT.cpp:1312
void addPrimes(const IndexSet &s1, NTL::ZZX *poly_p=0)
Expand the index set by s1. It is assumed that s1 is disjoint from the current index set....
Definition: DoubleCRT.cpp:413
void Sub(const DoubleCRT &other, bool matchIndexSets=true)
Definition: DoubleCRT.h:344
DoubleCRT & operator=(const DoubleCRT &other)
Definition: DoubleCRT.cpp:663
double sampleGaussianBounded(double stdev=0.0)
Definition: DoubleCRT.cpp:1276
friend std::istream & operator>>(std::istream &s, DoubleCRT &d)
Definition: DoubleCRT.cpp:1372
DoubleCRT & operator*=(const DoubleCRT &other)
Definition: DoubleCRT.h:320
bool operator!=(const DoubleCRT &other) const
Definition: DoubleCRT.h:242
DoubleCRT(const DoubleCRT &other)=default
NTL::xdouble breakIntoDigits(std::vector< DoubleCRT > &dgts) const
Break into n digits,according to the primeSets in context.digits. See Section 3.1....
Definition: DoubleCRT.cpp:327
JsonWrapper writeToJSON() const
Write out the ciphertext (Ctxt) object to a JsonWrapper.
Definition: DoubleCRT.cpp:1416
void toPoly(NTL::ZZX &p, const IndexSet &s, bool positive=false) const
Recovering the polynomial in coefficient representation. This yields an integer polynomial with coeff...
Definition: DoubleCRT.cpp:773
double sampleSmall()
Coefficients are -1/0/1, Prob[0]=1/2.
Definition: DoubleCRT.cpp:1229
double addPrimesAndScale(const IndexSet &s1)
Expand index set by s1, and multiply by Prod_{q in s1}. s1 is disjoint from the current index set,...
Definition: DoubleCRT.cpp:451
double sampleUniform(long B)
Coefficients are uniform in [-B..B].
Definition: DoubleCRT.cpp:1296
void randomize(const NTL::ZZ *seed=nullptr)
Fills each row i with random ints mod pi, uses NTL's PRG.
Definition: DoubleCRT.cpp:1106
void removePrimes(const IndexSet &s1)
Remove s1 from the index set.
Definition: DoubleCRT.h:274
void Add(const DoubleCRT &other, bool matchIndexSets=true)
Definition: DoubleCRT.h:339
long getOneRow(NTL::Vec< long > &row, long idx, bool positive=false) const
Get one row of a polynomial.
Definition: DoubleCRT.cpp:749
void Exp(long k)
Small-exponent polynomial exponentiation.
Definition: DoubleCRT.cpp:990
void writeTo(std::ostream &str) const
Write out the DoubleCRT object in binary format.
Definition: DoubleCRT.cpp:1378
static DoubleCRT readFrom(std::istream &str, const Context &context)
Read from the stream the serialized DoubleCRT object in binary format.
Definition: DoubleCRT.cpp:1390
DoubleCRT & operator+=(const DoubleCRT &other)
Definition: DoubleCRT.h:294
DoubleCRT & operator-=(const DoubleCRT &other)
Definition: DoubleCRT.h:302
double sampleHWt(long Hwt)
Coefficients are -1/0/1 with pre-specified number of nonzeros.
Definition: DoubleCRT.cpp:1248
void complexConj()
Compute the complex conjugate, the same as automorph(m-1)
Definition: DoubleCRT.cpp:1088
double sampleGaussian(double stdev=0.0)
Coefficients are Gaussians Return a high probability bound on L-infty norm of canonical embedding.
Definition: DoubleCRT.cpp:1266
bool operator==(const DoubleCRT &other) const
Definition: DoubleCRT.h:234
friend std::ostream & operator<<(std::ostream &s, const DoubleCRT &d)
Definition: DoubleCRT.cpp:1366
static DoubleCRT readFromJSON(std::istream &str, const Context &context)
Read from the stream the serialized ciphertext (Ctxt) object using JSON format.
Definition: DoubleCRT.cpp:1429
void automorph(long k)
Apply the automorphism F(X) --> F(X^k) (with gcd(k,m)=1)
Definition: DoubleCRT.cpp:1008
void read(std::istream &str)
In-place read from the stream the serialized DoubleCRT object in binary format.
Definition: DoubleCRT.cpp:1398
DoubleCRT(long num, const Context &context, const IndexSet &indexSet)
Definition: DoubleCRT.h:208
void remove(long j)
Delete indexes from IndexSet, may cause objects to be destroyed.
Definition: IndexMap.h:103
const IndexSet & getIndexSet() const
Get the underlying index set.
Definition: IndexMap.h:66
Definition: apiAttributes.h:21
void assertEq(const T &a, const T &b, const std::string &message)
Definition: assertions.h:108
Definition: JsonWrapper.h:9