Class PlaintextFactory

Page Contents

Class Documentation

class lbcrypto::PlaintextFactory

Static factory that creates plaintexts of a given encoding type (coefficient-packed, packed, string or CKKS packed) over given element and encoding parameters.

Public Static 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>
static inline Plaintext MakePlaintext(PlaintextEncodings encoding, std::shared_ptr<T> vp, EncodingParams ep, SCHEME schemeID = SCHEME::INVALID_SCHEME, CKKSDataType cdt = REAL)

Creates an empty plaintext of the given encoding type.

Parameters
  • encoding – the encoding type

  • vp – element parameters of the polynomial (Poly, NativePoly or DCRTPoly parameters)

  • ep – encoding parameters

  • schemeID – scheme the plaintext is created for (used by the coefficient-packed encoding)

  • cdt – CKKS data type (used by the CKKS packed encoding)

Returns

the plaintext

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>
static inline Plaintext MakePlaintext(const std::vector<int64_t> &value, PlaintextEncodings encoding, std::shared_ptr<T> vp, EncodingParams ep, SCHEME schemeID = SCHEME::INVALID_SCHEME, size_t noiseScaleDeg = 1, uint32_t level = 0, NativeInteger scalingFactor = 1)

Creates and encodes a plaintext from an integer vector (packed or coefficient-packed encoding). The vector may hold at most ringDim values (ringDim/2 for CKKS).

Parameters
  • value – the integer values to encode

  • encoding – the encoding type

  • vp – element parameters of the polynomial (Poly, NativePoly or DCRTPoly parameters)

  • ep – encoding parameters

  • schemeID – scheme the plaintext is created for

  • noiseScaleDeg – noise scale degree of the plaintext (BGV)

  • level – level of the plaintext

  • scalingFactor – integer scaling factor of the plaintext (BGV)

Returns

the encoded plaintext

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>
static inline Plaintext MakePlaintext(const std::string &value, PlaintextEncodings encoding, std::shared_ptr<T> vp, EncodingParams ep, SCHEME schemeID = SCHEME::INVALID_SCHEME, size_t noiseScaleDeg = 1, uint32_t level = 0, NativeInteger scalingFactor = 1)

Creates and encodes a plaintext from a string (string encoding). The string may hold at most ringDim characters (ringDim/2 for CKKS).

Parameters
  • value – the string to encode

  • encoding – the encoding type

  • vp – element parameters of the polynomial (Poly, NativePoly or DCRTPoly parameters)

  • ep – encoding parameters

  • schemeID – scheme the plaintext is created for

  • noiseScaleDeg – noise scale degree of the plaintext (BGV)

  • level – level of the plaintext

  • scalingFactor – integer scaling factor of the plaintext (BGV)

Returns

the encoded plaintext