HElib  1.0
Implementing Homomorphic Encryption
 All Classes Files Functions Variables Friends Pages
Public Member Functions | Friends | List of all members
Ctxt Class Reference

A Ctxt object holds a single cipehrtext. More...

#include <Ctxt.h>

Public Member Functions

 Ctxt (const FHEPubKey &newPubKey, long newPtxtSpace=2)
 
Ctxtoperator= (const Ctxt &other)
 
bool operator== (const Ctxt &other) const
 
bool operator!= (const Ctxt &other) const
 
bool equalsTo (const Ctxt &other, bool comparePkeys=true) const
 
void clear ()
 
Ciphertext arithmetic
void negate ()
 
Ctxtoperator+= (const Ctxt &other)
 
Ctxtoperator-= (const Ctxt &other)
 
void addCtxt (const Ctxt &other, bool negative=false)
 
Ctxtoperator*= (const Ctxt &other)
 
void automorph (long k)
 
Ctxtoperator>>= (long k)
 
void smartAutomorph (long k)
 automorphism with re-lienarization
 
void addConstant (const DoubleCRT &dcrt, double size=0.0)
 
void addConstant (const ZZX &poly, double size=0.0)
 
void multByConstant (const DoubleCRT &dcrt, double size=0.0)
 
void multByConstant (const ZZX &poly, double size=0.0)
 
void multiplyBy (const Ctxt &other)
 
void multiplyBy2 (const Ctxt &other1, const Ctxt &other2)
 
void square ()
 
void cube ()
 
Ciphertext maintenance
void reLinearize (long keyIdx=0)
 
xdouble modSwitchAddedNoiseVar () const
 Estimate the added noise variance.
 
void modUpToSet (const IndexSet &s)
 Modulus-switching up (to a larger modulus). Must have primeSet <= s, and s must contain either all the special primes or none of them.
 
void modDownToSet (const IndexSet &s)
 Modulus-switching down (to a smaller modulus). mod-switch down to primeSet s, after this call we have primeSet<=s. s must contain either all special primes or none of them.
 
void findBaseSet (IndexSet &s) const
 Fidn the "natural level" of a cipehrtext. Find the highest IndexSet so that mod-switching down to that set results in the dominant noise term being the additive term due to rounding.
 
Utility methods
bool inCanonicalForm (long keyID=0) const
 A canonical ciphertext has handles pointing to (1,s)
 
bool isCorrect () const
 Would this ciphertext be decrypted without errors?
 
const FHEcontextgetContext () const
 
const FHEPubKeygetPubKey () const
 
const IndexSetgetPrimeSet () const
 
const xdouble & getNoiseVar () const
 
const long getPtxtSpace () const
 
const long getKeyID () const
 
const long getLevel () const
 How many primes in the "base-set" for that ciphertext.
 
double log_of_ratio () const
 Returns log(noise-variance)/2 - log(q)
 

Friends

class FHEPubKey
 
class FHESecKey
 
istream & operator>> (istream &str, Ctxt &ctxt)
 
ostream & operator<< (ostream &str, const Ctxt &ctxt)
 

Detailed Description

A Ctxt object holds a single cipehrtext.

The class Ctxt includes a vector<CtxtPart>: For a Ctxt c, c[i] is the i'th ciphertext part, which can be used also as a DoubleCRT object (since CtxtPart is derived from DoubleCRT). By convention, c[0], the first CtxtPart object in the vector, has skHndl that points to 1 (i.e., it is just added in upon decryption, without being multiplied by anything). We maintain the invariance that all the parts of a ciphertext are defined relative to the same set of primes.

A ciphertext contains also pointers to the general parameters of this FHE instance and the public key, and an estimate of the noise variance. The noise variance is determined by the norm of the canonical embedding of the noise polynomials, namely their evaluations in roots of the ring polynomial (which are the complex primitive roots of unity). We consider each such evaluation point as a random variable, and estimate the variances of these variables. This estimate is heuristic, assuming that various quantities "behave like independent random variables". The variance is added on addition, multiplied on multiplications, remains unchanged for automorphism, and is roughly scaled down by mod-switching with some added factor, and similarly scaled up by key-switching with some added factor. The noiseVar data member of the class keeps the esitmated variance.


The documentation for this class was generated from the following files: