One entry in a ciphertext std::vector. More...

#include <Ctxt.h>

Inheritance diagram for helib::CtxtPart:
helib::DoubleCRT

Public Member Functions

bool operator== (const CtxtPart &other) const
 
bool operator!= (const CtxtPart &other) const
 
 CtxtPart (const Context &_context, const IndexSet &s)
 
 CtxtPart (const Context &_context, const IndexSet &s, const SKHandle &otherHandle)
 
 CtxtPart (const DoubleCRT &other)
 
 CtxtPart (const DoubleCRT &other, const SKHandle &otherHandle)
 
void writeTo (std::ostream &str) const
 Write out the CtxtPart object in binary format. More...
 
void read (std::istream &str)
 In-place read from the stream the serialized CtxtPart object in binary format. More...
 
void writeToJSON (std::ostream &str) const
 Write out the ciphertext part (CtxtPart) object to the output stream using JSON format. More...
 
JsonWrapper writeToJSON () const
 Write out the ciphertext part (CtxtPart) object to a JsonWrapper. More...
 
void readJSON (std::istream &str)
 Read from the stream the serialized ciphertext part (CtxtPart) object using JSON format. More...
 
void readJSON (const JsonWrapper &j)
 Read from the JsonWrapper the serialized ciphertext part (CtxtPart) object. More...
 
- Public Member Functions inherited from helib::DoubleCRT
 DoubleCRT (const DoubleCRT &other)=default
 
 DoubleCRT (const NTL::ZZX &poly, const Context &_context, const IndexSet &indexSet)
 Initializing DoubleCRT from a ZZX polynomial. More...
 
 DoubleCRT (const zzX &poly, const Context &_context, const IndexSet &indexSet)
 Same as above, but with zzX's. More...
 
 DoubleCRT (const Context &_context, const IndexSet &indexSet)
 Also specify the IndexSet explicitly. More...
 
DoubleCRToperator= (const DoubleCRT &other)
 
DoubleCRToperator= (const zzX &poly)
 
DoubleCRToperator= (const NTL::ZZX &poly)
 
DoubleCRToperator= (const NTL::ZZ &num)
 
DoubleCRToperator= (const long num)
 
 DoubleCRT (const NTL::ZZ &num, const Context &context, const IndexSet &indexSet)
 
 DoubleCRT (long num, const Context &context, const IndexSet &indexSet)
 
long getOneRow (NTL::Vec< long > &row, long idx, bool positive=false) const
 Get one row of a polynomial. More...
 
long getOneRow (NTL::zz_pX &row, long idx) const
 
void toPoly (NTL::ZZX &p, const IndexSet &s, bool positive=false) const
 Recovering the polynomial in coefficient representation. This yields an integer polynomial with coefficients in [-P/2,P/2], unless the positive flag is set to true, in which case we get coefficients in [0,P-1] (P is the product of all moduli used). Using the optional IndexSet param we compute the polynomial reduced modulo the product of only the primes in that set. More...
 
void toPoly (NTL::ZZX &p, bool positive=false) const
 
bool operator== (const DoubleCRT &other) const
 
bool operator!= (const DoubleCRT &other) const
 
DoubleCRTSetZero ()
 
DoubleCRTSetOne ()
 
NTL::xdouble breakIntoDigits (std::vector< DoubleCRT > &dgts) const
 Break into n digits,according to the primeSets in context.digits. See Section 3.1.6 of the design document (re-linearization) Returns the sum of the canonical embedding of the digits. More...
 
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. If poly_p != 0, then *poly_p will first be set to the result of applying toPoly. More...
 
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, returns log(product). More...
 
void removePrimes (const IndexSet &s1)
 Remove s1 from the index set. More...
 
void setPrimes (const IndexSet &s1)
 @ brief make prime set equal to s1 More...
 
const ContextgetContext () const
 
const IndexMap< NTL::vec_long > & getMap () const
 
const IndexSetgetIndexSet () const
 
void randomize (const NTL::ZZ *seed=nullptr)
 Fills each row i with random ints mod pi, uses NTL's PRG. More...
 
double sampleSmall ()
 Coefficients are -1/0/1, Prob[0]=1/2. More...
 
double sampleSmallBounded ()
 
double sampleHWt (long Hwt)
 Coefficients are -1/0/1 with pre-specified number of nonzeros. More...
 
double sampleHWtBounded (long Hwt)
 
double sampleGaussian (double stdev=0.0)
 Coefficients are Gaussians Return a high probability bound on L-infty norm of canonical embedding. More...
 
double sampleGaussianBounded (double stdev=0.0)
 
NTL::xdouble sampleGaussianBounded (NTL::xdouble stdev)
 
double sampleUniform (long B)
 Coefficients are uniform in [-B..B]. More...
 
NTL::xdouble sampleUniform (const NTL::ZZ &B)
 
void scaleDownToSet (const IndexSet &s, long ptxtSpace, NTL::ZZX &delta)
 
void FFT (const NTL::ZZX &poly, const IndexSet &s)
 
void FFT (const zzX &poly, const IndexSet &s)
 
void reduce () const
 
void writeTo (std::ostream &str) const
 Write out the DoubleCRT object in binary format. More...
 
void read (std::istream &str)
 In-place read from the stream the serialized DoubleCRT 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...
 
DoubleCRTNegate (const DoubleCRT &other)
 
DoubleCRTNegate ()
 
DoubleCRToperator+= (const DoubleCRT &other)
 
DoubleCRToperator+= (const NTL::ZZX &poly)
 
DoubleCRToperator+= (const NTL::ZZ &num)
 
DoubleCRToperator+= (long num)
 
DoubleCRToperator-= (const DoubleCRT &other)
 
DoubleCRToperator-= (const NTL::ZZX &poly)
 
DoubleCRToperator-= (const NTL::ZZ &num)
 
DoubleCRToperator-= (long num)
 
DoubleCRToperator++ ()
 
DoubleCRToperator-- ()
 
void operator++ (int)
 
void operator-- (int)
 
DoubleCRToperator*= (const DoubleCRT &other)
 
DoubleCRToperator*= (const NTL::ZZX &poly)
 
DoubleCRToperator*= (const NTL::ZZ &num)
 
DoubleCRToperator*= (long num)
 
void Add (const DoubleCRT &other, bool matchIndexSets=true)
 
void Sub (const DoubleCRT &other, bool matchIndexSets=true)
 
void Mul (const DoubleCRT &other, bool matchIndexSets=true)
 
DoubleCRToperator/= (const NTL::ZZ &num)
 
DoubleCRToperator/= (long num)
 
void Exp (long k)
 Small-exponent polynomial exponentiation. More...
 
void automorph (long k)
 Apply the automorphism F(X) --> F(X^k) (with gcd(k,m)=1) More...
 
DoubleCRToperator>>= (long k)
 
void complexConj ()
 Compute the complex conjugate, the same as automorph(m-1) More...
 

Static Public Member Functions

static CtxtPart readFrom (std::istream &str, const Context &context)
 Read from the stream the serialized CtxtPart object in binary format. More...
 
static CtxtPart readFromJSON (std::istream &str, const Context &context)
 Read from the stream the serialized ciphertext part (CtxtPart) object using JSON format. More...
 
static CtxtPart readFromJSON (const JsonWrapper &j, const Context &context)
 Read from the JsonWrapper the serialized ciphertext part (CtxtPart) object. More...
 
- Static Public Member Functions inherited from helib::DoubleCRT
static DoubleCRT readFrom (std::istream &str, const Context &context)
 Read from the stream the serialized DoubleCRT object in binary format. More...
 
static DoubleCRT readFromJSON (std::istream &str, const Context &context)
 Read from the stream the serialized ciphertext (Ctxt) object using JSON format. More...
 
static DoubleCRT readFromJSON (const JsonWrapper &j, const Context &context)
 Read from the JsonWrapper the serialized ciphertext (Ctxt) object. More...
 

Public Attributes

SKHandle skHandle
 The handle is a public data member. More...
 

Detailed Description

One entry in a ciphertext std::vector.

A ciphertext part consists of a polynomial (element of the ring R_Q) and a handle to the corresponding secret-key polynomial.

Constructor & Destructor Documentation

◆ CtxtPart() [1/4]

helib::CtxtPart::CtxtPart ( const Context _context,
const IndexSet s 
)
inline

◆ CtxtPart() [2/4]

helib::CtxtPart::CtxtPart ( const Context _context,
const IndexSet s,
const SKHandle otherHandle 
)
inline

◆ CtxtPart() [3/4]

helib::CtxtPart::CtxtPart ( const DoubleCRT other)
inlineexplicit

◆ CtxtPart() [4/4]

helib::CtxtPart::CtxtPart ( const DoubleCRT other,
const SKHandle otherHandle 
)
inline

Member Function Documentation

◆ operator!=()

bool helib::CtxtPart::operator!= ( const CtxtPart other) const
inline

◆ operator==()

bool helib::CtxtPart::operator== ( const CtxtPart other) const

◆ read()

void helib::CtxtPart::read ( std::istream &  str)

In-place read from the stream the serialized CtxtPart object in binary format.

Parameters
strInput std::istream.

◆ readFrom()

CtxtPart helib::CtxtPart::readFrom ( std::istream &  str,
const Context context 
)
static

Read from the stream the serialized CtxtPart object in binary format.

Parameters
strInput std::istream.
Returns
The deserialized CtxtPart object.

◆ readFromJSON() [1/2]

CtxtPart helib::CtxtPart::readFromJSON ( const JsonWrapper j,
const Context context 
)
static

Read from the JsonWrapper the serialized ciphertext part (CtxtPart) object.

Parameters
jThe JsonWrapper containing the serialized CtxtPart object.
contextThe Context to be used.
Returns
The deserialized CtxtPart object.

◆ readFromJSON() [2/2]

CtxtPart helib::CtxtPart::readFromJSON ( std::istream &  str,
const Context context 
)
static

Read from the stream the serialized ciphertext part (CtxtPart) object using JSON format.

Parameters
strInput std::istream.
contextThe Context to be used.
Returns
The deserialized CtxtPart object.

◆ readJSON() [1/2]

void helib::CtxtPart::readJSON ( const JsonWrapper j)

Read from the JsonWrapper the serialized ciphertext part (CtxtPart) object.

Parameters
jThe JsonWrapper containing the serialized SKHandle object.

◆ readJSON() [2/2]

void helib::CtxtPart::readJSON ( std::istream &  str)

Read from the stream the serialized ciphertext part (CtxtPart) object using JSON format.

Parameters
strInput std::istream.

◆ writeTo()

void helib::CtxtPart::writeTo ( std::ostream &  str) const

Write out the CtxtPart object in binary format.

Parameters
strOutput std::ostream.

◆ writeToJSON() [1/2]

JsonWrapper helib::CtxtPart::writeToJSON ( ) const

Write out the ciphertext part (CtxtPart) object to a JsonWrapper.

Returns
The JsonWrapper.

◆ writeToJSON() [2/2]

void helib::CtxtPart::writeToJSON ( std::ostream &  str) const

Write out the ciphertext part (CtxtPart) object to the output stream using JSON format.

Parameters
strOutput std::ostream.

Member Data Documentation

◆ skHandle

SKHandle helib::CtxtPart::skHandle

The handle is a public data member.