Class CKKSPackedEncoding

Inheritance Relationships

Base Type

Class Documentation

class lbcrypto::CKKSPackedEncoding : public lbcrypto::PlaintextImpl

Inheritence diagram for lbcrypto::CKKSPackedEncoding:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="lbcrypto::PlaintextImpl" tooltip="lbcrypto::PlaintextImpl"]
    "1" [label="lbcrypto::CKKSPackedEncoding" tooltip="lbcrypto::CKKSPackedEncoding" fillcolor="#BFBFBF"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
}

Collaboration diagram for lbcrypto::CKKSPackedEncoding:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "12" [label="lbcrypto::ILElement< DerivedType, BigVecType >" tooltip="lbcrypto::ILElement< DerivedType, BigVecType >"]
    "9" [label="lbcrypto::BigIntegerInterface< NativeIntegerT< NativeInt > >" tooltip="lbcrypto::BigIntegerInterface< NativeIntegerT< NativeInt > >"]
    "2" [label="lbcrypto::PlaintextImpl" tooltip="lbcrypto::PlaintextImpl"]
    "8" [label="intnat::NativeIntegerT< NativeInt >" tooltip="intnat::NativeIntegerT< NativeInt >"]
    "6" [label="lbcrypto::Serializable" tooltip="lbcrypto::Serializable"]
    "10" [label="lbcrypto::DCRTPolyImpl< BigVector >" tooltip="lbcrypto::DCRTPolyImpl< BigVector >"]
    "11" [label="lbcrypto::DCRTPolyInterface< DerivedType, BigVecType, LilVecType, RNSContainerType >" tooltip="lbcrypto::DCRTPolyInterface< DerivedType, BigVecType, LilVecType, RNSContainerType >"]
    "4" [label="lbcrypto::PolyInterface< DerivedType, VecType, ContainerType >" tooltip="lbcrypto::PolyInterface< DerivedType, VecType, ContainerType >"]
    "5" [label="lbcrypto::ILElement< DerivedType, VecType >" tooltip="lbcrypto::ILElement< DerivedType, VecType >"]
    "3" [label="lbcrypto::PolyImpl< NativeVector >" tooltip="lbcrypto::PolyImpl< NativeVector >"]
    "1" [label="lbcrypto::CKKSPackedEncoding" tooltip="lbcrypto::CKKSPackedEncoding" fillcolor="#BFBFBF"]
    "7" [label="lbcrypto::PolyImpl< BigVector >" tooltip="lbcrypto::PolyImpl< BigVector >"]
    "12" -> "6" [dir=forward tooltip="public-inheritance"]
    "2" -> "3" [dir=forward tooltip="usage"]
    "2" -> "7" [dir=forward tooltip="usage"]
    "2" -> "8" [dir=forward tooltip="usage"]
    "2" -> "10" [dir=forward tooltip="usage"]
    "8" -> "9" [dir=forward tooltip="public-inheritance"]
    "10" -> "11" [dir=forward tooltip="public-inheritance"]
    "11" -> "12" [dir=forward tooltip="public-inheritance"]
    "4" -> "5" [dir=forward tooltip="public-inheritance"]
    "5" -> "6" [dir=forward tooltip="public-inheritance"]
    "3" -> "4" [dir=forward tooltip="public-inheritance"]
    "1" -> "2" [dir=forward tooltip="public-inheritance"]
    "7" -> "4" [dir=forward tooltip="public-inheritance"]
}

Type used for representing IntArray types. Provides conversion functions to encode and decode plaintext data as type vector<uint64_t>. This class uses bit packing techniques to enable efficient computing on vectors of integers. It is NOT supported for DCRTPoly.

Public Functions

template<typename T, typename std::enable_if<std::is_same<T, Poly::Params>::value || std::is_same<T, NativePoly::Params>::value || std::is_same<T, DCRTPoly::Params>::value, bool>::type = true>
inline CKKSPackedEncoding(std::shared_ptr<T> vp, EncodingParams ep, CKKSDataType ckksdt = REAL)
template<typename T, typename std::enable_if<std::is_same<T, Poly::Params>::value || std::is_same<T, NativePoly::Params>::value || std::is_same<T, DCRTPoly::Params>::value, bool>::type = true>
inline CKKSPackedEncoding(std::shared_ptr<T> vp, EncodingParams ep, const std::vector<std::complex<double>> &v, size_t nsdeg, uint32_t lvl, double scFact, uint32_t slts, CKKSDataType ckksdt = REAL)
inline explicit CKKSPackedEncoding(const std::vector<std::complex<double>> &v, uint32_t s)

Constructs a container with a copy of each of the elements in v, in the same order.

Parameters

v – - The input object to copy.

inline CKKSPackedEncoding()

Default empty constructor with empty uninitialized data elements.

inline CKKSPackedEncoding(const CKKSPackedEncoding &rhs)
inline CKKSPackedEncoding(CKKSPackedEncoding &&rhs) noexcept
virtual bool Encode() override

Encode the plaintext into a polynomial

Returns

true on success

inline virtual bool Decode() override

Decode the polynomial into the plaintext.

Returns

virtual bool Decode(size_t depth, double scalingFactor, ScalingTechnique scalTech, ExecutionMode executionMode) override
inline virtual const std::vector<std::complex<double>> &GetCKKSPackedValue() const override
inline virtual std::vector<double> GetRealPackedValue() const override
inline virtual size_t GetLength() const override

Get method to return the length of plaintext

Returns

the length of the plaintext in terms of the number of bits.

inline virtual double GetLogError() const override

Get method to return log2 of estimated standard deviation of approximation error

inline virtual double GetLogPrecision() const override

Get method to return log2 of estimated precision

inline virtual void SetLength(size_t siz) override

SetLength of the plaintext to the given size

Parameters

siz

inline virtual std::string GetFormattedValues(int64_t precision) const override

GetFormattedValues() is called by operator<< and requires a precision as an argument.

Parameters

precision – number of decimal digits of precision to print

Returns

string with all values and “estimated precision”

Public Static Functions

static inline std::vector<DCRTPoly::Integer> CRTMult(const std::vector<DCRTPoly::Integer> &a, const std::vector<DCRTPoly::Integer> &b, const std::vector<DCRTPoly::Integer> &m)

Static utility method to multiply two numbers in CRT representation. CRT representation is stored in a vector of native integers, and each position corresponds to the remainder of the number against one of the moduli in mods.

Parameters
  • a – is the first number in CRT representation.

  • b – is the second number in CRT representation.

  • m

Returns

the product of the two numbers in CRT representation.

static void Destroy()

Destructor method.

Protected Functions

inline virtual void PrintValue(std::ostream &out) const override

PrintValue() is called by operator<<.

Parameters

out

inline uint32_t GetDefaultSlotSize(uint32_t slots = 0, size_t vlen = 0)
inline virtual bool CompareTo(const PlaintextImpl &rhs) const override

Method to compare two plaintext to test for equivalence. This method does not test that the plaintext are of the same type.

Parameters

rhs – - the other plaintext to compare to.

Returns

whether the two plaintext are equivalent.

void FitToNativeVector(const std::vector<int64_t> &vec, int64_t bigBound, NativeVector *nativeVec) const

Set modulus and recalculates the vector values to fit the modulus

Parameters
  • &vec – input vector

  • &bigValue – big bound of the vector values.

  • &modulus – modulus to be set for vector.