Class PlaintextImpl

Inheritance Relationships

Derived Types

Class Documentation

class lbcrypto::PlaintextImpl

Inheritence diagram for lbcrypto::PlaintextImpl:

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

Collaboration diagram for lbcrypto::PlaintextImpl:

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

This class represents plaintext in the OpenFHE library.

PlaintextImpl is primarily intended to be used as a container and in conjunction with specific encodings which inherit from this class which depend on the application the plaintext is used with. It provides virtual methods for encoding and decoding of data.

Subclassed by lbcrypto::CKKSPackedEncoding, lbcrypto::CoefPackedEncoding, lbcrypto::PackedEncoding, lbcrypto::StringEncoding

Public Functions

inline PlaintextImpl(const std::shared_ptr<Poly::Params> &vp, EncodingParams ep, SCHEME schemeTag = SCHEME::INVALID_SCHEME, bool isEncoded = false)
inline PlaintextImpl(const std::shared_ptr<NativePoly::Params> &vp, EncodingParams ep, SCHEME schemeTag = SCHEME::INVALID_SCHEME, bool isEncoded = false)
inline PlaintextImpl(const std::shared_ptr<DCRTPoly::Params> &vp, EncodingParams ep, SCHEME schemeTag = SCHEME::INVALID_SCHEME, bool isEncoded = false)
inline PlaintextImpl(const PlaintextImpl &rhs)
inline PlaintextImpl(PlaintextImpl &&rhs)
inline virtual ~PlaintextImpl()
virtual PlaintextEncodings GetEncodingType() const = 0

GetEncodingType

Returns

Encoding type used by this plaintext

inline double GetScalingFactor() const

Get the scaling factor of the plaintext for CKKS-based plaintexts.

inline void SetScalingFactor(double sf)

Set the scaling factor of the plaintext for CKKS-based plaintexts.

inline const NativeInteger GetScalingFactorInt() const

Get the scaling factor of the plaintext for BGV-based plaintexts.

inline void SetScalingFactorInt(NativeInteger sf)

Set the scaling factor of the plaintext for BGV-based plaintexts.

inline SCHEME GetSchemeID() const

Get the encryption technique of the plaintext for BFV-based plaintexts.

inline bool IsEncoded() const

IsEncoded

Returns

true when encoding is done

inline const EncodingParams GetEncodingParams() const

GetEncodingParams

Returns

Encoding params used with this plaintext

virtual bool Encode() = 0

Encode the plaintext into a polynomial

Returns

true on success

virtual bool Decode() = 0

Decode the polynomial into the plaintext

Returns

inline int64_t LowBound() const

Calculate and return lower bound that can be encoded with the plaintext modulus the number to encode MUST be greater than this value

Returns

floor(-p/2)

inline int64_t HighBound() const

Calculate and return upper bound that can be encoded with the plaintext modulus the number to encode MUST be less than or equal to this value

Returns

floor(p/2)

inline void SetFormat(Format fmt) const

SetFormat - allows format to be changed for PlaintextImpl evaluations

Parameters

fmt

template<typename Element>
inline Element &GetElement()

GetElement

Returns

the Polynomial that the element was encoded into

template<typename Element>
inline const Element &GetElement() const
inline usint GetElementRingDimension() const

GetElementRingDimension

Returns

ring dimension on the underlying element

inline const BigInteger GetElementModulus() const

GetElementModulus

Returns

modulus on the underlying elemenbt

virtual size_t GetLength() const = 0

Get method to return the length of plaintext

Returns

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

inline virtual void SetLength(size_t newSize)

resize the plaintext; only works for plaintexts that support a resizable vector (coefpacked)

Parameters

newSize

inline size_t GetNoiseScaleDeg() const
inline void SetNoiseScaleDeg(size_t d)
inline size_t GetLevel() const
inline void SetLevel(size_t l)
inline usint GetSlots() const
inline void SetSlots(usint l)
inline virtual double GetLogError() const
inline virtual double GetLogPrecision() const
inline virtual const std::string &GetStringValue() const
inline virtual const std::vector<int64_t> &GetCoefPackedValue() const
inline virtual const std::vector<int64_t> &GetPackedValue() const
inline virtual const std::vector<std::complex<double>> &GetCKKSPackedValue() const
inline virtual const std::vector<double> GetRealPackedValue() const
inline virtual void SetStringValue(const std::string&)
inline virtual void SetIntVectorValue(const std::vector<int64_t>&)
virtual bool CompareTo(const PlaintextImpl &other) const = 0

Method to compare two plaintext to test for equivalence. This method is called by operator==

Parameters

other – - the other plaintext to compare to.

Returns

whether the two plaintext are equivalent.

inline bool operator==(const PlaintextImpl &other) const

operator== for plaintexts. This method makes sure the plaintexts are of the same type.

Parameters

other – - the other plaintext to compare to.

Returns

whether the two plaintext are the same.

inline bool operator!=(const PlaintextImpl &other) const
virtual void PrintValue(std::ostream &out) const = 0

PrintValue is called by operator<<

Parameters

out

template<>
inline const Poly &GetElement() const

GetElement

Returns

the Polynomial that the element was encoded into

template<>
inline Poly &GetElement()
template<>
inline const NativePoly &GetElement() const

GetElement

Returns

the NativePolynomial that the element was encoded into

template<>
inline NativePoly &GetElement()
template<>
inline const DCRTPoly &GetElement() const

GetElement

Returns

the DCRTPolynomial that the element was encoded into

template<>
inline DCRTPoly &GetElement()

Protected Types

enum PtxtPolyType

Values:

enumerator IsPoly
enumerator IsDCRTPoly
enumerator IsNativePoly

Protected Attributes

bool isEncoded
PtxtPolyType typeFlag
EncodingParams encodingParams
mutable Poly encodedVector
mutable NativePoly encodedNativeVector
mutable DCRTPoly encodedVectorDCRT
double scalingFactor = 1
NativeInteger scalingFactorInt = 1
size_t level = 0
size_t noiseScaleDeg = 1
usint slots = 0
SCHEME schemeID

Protected Static Attributes

static constexpr int intCTOR = 0x01
static constexpr int vecintCTOR = 0x02
static constexpr int fracCTOR = 0x04
static constexpr int vecuintCTOR = 0x08

Friends

friend std::ostream &operator<<(std::ostream &out, const PlaintextImpl &item)

operator<< for ostream integration - calls PrintValue

Parameters
  • out

  • item

Returns