A Ctxt object holds a single ciphertext. More...
#include <Ctxt.h>
Public Member Functions | |
Ctxt (const Ctxt &other)=default | |
Ctxt (const PubKey &newPubKey, long newPtxtSpace=0) | |
Ctxt (ZeroCtxtLike_type, const Ctxt &ctxt) | |
void | DummyEncrypt (const NTL::ZZX &ptxt, double size=-1.0) |
Ctxt & | operator= (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 | writeTo (std::ostream &str) const |
Write out the Ctxt object in binary format. More... | |
void | read (std::istream &str) |
In-place read from the stream the serialized Ctxt object in binary format. More... | |
void | writeToJSON (std::ostream &str) const |
Write out the ciphertext (Ctxt ) object to the output stream using JSON format. More... | |
JsonWrapper | writeToJSON () const |
Write out the ciphertext (Ctxt ) object to a JsonWrapper . More... | |
void | readJSON (std::istream &str) |
In-place read from the str std::istream the serialized ciphertext (Ctxt ) object. More... | |
void | readJSON (const JsonWrapper &j) |
In-place read from the JsonWrapper the serialized ciphertext (Ctxt ) object. More... | |
void | addedNoiseForCKKSDecryption (const SecKey &sk, double eps, NTL::ZZX &noise) const |
Ciphertext maintenance | |
void | reducePtxtSpace (long newPtxtSpace) |
Reduce plaintext space to a divisor of the original plaintext space. More... | |
void | hackPtxtSpace (long newPtxtSpace) |
void | bumpNoiseBound (double factor) |
void | relin_CKKS_adjust () |
void | reLinearize (long keyIdx=0) |
Ctxt & | cleanUp () |
void | blindCtxt (const NTL::ZZX &poly) |
Add a high-noise encryption of the given constant. More... | |
NTL::xdouble | modSwitchAddedNoiseBound () const |
Estimate the added noise. More... | |
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. More... | |
void | modDownToSet (const IndexSet &s) |
Modulus-switching down (to a smaller modulus). mod-switch down to primeSet \intersect s, after this call we have primeSet<=s. s must contain either all special primes or none of them. More... | |
void | bringToSet (const IndexSet &s) |
make the primeSet equal to newPrimeSet, via modUpToSet and modDownToSet More... | |
double | naturalSize () const |
IndexSet | naturalPrimeSet () const |
"natural size" is size before squaring More... | |
void | dropSmallAndSpecialPrimes () |
the corresponding primeSet More... | |
NTL::xdouble | totalNoiseBound () const |
returns the total noise bound, which for CKKS is ptxtMag*ratFactor + noiseBound More... | |
double | errorBound () const |
for CKKS, returns a bound on the absolute error (which is noiseBound/ratFactor); for BGV, returns 0. More... | |
double | capacity () const |
returns the "capacity" of a ciphertext, which is the log2 of the ratio of the modulus to the total noise bound More... | |
double | logOfPrimeSet () const |
returns the log of the prime set More... | |
long | bitCapacity () const |
the capacity in bits, returned as an integer More... | |
double | rawModSwitch (std::vector< NTL::ZZX > &zzParts, long toModulus) const |
Special-purpose modulus-switching for bootstrapping. More... | |
void | evalPoly (const NTL::ZZX &poly) |
compute the power X,X^2,...,X^n More... | |
Utility methods | |
void | clear () |
bool | isEmpty () const |
Is this an empty ciphertext without any parts. More... | |
bool | inCanonicalForm (long keyID=0) const |
A canonical ciphertext has (at most) handles pointing to (1,s) More... | |
bool | isCorrect () const |
Would this ciphertext be decrypted without errors? More... | |
const Context & | getContext () const |
const PubKey & | getPubKey () const |
const IndexSet & | getPrimeSet () const |
long | getPtxtSpace () const |
const NTL::xdouble & | getNoiseBound () const |
const NTL::xdouble & | getRatFactor () const |
const NTL::xdouble & | getPtxtMag () const |
void | setPtxtMag (const NTL::xdouble &z) |
long | getKeyID () const |
bool | isCKKS () const |
long | effectiveR () const |
double | log_of_ratio () const |
Returns log(noiseBound) - log(q) More... | |
Static Public Member Functions | |
static Ctxt | readFrom (std::istream &str, const PubKey &pubKey) |
Read from the stream the serialized Ctxt object in binary format. More... | |
static Ctxt | readFromJSON (std::istream &str, const PubKey &pubKey) |
Read from the stream the serialized ciphertext (Ctxt ) object using JSON format. More... | |
static Ctxt | readFromJSON (const JsonWrapper &j, const PubKey &pubKey) |
Read from the JsonWrapper the serialized ciphertext (Ctxt ) object. More... | |
static void | equalizeRationalFactors (Ctxt &c1, Ctxt &c2) |
Static Public Attributes | |
static constexpr std::string_view | typeName = "Ctxt" |
Class label to be added to JSON serialization as object type information. More... | |
Friends | |
class | PubKey |
class | SecKey |
class | BasicAutomorphPrecon |
std::istream & | operator>> (std::istream &str, Ctxt &ctxt) |
std::ostream & | operator<< (std::ostream &str, const Ctxt &ctxt) |
Ciphertext arithmetic | |
void | negate () |
Ctxt & | operator+= (const Ctxt &other) |
Ctxt & | operator-= (const Ctxt &other) |
void | addCtxt (const Ctxt &other, bool negative=false) |
void | multLowLvl (const Ctxt &other, bool destructive=false) |
Ctxt & | operator*= (const Ctxt &other) |
void | automorph (long k) |
Ctxt & | operator>>= (long k) |
void | complexConj () |
void | smartAutomorph (long k) |
automorphism with re-linearization More... | |
void | frobeniusAutomorph (long j) |
applies the automorphism p^j using smartAutomorphism More... | |
Ctxt & | operator*= (const NTL::ZZX &poly) |
Times equals operator with a ZZX . More... | |
void | addConstant (const DoubleCRT &dcrt, double size=-1.0) |
void | addConstant (const NTL::ZZX &poly, double size=-1.0) |
template<typename Scheme > | |
void | addConstant (const Ptxt< Scheme > &ptxt, bool neg=false) |
Add a plaintext to this Ctxt . More... | |
template<typename Scheme > | |
Ctxt & | operator+= (const Ptxt< Scheme > &ptxt) |
template<typename Scheme > | |
Ctxt & | operator-= (const Ptxt< Scheme > &ptxt) |
void | addConstantCKKS (std::pair< long, long >) |
add a rational number in the form a/b, a,b are long More... | |
void | addConstantCKKS (double x) |
void | addConstantCKKS (const DoubleCRT &dcrt, NTL::xdouble size=NTL::xdouble(-1.0), NTL::xdouble factor=NTL::xdouble(-1.0)) |
void | addConstantCKKS (const NTL::ZZX &poly, NTL::xdouble size=NTL::xdouble(-1.0), NTL::xdouble factor=NTL::xdouble(-1.0)) |
void | addConstantCKKS (const std::vector< std::complex< double >> &ptxt) |
void | addConstantCKKS (const Ptxt< CKKS > &ptxt) |
Add a CKKS plaintext to this Ctxt . More... | |
void | addConstantCKKS (const NTL::ZZ &c) |
void | multByConstant (const DoubleCRT &dcrt, double size=-1.0) |
void | multByConstant (const NTL::ZZX &poly, double size=-1.0) |
void | multByConstant (const zzX &poly, double size=-1.0) |
void | multByConstant (const PtxtArray &ptxt) |
Multiply a Ctxt with a specified plaintext constant. More... | |
void | multByConstant (const EncodedPtxt &ptxt) |
Multiply a Ctxt with a specified plaintext constant. More... | |
void | multByConstant (const FatEncodedPtxt &ptxt) |
Multiply a Ctxt with a specified plaintext constant. More... | |
void | multByConstant (const NTL::ZZ &ptxt) |
Multiply a Ctxt with an NTL::ZZ scalar. More... | |
void | multByConstant (long ptxt) |
Multiply a Ctxt with a long scalar. More... | |
void | multByConstant (double ptxt) |
Multiply a Ctxt with a double scalar. More... | |
void | multByConstant (NTL::xdouble ptxt) |
Multiply a Ctxt with an NTL::xdouble scalar. More... | |
Ctxt & | operator*= (const PtxtArray &ptxt) |
Times equals operator with a plaintext constant. More... | |
Ctxt & | operator*= (const EncodedPtxt &ptxt) |
Times equals operator with a plaintext constant. More... | |
Ctxt & | operator*= (const FatEncodedPtxt &ptxt) |
Times equals operator with a plaintext constant. More... | |
Ctxt & | operator*= (const NTL::ZZ &ptxt) |
Times equals operator with an NTL::ZZ scalar. More... | |
Ctxt & | operator*= (long ptxt) |
Times equals operator with a long scalar. More... | |
Ctxt & | operator*= (double ptxt) |
Times equals operator with a double scalar. More... | |
Ctxt & | operator*= (NTL::xdouble ptxt) |
Times equals operator with an NTL::xdouble scalar. More... | |
void | addConstant (const PtxtArray &ptxt, bool neg=false) |
Add to a Ctxt a specified plaintext constant. More... | |
void | addConstant (const EncodedPtxt &ptxt, bool neg=false) |
Add to a Ctxt a specified plaintext constant. More... | |
void | addConstant (const FatEncodedPtxt &ptxt, bool neg=false) |
Add to a Ctxt a specified plaintext constant. More... | |
void | addConstant (const NTL::ZZ &ptxt, bool neg=false) |
Add to a Ctxt an NTL::ZZ scalar. More... | |
void | addConstant (long ptxt, bool neg=false) |
Add to a Ctxt a long scalar. More... | |
void | addConstant (double ptxt, bool neg=false) |
Add to a Ctxt a double scalar. More... | |
void | addConstant (NTL::xdouble ptxt, bool neg=false) |
Add to a Ctxt an NTL::xdouble scalar. More... | |
Ctxt & | operator+= (const PtxtArray &ptxt) |
Plus equals operator with plaintext constant. More... | |
Ctxt & | operator+= (const EncodedPtxt &ptxt) |
Plus equals operator with plaintext constant. More... | |
Ctxt & | operator+= (const FatEncodedPtxt &ptxt) |
Plus equals operator with plaintext constant. More... | |
Ctxt & | operator+= (const NTL::ZZ &ptxt) |
Plus equals operator with an NTL::ZZ scalar. More... | |
Ctxt & | operator+= (long ptxt) |
Plus equals operator with a long scalar. More... | |
Ctxt & | operator+= (double ptxt) |
Plus equals operator with a double scalar. More... | |
Ctxt & | operator+= (NTL::xdouble ptxt) |
Plus equals operator with an NTL::xdouble scalar. More... | |
Ctxt & | operator-= (const PtxtArray &ptxt) |
Minus equals operator with plaintext constant. More... | |
Ctxt & | operator-= (const EncodedPtxt &ptxt) |
Minus equals operator with plaintext constant. More... | |
Ctxt & | operator-= (const FatEncodedPtxt &ptxt) |
Minus equals operator with plaintext constant. More... | |
Ctxt & | operator-= (const NTL::ZZ &ptxt) |
Minus equals operator with an NTL::ZZ scalar. More... | |
Ctxt & | operator-= (long ptxt) |
Minus equals operator with a long scalar. More... | |
Ctxt & | operator-= (double ptxt) |
Minus equals operator with a double scalar. More... | |
Ctxt & | operator-= (NTL::xdouble ptxt) |
Minus equals operator with an NTL::xdouble scalar. More... | |
template<typename Scheme > | |
void | multByConstant (const Ptxt< Scheme > &ptxt) |
Multiply a plaintext to this Ctxt . More... | |
template<typename Scheme > | |
Ctxt & | operator*= (const Ptxt< Scheme > &ptxt) |
void | multByConstantCKKS (double x) |
multiply by a rational number or floating point More... | |
void | multByConstantCKKS (std::pair< long, long > num) |
void | multByConstantCKKS (const DoubleCRT &dcrt, NTL::xdouble size=NTL::xdouble(-1.0), NTL::xdouble factor=NTL::xdouble(-1.0), double roundingErr=-1.0) |
void | multByConstantCKKS (const NTL::ZZX &poly, NTL::xdouble size=NTL::xdouble(-1.0), NTL::xdouble factor=NTL::xdouble(-1.0), double roundingErr=-1.0) |
void | multByConstantCKKS (const Ptxt< CKKS > &ptxt) |
Multiply a CKKS plaintext to this Ctxt . More... | |
void | multByConstantCKKS (const std::vector< std::complex< double >> &ptxt) |
void | xorConstant (const DoubleCRT &poly, UNUSED double size=-1.0) |
void | xorConstant (const NTL::ZZX &poly, double size=-1.0) |
void | nxorConstant (const DoubleCRT &poly, UNUSED double size=-1.0) |
void | nxorConstant (const NTL::ZZX &poly, double size=-1.0) |
void | divideByP () |
void | multByP (long e=1) |
void | divideBy2 () |
void | extractBits (std::vector< Ctxt > &bits, long nBits2extract=0) |
void | multiplyBy (const Ctxt &other) |
void | multiplyBy2 (const Ctxt &other1, const Ctxt &other2) |
void | square () |
void | cube () |
void | power (long e) |
raise ciphertext to some power More... | |
Detailed Description
A Ctxt object holds a single ciphertext.
The class Ctxt includes a std::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 std::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 a high-probability bound on the noise magnitude (kept in the noiseBound data member). The noise bound is a bound on the l-infinity norm of the canonical embedding of the noise polynomial, namely its evaluation in roots of the ring polynomial (which are the complex primitive roots of unity). The noise bound 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.
Constructor & Destructor Documentation
◆ Ctxt() [1/3]
|
default |
◆ Ctxt() [2/3]
|
explicit |
◆ Ctxt() [3/3]
helib::Ctxt::Ctxt | ( | ZeroCtxtLike_type | , |
const Ctxt & | ctxt | ||
) |
Member Function Documentation
◆ addConstant() [1/10]
void helib::Ctxt::addConstant | ( | const DoubleCRT & | dcrt, |
double | size = -1.0 |
||
) |
Add a constant polynomial. If provided, size should be a high-probability bound on the L-infty norm of the canonical embedding Otherwise, for the DoubleCRT variant, a bound based on the assumption that the coefficients are uniformly and independently distributed over [-ptxtSpace/2, ptxtSpace/2]. For the other variants, explicit bounds are computed (if not CKKS).
◆ addConstant() [2/10]
void helib::Ctxt::addConstant | ( | const EncodedPtxt & | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
a specified plaintext constant.
- Parameters
-
ptxt The constant to add as an EncodedPtxt
object.neg Flag to specify if the constant is negative. Default is false
.
- Note
EncodedPtxt
is a plaintext object containingNTL::ZZX
data.
◆ addConstant() [3/10]
void helib::Ctxt::addConstant | ( | const FatEncodedPtxt & | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
a specified plaintext constant.
- Parameters
-
ptxt The constant to add as a FatEncodedPtxt
object.neg Flag to specify if the constant is negative. Default is false
.
- Note
FatEncodedPtxt
is a plaintext object containinghelib::DoubleCRT
data.
◆ addConstant() [4/10]
void helib::Ctxt::addConstant | ( | const NTL::ZZ & | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
an NTL::ZZ
scalar.
- Parameters
-
ptxt The scalar to add. neg Flag to specify if the constant is negative. Default is false
.
◆ addConstant() [5/10]
void helib::Ctxt::addConstant | ( | const NTL::ZZX & | poly, |
double | size = -1.0 |
||
) |
◆ addConstant() [6/10]
|
inline |
◆ addConstant() [7/10]
void helib::Ctxt::addConstant | ( | const PtxtArray & | ptxt, |
bool | neg = false |
||
) |
◆ addConstant() [8/10]
void helib::Ctxt::addConstant | ( | double | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
a double
scalar.
- Parameters
-
ptxt The scalar to add. neg Flag to specify if the constant is negative. Default is false
.
◆ addConstant() [9/10]
void helib::Ctxt::addConstant | ( | long | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
a long
scalar.
- Parameters
-
ptxt The scalar to add. neg Flag to specify if the constant is negative. Default is false
.
◆ addConstant() [10/10]
void helib::Ctxt::addConstant | ( | NTL::xdouble | ptxt, |
bool | neg = false |
||
) |
Add to a Ctxt
an NTL::xdouble
scalar.
- Parameters
-
ptxt The scalar to add. neg Flag to specify if the constant is negative. Default is false
.
◆ addConstantCKKS() [1/7]
void helib::Ctxt::addConstantCKKS | ( | const DoubleCRT & | dcrt, |
NTL::xdouble | size = NTL::xdouble(-1.0) , |
||
NTL::xdouble | factor = NTL::xdouble(-1.0) |
||
) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(const FatEncodedPtxt& ptxt)
instead.
◆ addConstantCKKS() [2/7]
void helib::Ctxt::addConstantCKKS | ( | const NTL::ZZ & | c | ) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(const NTL::ZZ& ptxt)
instead.
◆ addConstantCKKS() [3/7]
void helib::Ctxt::addConstantCKKS | ( | const NTL::ZZX & | poly, |
NTL::xdouble | size = NTL::xdouble(-1.0) , |
||
NTL::xdouble | factor = NTL::xdouble(-1.0) |
||
) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(const EncodedPtxt& ptxt)
instead.
◆ addConstantCKKS() [4/7]
Add a CKKS
plaintext to this Ctxt
.
- Parameters
-
ptxt Plaintext Ptxt
object with which to add.
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(const PtxtArray& ptxt)
instead.
◆ addConstantCKKS() [5/7]
void helib::Ctxt::addConstantCKKS | ( | const std::vector< std::complex< double >> & | ptxt | ) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(const PtxtArray& ptxt)
instead.
◆ addConstantCKKS() [6/7]
|
inline |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(double ptxt)
instead.
◆ addConstantCKKS() [7/7]
void helib::Ctxt::addConstantCKKS | ( | std::pair< long, long > | num | ) |
add a rational number in the form a/b, a,b are long
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator+=(double ptxt)
instead.
◆ addCtxt()
void helib::Ctxt::addCtxt | ( | const Ctxt & | other, |
bool | negative = false |
||
) |
◆ addedNoiseForCKKSDecryption()
void helib::Ctxt::addedNoiseForCKKSDecryption | ( | const SecKey & | sk, |
double | eps, | ||
NTL::ZZX & | noise | ||
) | const |
◆ automorph()
void helib::Ctxt::automorph | ( | long | k | ) |
◆ bitCapacity()
|
inline |
the capacity in bits, returned as an integer
◆ blindCtxt()
void helib::Ctxt::blindCtxt | ( | const NTL::ZZX & | poly | ) |
Add a high-noise encryption of the given constant.
◆ bringToSet()
void helib::Ctxt::bringToSet | ( | const IndexSet & | s | ) |
make the primeSet equal to newPrimeSet, via modUpToSet and modDownToSet
◆ bumpNoiseBound()
|
inline |
◆ capacity()
|
inline |
returns the "capacity" of a ciphertext, which is the log2 of the ratio of the modulus to the total noise bound
◆ cleanUp()
Ctxt & helib::Ctxt::cleanUp | ( | ) |
◆ clear()
|
inline |
◆ complexConj()
void helib::Ctxt::complexConj | ( | ) |
◆ cube()
|
inline |
◆ divideBy2()
void helib::Ctxt::divideBy2 | ( | ) |
◆ divideByP()
void helib::Ctxt::divideByP | ( | ) |
Divide a ciphertext by p, for plaintext space p^r, r>1. It is assumed that the ciphertext encrypts a polynomial which is zero mod p. If this is not the case then the result will not be a valid ciphertext anymore. As a side-effect, the plaintext space is reduced from p^r to p^{r-1}.
◆ dropSmallAndSpecialPrimes()
void helib::Ctxt::dropSmallAndSpecialPrimes | ( | ) |
the corresponding primeSet
drop all smallPrimes and specialPrimes, adding ctxtPrimes as necessary to ensure that the scaled noise is above the modulus-switching added noise term.
◆ DummyEncrypt()
void helib::Ctxt::DummyEncrypt | ( | const NTL::ZZX & | ptxt, |
double | size = -1.0 |
||
) |
Dummy encryption, just encodes the plaintext in a Ctxt object If provided, size should be a high-probability bound on the L-infty norm of the canonical embedding
◆ effectiveR()
|
inline |
◆ equalizeRationalFactors()
◆ equalsTo()
bool helib::Ctxt::equalsTo | ( | const Ctxt & | other, |
bool | comparePkeys = true |
||
) | const |
◆ errorBound()
|
inline |
◆ evalPoly()
void helib::Ctxt::evalPoly | ( | const NTL::ZZX & | poly | ) |
compute the power X,X^2,...,X^n
Evaluate the cleartext poly on the encrypted ciphertext
◆ extractBits()
|
inline |
◆ frobeniusAutomorph()
void helib::Ctxt::frobeniusAutomorph | ( | long | j | ) |
applies the automorphism p^j using smartAutomorphism
◆ getContext()
|
inline |
◆ getKeyID()
long helib::Ctxt::getKeyID | ( | ) | const |
◆ getNoiseBound()
|
inline |
◆ getPrimeSet()
|
inline |
◆ getPtxtMag()
|
inline |
◆ getPtxtSpace()
|
inline |
◆ getPubKey()
|
inline |
◆ getRatFactor()
|
inline |
◆ hackPtxtSpace()
|
inline |
◆ inCanonicalForm()
|
inline |
A canonical ciphertext has (at most) handles pointing to (1,s)
◆ isCKKS()
|
inline |
◆ isCorrect()
bool helib::Ctxt::isCorrect | ( | ) | const |
Would this ciphertext be decrypted without errors?
◆ isEmpty()
|
inline |
Is this an empty ciphertext without any parts.
◆ log_of_ratio()
|
inline |
Returns log(noiseBound) - log(q)
- Deprecated:
- This is deprecated. Please use
Ctxt::capacity()
instead.
◆ logOfPrimeSet()
|
inline |
returns the log of the prime set
◆ modDownToSet()
void helib::Ctxt::modDownToSet | ( | const IndexSet & | s | ) |
Modulus-switching down (to a smaller modulus). mod-switch down to primeSet \intersect s, after this call we have primeSet<=s. s must contain either all special primes or none of them.
◆ modSwitchAddedNoiseBound()
NTL::xdouble helib::Ctxt::modSwitchAddedNoiseBound | ( | ) | const |
Estimate the added noise.
◆ modUpToSet()
void helib::Ctxt::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.
◆ multByConstant() [1/11]
void helib::Ctxt::multByConstant | ( | const DoubleCRT & | dcrt, |
double | size = -1.0 |
||
) |
Multiply-by-constant. If the size is not given, for the DCRT variant, we use a high probability bound assuming "random" coefficients mod ptxtSpace, while for the other variants, we use explicitly computed bounds (if not CKKS).
◆ multByConstant() [2/11]
void helib::Ctxt::multByConstant | ( | const EncodedPtxt & | ptxt | ) |
Multiply a Ctxt
with a specified plaintext constant.
- Parameters
-
ptxt The constant to multiply as an EncodedPtxt
object.
- Note
EncodedPtxt
is a plaintext object containingNTL::ZZX
data.
◆ multByConstant() [3/11]
void helib::Ctxt::multByConstant | ( | const FatEncodedPtxt & | ptxt | ) |
Multiply a Ctxt
with a specified plaintext constant.
- Parameters
-
ptxt The constant to multiply as a FatEncodedPtxt
object.
- Note
FatEncodedPtxt
is a plaintext object containinghelib::DoubleCRT
data.
◆ multByConstant() [4/11]
void helib::Ctxt::multByConstant | ( | const NTL::ZZ & | ptxt | ) |
Multiply a Ctxt
with an NTL::ZZ
scalar.
- Parameters
-
ptxt Scalar to multiply.
◆ multByConstant() [5/11]
void helib::Ctxt::multByConstant | ( | const NTL::ZZX & | poly, |
double | size = -1.0 |
||
) |
◆ multByConstant() [6/11]
|
inline |
◆ multByConstant() [7/11]
void helib::Ctxt::multByConstant | ( | const PtxtArray & | ptxt | ) |
◆ multByConstant() [8/11]
void helib::Ctxt::multByConstant | ( | const zzX & | poly, |
double | size = -1.0 |
||
) |
◆ multByConstant() [9/11]
void helib::Ctxt::multByConstant | ( | double | ptxt | ) |
Multiply a Ctxt
with a double
scalar.
- Parameters
-
ptxt Scalar to multiply.
◆ multByConstant() [10/11]
void helib::Ctxt::multByConstant | ( | long | ptxt | ) |
Multiply a Ctxt
with a long
scalar.
- Parameters
-
ptxt Scalar to multiply.
◆ multByConstant() [11/11]
void helib::Ctxt::multByConstant | ( | NTL::xdouble | ptxt | ) |
Multiply a Ctxt
with an NTL::xdouble
scalar.
- Parameters
-
ptxt Scalar to multiply.
◆ multByConstantCKKS() [1/6]
void helib::Ctxt::multByConstantCKKS | ( | const DoubleCRT & | dcrt, |
NTL::xdouble | size = NTL::xdouble(-1.0) , |
||
NTL::xdouble | factor = NTL::xdouble(-1.0) , |
||
double | roundingErr = -1.0 |
||
) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(const FatEncodedPtxt& ptxt)
instead.
◆ multByConstantCKKS() [2/6]
|
inline |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(const EncodedPtxt& ptxt)
instead.
◆ multByConstantCKKS() [3/6]
Multiply a CKKS
plaintext to this Ctxt
.
- Parameters
-
ptxt Plaintext Ptxt
object polynomial with which to multiply.
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(const PtxtArray& ptxt)
instead.
◆ multByConstantCKKS() [4/6]
void helib::Ctxt::multByConstantCKKS | ( | const std::vector< std::complex< double >> & | ptxt | ) |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(const PtxtArray& ptxt)
instead.
◆ multByConstantCKKS() [5/6]
|
inline |
multiply by a rational number or floating point
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(double ptxt)
instead.
◆ multByConstantCKKS() [6/6]
|
inline |
- Deprecated:
- This function is deprecated in favor of a newer API. Please use
Ctxt::operator*=(double ptxt)
instead.
◆ multByP()
|
inline |
Multiply ciphertext by p^e, for plaintext space p^r. This also has the side-effect of increasing the plaintext space to p^{r+e}.
◆ multiplyBy()
void helib::Ctxt::multiplyBy | ( | const Ctxt & | other | ) |
◆ multiplyBy2()
◆ multLowLvl()
void helib::Ctxt::multLowLvl | ( | const Ctxt & | other, |
bool | destructive = false |
||
) |
◆ naturalPrimeSet()
IndexSet helib::Ctxt::naturalPrimeSet | ( | ) | const |
"natural size" is size before squaring
◆ naturalSize()
double helib::Ctxt::naturalSize | ( | ) | const |
◆ negate()
void helib::Ctxt::negate | ( | ) |
◆ nxorConstant() [1/2]
|
inline |
◆ nxorConstant() [2/2]
|
inline |
◆ operator!=()
|
inline |
◆ operator*=() [1/10]
◆ operator*=() [2/10]
|
inline |
Times equals operator with a plaintext constant.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
- Note
EncodedPtxt
is a plaintext object containingNTL::ZZX
data.
◆ operator*=() [3/10]
|
inline |
Times equals operator with a plaintext constant.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
- Note
FatEncodedPtxt
is a plaintext object containinghelib::DoubleCRT
data.
◆ operator*=() [4/10]
|
inline |
Times equals operator with an NTL::ZZ
scalar.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
◆ operator*=() [5/10]
Ctxt & helib::Ctxt::operator*= | ( | const NTL::ZZX & | poly | ) |
Times equals operator with a ZZX
.
- Parameters
-
poly Element by which to multiply.
- Returns
- Reference to
*this
post multiplication.
- Deprecated:
- This function is deprecated in favor of a new
EncodedPtxt
-based API.
Please useCtxt::operator*=(const EncodedPtxt& ptxt)
instead.
◆ operator*=() [6/10]
◆ operator*=() [7/10]
Times equals operator with a plaintext constant.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
◆ operator*=() [8/10]
|
inline |
Times equals operator with a double
scalar.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
◆ operator*=() [9/10]
|
inline |
Times equals operator with a long
scalar.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
◆ operator*=() [10/10]
|
inline |
Times equals operator with an NTL::xdouble
scalar.
- Parameters
-
ptxt Right hand side of multiplication.
- Returns
- Reference to
*this
post multiplication.
◆ operator+=() [1/9]
◆ operator+=() [2/9]
|
inline |
Plus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
- Note
EncodedPtxt
is a plaintext object containingNTL::ZZX
data.
◆ operator+=() [3/9]
|
inline |
Plus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
- Note
FatEncodedPtxt
is a plaintext object containinghelib::DoubleCRT
data.
◆ operator+=() [4/9]
|
inline |
Plus equals operator with an NTL::ZZ
scalar.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
◆ operator+=() [5/9]
◆ operator+=() [6/9]
Plus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
◆ operator+=() [7/9]
|
inline |
Plus equals operator with a double
scalar.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
◆ operator+=() [8/9]
|
inline |
Plus equals operator with a long
scalar.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
◆ operator+=() [9/9]
|
inline |
Plus equals operator with an NTL::xdouble
scalar.
- Parameters
-
ptxt Right hand side of addition.
- Returns
- Reference to
*this
post addition.
◆ operator-=() [1/9]
◆ operator-=() [2/9]
|
inline |
Minus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
- Note
EncodedPtxt
is a plaintext object containingNTL::ZZX
data.
◆ operator-=() [3/9]
|
inline |
Minus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
- Note
FatEncodedPtxt
is a plaintext object containinghelib::DoubleCRT
data.
◆ operator-=() [4/9]
|
inline |
Minus equals operator with an NTL::ZZ
scalar.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
◆ operator-=() [5/9]
◆ operator-=() [6/9]
Minus equals operator with plaintext constant.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
◆ operator-=() [7/9]
|
inline |
Minus equals operator with a double
scalar.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
◆ operator-=() [8/9]
|
inline |
Minus equals operator with a long
scalar.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
◆ operator-=() [9/9]
|
inline |
Minus equals operator with an NTL::xdouble
scalar.
- Parameters
-
ptxt Right hand side of subtraction.
- Returns
- Reference to
*this
post subtraction.
◆ operator=()
◆ operator==()
|
inline |
◆ operator>>=()
|
inline |
◆ power()
void helib::Ctxt::power | ( | long | e | ) |
raise ciphertext to some power
◆ rawModSwitch()
double helib::Ctxt::rawModSwitch | ( | std::vector< NTL::ZZX > & | zzParts, |
long | toModulus | ||
) | const |
Special-purpose modulus-switching for bootstrapping.
Mod-switch to an externally-supplied modulus. The modulus need not be in the moduli-chain in the context, and does not even need to be a prime. The ciphertext *this is not affected, instead the result is returned in the zzParts std::vector, as a std::vector of ZZX'es. Returns an estimate for the scaled noise (not including the additive mod switching noise)
◆ read()
void helib::Ctxt::read | ( | std::istream & | str | ) |
In-place read from the stream the serialized Ctxt
object in binary format.
- Parameters
-
str Input std::istream
.
◆ readFrom()
◆ readFromJSON() [1/2]
|
static |
Read from the JsonWrapper
the serialized ciphertext (Ctxt
) object.
- Parameters
-
j The JsonWrapper
containing the serializedCtxt
object.pubKey The PubKey
to be used.
- Returns
- The deserialized
Ctxt
object.
◆ readFromJSON() [2/2]
◆ readJSON() [1/2]
void helib::Ctxt::readJSON | ( | const JsonWrapper & | j | ) |
In-place read from the JsonWrapper
the serialized ciphertext (Ctxt
) object.
- Parameters
-
j The JsonWrapper
containing the serializedCtxt
object.
◆ readJSON() [2/2]
void helib::Ctxt::readJSON | ( | std::istream & | str | ) |
In-place read from the str
std::istream
the serialized ciphertext (Ctxt
) object.
- Parameters
-
j The JsonWrapper
containing the serializedCtxt
object.
◆ reducePtxtSpace()
void helib::Ctxt::reducePtxtSpace | ( | long | newPtxtSpace | ) |
Reduce plaintext space to a divisor of the original plaintext space.
◆ relin_CKKS_adjust()
void helib::Ctxt::relin_CKKS_adjust | ( | ) |
◆ reLinearize()
void helib::Ctxt::reLinearize | ( | long | keyIdx = 0 | ) |
◆ setPtxtMag()
|
inline |
◆ smartAutomorph()
void helib::Ctxt::smartAutomorph | ( | long | k | ) |
automorphism with re-linearization
◆ square()
|
inline |
◆ totalNoiseBound()
|
inline |
returns the total noise bound, which for CKKS is ptxtMag*ratFactor + noiseBound
◆ writeTo()
void helib::Ctxt::writeTo | ( | std::ostream & | str | ) | const |
Write out the Ctxt
object in binary format.
- Parameters
-
str Output std::ostream
.
◆ writeToJSON() [1/2]
JsonWrapper helib::Ctxt::writeToJSON | ( | ) | const |
Write out the ciphertext (Ctxt
) object to a JsonWrapper
.
- Returns
- The
JsonWrapper
.
◆ writeToJSON() [2/2]
void helib::Ctxt::writeToJSON | ( | std::ostream & | str | ) | const |
Write out the ciphertext (Ctxt
) object to the output stream using JSON format.
- Parameters
-
str Output std::ostream
.
◆ xorConstant() [1/2]
|
inline |
Convenience method: XOR and nXOR with arbitrary plaintext space: a xor b = a+b-2ab = a + (1-2a)*b, a nxor b = 1-a-b+2ab = (b-1)(2a-1)+a
◆ xorConstant() [2/2]
|
inline |
Friends And Related Function Documentation
◆ BasicAutomorphPrecon
|
friend |
◆ operator<<
|
friend |
◆ operator>>
|
friend |
◆ PubKey
|
friend |
◆ SecKey
|
friend |
Member Data Documentation
◆ typeName
|
staticconstexpr |
Class label to be added to JSON serialization as object type information.