Context.h
Same as above, but for "thin" bootstrapping, where the slots are assumed to contain constants.
Definition: recryption.h:123
ModuliSizes modSizes
A helper table to map required modulo-sizes to primeSets.
Definition: Context.h:356
double noiseBoundForUniform(double magBound, long degBound) const
Definition: Context.h:188
long ithPrime(unsigned long i) const
The ith small prime in the modulus chain.
Definition: Context.h:422
ThinRecryptData rcData
Bootstrapping-related data in the context.
Definition: Context.h:380
void writeContextBaseBinary(std::ostream &str, const Context &context)
write [m p r gens ords] data
Definition: Context.cpp:225
void buildModChain(Context &context, long nBits, long nDgts=3, bool willBeBootstrappable=false, long skHwt=0, long resolution=3, long bitsInSpecialPrimes=0)
Definition: primeChain.cpp:748
std::shared_ptr< const PowerfulDCRT > pwfl_converter
Definition: Context.h:139
long last() const
Returns the last element, -1 if the set is empty.
Definition: IndexSet.h:71
double noiseBoundForHWt(long hwt, UNUSED long degBound) const
Definition: Context.h:294
void writeContextBase(std::ostream &s, const Context &context)
write [m p r gens ords] data
Definition: Context.cpp:405
double boundForRecryption(long skHwt=0) const
Definition: Context.h:330
void init(const Context &context, const NTL::Vec< long > &mvec_, bool alsoThick, long t=0, bool build_cache=false, bool minimal=false)
Initialize the recryption data in the context.
Definition: recryption.cpp:772
friend void readContextBase(std::istream &str, unsigned long &m, unsigned long &p, unsigned long &r, std::vector< long > &gens, std::vector< long > &ords)
read [m p r] data, needed to construct context
Definition: Context.cpp:464
bool isZeroDivisor(const NTL::ZZ &num) const
Is num divisible by any of the primes in the chain?
Definition: Context.h:434
double lweEstimateSecurity(int n, double log2AlphaInv, int hwt)
An estimate for the security-level. This has a lower bound of 0.
Definition: Context.h:53
void readContextBaseBinary(std::istream &s, unsigned long &m, unsigned long &p, unsigned long &r, std::vector< long > &gens, std::vector< long > &ords)
read [m p r gens ords] data, needed to construct context
Definition: Context.cpp:254
long skHwt
Hamming weight of recryption secret key.
Definition: recryption.h:49
const Cmodulus & ithModulus(unsigned long i) const
Cmodulus object corresponding to ith small prime in the chain.
Definition: Context.h:428
double noiseBoundForMod(long modulus, long degBound) const
Definition: Context.h:226
Context(unsigned long m, unsigned long p, unsigned long r, const std::vector< long > &gens=std::vector< long >(), const std::vector< long > &ords=std::vector< long >())
Definition: Context.cpp:569
friend void writeContextBase(std::ostream &str, const Context &context)
write [m p r] data
Definition: Context.cpp:405
NTL::ZZ productOfPrimes(const IndexSet &s) const
Definition: Context.h:454
void writeContextBinary(std::ostream &str, const Context &context)
Definition: Context.cpp:284
void init(const Context &context)
initialize helper table for a given chain
Definition: primeChain.cpp:58
long getPow2() const
if m = 2^k, then pow2 == k; otherwise, pow2 == 0
Definition: PAlgebra.h:189
double noiseBoundForGaussian(double sigma, long degBound) const
Definition: Context.h:249
void readContextBase(std::istream &s, unsigned long &m, unsigned long &p, unsigned long &r, std::vector< long > &gens, std::vector< long > &ords)
read [m p r gens ords] data, needed to construct context
Definition: Context.cpp:464
std::shared_ptr< const PAlgebraMod > alMod
for plaintext space p^{e-e'+r}
Definition: recryption.h:52
Provides FFT and iFFT routines modulo a single-precision prime.
Definition: CModulus.h:43
long numPrimes() const
Total number of small prime in the chain.
Definition: Context.h:431
void AddSmallPrime(long q)
Just add the given prime to the chain.
Definition: primeChain.cpp:450
long FindM(long k, long nBits, long c, long p, long d, long s, long chosen_m, bool verbose=false)
Returns smallest parameter m satisfying various constraints:
Definition: Context.cpp:24
double logOfProduct(const IndexSet &s) const
Returns the natural logarithm of productOfPrimes(s)
Definition: Context.h:467
friend std::ostream & operator<<(std::ostream &str, const Context &context)
Write all other data.
Definition: Context.cpp:426
void readContextBinary(std::istream &str, Context &context)
Definition: Context.cpp:332
long getNFactors() const
The number of distinct prime factors of m.
Definition: PAlgebra.h:174
Definition: apiAttributes.h:21
friend void readContextBinary(std::istream &str, Context &context)
Definition: Context.cpp:332
long first() const
Returns the first element, 0 if the set is empty.
Definition: IndexSet.h:68
NTL::xdouble noiseBoundForUniform(NTL::xdouble magBound, long degBound) const
Definition: Context.h:193
void productOfPrimes(NTL::ZZ &p, const IndexSet &s) const
The product of all the primes in the given set.
Definition: Context.cpp:178
double logOfPrime(unsigned long i) const
Returns the natural logarithm of the ith prime.
Definition: Context.h:464
A helper class to map required modulo-sizes to primeSets.
Definition: primeChain.h:28
double noiseBoundForSmall(double prob, long degBound) const
Definition: Context.h:271
double stdDevForRecryption(long skHwt=0) const
NOTE: this is a bit heuristic. See design document for details.
Definition: Context.h:313
NTL::xdouble stdev
sqrt(variance) of the LWE error (default=3.2)
Definition: Context.h:148
bool inChain(long p) const
Is p already in the chain?
Definition: Context.h:443
std::unique_ptr< Context > buildContextFromAscii(std::istream &str)
Definition: Context.cpp:480
friend std::istream & operator>>(std::istream &str, Context &context)
read all other data associated with context
Definition: Context.cpp:488
std::unique_ptr< Context > buildContextFromBinary(std::istream &str)
Definition: Context.cpp:276
double fsquare(double x)
Return the square of a number as a double.
Definition: NumbTh.h:148
friend void writeContextBinary(std::ostream &str, const Context &context)
Definition: Context.cpp:284
std::shared_ptr< PolyModRing > slotRing
The structure of a single slot of the plaintext space.
Definition: Context.h:145
void printout(std::ostream &out=std::cout) const
print out algebra and other important info
Definition: Context.cpp:590
void makeBootstrappable(const NTL::Vec< long > &mvec, long skWht=0, bool build_cache=false, bool alsoThick=true)
Definition: Context.h:390
double securityLevel(int hwt=0) const
An estimate for the security-level. This has a lower bound of 0.
Definition: Context.h:495
std::vector< IndexSet > digits
The set of primes for the digits.
Definition: Context.h:376
std::shared_ptr< const EncryptedArray > ea
A default EncryptedArray.
Definition: Context.h:137