Template Class CiphertextImpl

Inheritance Relationships

Base Type

Template Parameter Order

  1. class Element

Class Documentation

template<class Element>
class lbcrypto::CiphertextImpl : public lbcrypto::CryptoObject<Element>

Inheritence diagram for lbcrypto::CiphertextImpl:

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

Collaboration diagram for lbcrypto::CiphertextImpl:

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

CiphertextImpl.

The CiphertextImpl object is used to contain encrypted text in the OpenFHE library

Template Parameters

Element – a ring element.

Public Functions

CiphertextImpl() = default

Default constructor

inline explicit CiphertextImpl(const CryptoContext<Element> &cc, const std::string &id = "", PlaintextEncodings encType = INVALID_ENCODING)

Construct a new ciphertext in the given context

Parameters

cc

inline explicit CiphertextImpl(const std::shared_ptr<Key<Element>> &k)

Construct a new ciphertext from the parameters of a given public key

Parameters

k – key whose CryptoObject parameters will get cloned

CiphertextImpl(const CiphertextImpl<Element> &ct) = default

Copy constructor

inline explicit CiphertextImpl(const Ciphertext<Element> &ct)
CiphertextImpl(CiphertextImpl<Element> &&ct) noexcept = default

Move constructor

inline explicit CiphertextImpl(Ciphertext<Element> &&ct) noexcept
virtual ~CiphertextImpl() = default

Destructor

CiphertextImpl<Element> &operator=(const CiphertextImpl<Element> &rhs) = default

Assignment Operator.

Parameters

&rhs – the CiphertextImpl to assign from

Returns

this CiphertextImpl

CiphertextImpl<Element> &operator=(CiphertextImpl<Element> &&rhs) noexcept = default

Move Assignment Operator.

Parameters

&rhs – the CiphertextImpl to move from

Returns

this CiphertextImpl

inline const Element &GetElement() const

GetElement - get the ring element for the cases that use only one element in the vector this method will throw an exception if it’s ever called in cases with other than 1 element

Returns

the first (and only!) ring element

inline Element &GetElement()

GetElement - get the ring element for the cases that use only one element in the vector this method will throw an exception if it’s ever called in cases with other than 1 element

Returns

the first (and only!) ring element

inline const std::vector<Element> &GetElements() const

GetElements: get all of the ring elements in the CiphertextImpl

Returns

vector of ring elements

inline std::vector<Element> &GetElements()

GetElements: get all of the ring elements in the CiphertextImpl

Returns

vector of ring elements

inline size_t NumberCiphertextElements() const
inline void SetElement(const Element &element)

SetElement - sets the ring element for the cases that use only one element in the vector this method will throw an exception if it’s ever called in cases with other than 1 element

Parameters

&element – is a polynomial ring element.

inline void SetElements(const std::vector<Element> &elements)

Sets the data elements.

Parameters

&element – is a polynomial ring element.

inline void SetElements(std::vector<Element> &&elements) noexcept

Sets the data elements by std::move.

Parameters

&&element – is a polynomial ring element.

inline size_t GetNoiseScaleDeg() const

Get the degree of the scaling factor for the encrypted message.

inline void SetNoiseScaleDeg(size_t noiseScaleDeg)

Set the degree of the scaling factor for the encrypted message.

inline size_t GetLevel() const

Get the number of scalings performed

inline void SetLevel(size_t level)

Set the number of scalings

inline size_t GetHopLevel() const

Get the re-encryption level of the ciphertext.

inline void SetHopLevel(size_t hoplevel)

Set the re-encryption level of the ciphertext.

inline double GetScalingFactor() const

Get the scaling factor of the ciphertext.

inline void SetScalingFactor(double sf)

Set the scaling factor of the ciphertext.

inline NativeInteger GetScalingFactorInt() const

Get the scaling factor of the ciphertext.

inline void SetScalingFactorInt(NativeInteger sf)

Set the scaling factor of the ciphertext.

inline uint32_t GetSlots() const

Get the number of slots of the ciphertext.

inline void SetSlots(uint32_t slots)

Set the number of slots of the ciphertext.

inline PlaintextEncodings GetEncodingType() const

GetEncodingType

Returns

how the Plaintext that this CiphertextImpl was created from was encoded

inline void SetEncodingType(PlaintextEncodings et)

SetEncodingType - after Encrypt, remember the CiphertextImpl’s encoding type

Parameters

et

inline MetadataMap GetMetadataMap() const

Get the Metadata map of the ciphertext.

inline void SetMetadataMap(const MetadataMap &mdata)

Set the Metadata map of the ciphertext.

inline std::map<std::string, std::shared_ptr<Metadata>>::iterator FindMetadataByKey(std::string key) const

This method searches the metadata map for metadata of a specific key.

Parameters

key – the string value which serves as a key in the metadata map

Returns

an iterator pointing at the position in the map where the key was found (or the map.end() if not found).

inline bool MetadataFound(std::map<std::string, std::shared_ptr<Metadata>>::iterator it) const

This method checks whether an iterator return from FindMetadataByKey corresponds to whether the key was found or not.

Parameters

it – iterator pointing at the position in the map where the key was found (or the map.end() if not found).

Returns

a boolean value indicating whether the key was found or not.

inline std::shared_ptr<Metadata> &GetMetadata(std::map<std::string, std::shared_ptr<Metadata>>::iterator it) const

This method returns the Metadata object stored in the iterator position returned by FindMetadataByKey.

Parameters

it – iterator pointing at the position in the map where the key was found (or the map.end() if not found).

Returns

a shared pointer pointing to the Metadata object in the map.

inline std::shared_ptr<Metadata> GetMetadataByKey(const std::string &key) const

Get a Metadata element from the Metadata map of the ciphertext.

inline void SetMetadataByKey(const std::string &key, const std::shared_ptr<Metadata> &value)

Set a Metadata element in the Metadata map of the ciphertext.

inline virtual Ciphertext<Element> CloneEmpty() const

This method creates a copy of this, skipping the actual encrypted elements. This means it copies parameters, key tags, encoding type, and metadata.

inline virtual Ciphertext<Element> Clone() const
inline bool operator==(const CiphertextImpl<Element> &rhs) const
inline bool operator!=(const CiphertextImpl<Element> &rhs) const
template<class Archive>
inline void save(Archive &ar, std::uint32_t const version) const
template<class Archive>
inline void load(Archive &ar, std::uint32_t const version)
inline std::string SerializedObjectName() const
void SetLevel(size_t level)
void SetLevel(size_t level)

Public Static Functions

static inline uint32_t SerializedVersion()

Friends

inline friend std::ostream &operator<<(std::ostream &out, const CiphertextImpl<Element> &c)
inline friend std::ostream &operator<<(std::ostream &out, Ciphertext<Element> c)