HElib 1.0 Implementing Homomorphic Encryption

- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Files Functions Variables Friends Pages
Public Member Functions | Public Attributes | List of all members
FHEcontext Class Reference

Maintaining the parameters. More...

`#include <FHEContext.h>`

## Public Member Functions
| FHEcontext (unsigned m, unsigned p, unsigned r)
bool | operator== (const FHEcontext &other) const
bool | operator!= (const FHEcontext &other) const
long | ithPrime (unsigned i) const
| The ith small prime in the modulus chain.
const Cmodulus & | ithModulus (unsigned i) const
| Cmodulus object corresponding to ith small prime in the chain.
long | numPrimes () const
| Total number of small prime in the chain.
bool | isZeroDivisor (const ZZ &num) const
| Is num divisible by any of the primes in the chain?
bool | inChain (long p) const
| Is p already in the chain?
double | logOfPrime (unsigned i) const
| Returns the natural logarithm of the ith prime.
double | logOfProduct (const IndexSet &s) const
| Returns the natural logarithm of productOfPrimes(s)
void | AddPrime (long p, bool special)
| Add p to the chain, if it's not already there.
void | productOfPrimes (ZZ &p, const IndexSet &s) const
| The product of all the primes in the given set.
ZZ | productOfPrimes (const IndexSet &s) const

## Public Attributes
PAlgebra | zMStar
| The structure of Zm*.
PAlgebraMod | alMod
| The structure of Z[X]/(Phi_m(X),2)
xdouble | stdev
| sqrt(variance) of the LWE error (default=3.2)
IndexSet | ctxtPrimes
| The "ciphertext primes", used for fresh ciphertexts. More...
IndexSet | specialPrimes
| All the other primes in the chain. More...
vector< IndexSet > | digits
| The set of primes for the digits. More...

## Friends
I/O routines
To write out all the data associated with a context, do the following: writeContextBase(str, context); str << context; The first function call writes out just [m p r], which is the data needed to invoke the context constructor. The second call writes out all other information, including the stdev field, the prime sequence (including which primes are "special"), and the digits info. To read in all the data associated with a context, do the following: unsigned m, p, r; readContextBase(str, m, p, r); FHEcontext context(m, p, r); str >> context; The call to readContextBase just reads the values m, p, r. Then, after constructing the context, the >> operator reads in and attaches all other information.
void | writeContextBase (ostream &str, const FHEcontext &context)
| write [m p r] data
ostream & | operator<< (ostream &str, const FHEcontext &context)
| Write all other data.
void | readContextBase (istream &str, unsigned &m, unsigned &p, unsigned &r)
| read [m p r] data, needed to construct context
istream & | operator>> (istream &str, FHEcontext &context)
| read all other data associated with context

## Detailed Description

Maintaining the parameters.

## Member Data Documentation

IndexSet FHEcontext::ctxtPrimes

The "ciphertext primes", used for fresh ciphertexts.

The public encryption key and "fresh" ciphertexts are encrypted relative to only a subset of the primes, to allow for mod-UP during key-switching. See section 3.1.6 in the design document (key-switching). In ctxtPrimes we keep the indexes of this subset. Namely, for a ciphertext part p in a fresh ciphertext we have p.getMap().getIndexSet()==ctxtPrimes.

vector<IndexSet> FHEcontext::digits

The set of primes for the digits.

The different columns in any key-switching matrix contain encryptions of multiplies of the secret key, sk, B1*sk, B2*B1*sk, B3*B2*B1*sk,... with each Bi a product of a few "non-special" primes in the chain. The digits data member indicate which primes correspond to each of the Bi's. These are all IndexSet objects, whose union is the subset ctxtPrimes.

The number of Bi's is one less than the number of columns in the key switching matrices (since the 1st column encrypts sk, without any Bi's), but we keep in the digits vector also an entry for the primes that do not participate in any Bi (so digits.size() is the same as the number of columns in the key switching matrices). See section 3.1.6 in the design document (key-switching).

IndexSet FHEcontext::specialPrimes

All the other primes in the chain.

For convenience, we also keep in specialPrimes the complemeting subset, i.e., specialPrimes = [0,numPrimes()-1] setminus ctxtPrimes.

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

- src/FHEContext.h
- src/FHEContext.cpp