25 #ifndef LBCRYPTO_ENCODING_ENCODINGPARAMS_H 26 #define LBCRYPTO_ENCODING_ENCODINGPARAMS_H 32 #include "math/backend.h" 35 class EncodingParamsImpl;
37 typedef std::shared_ptr<EncodingParamsImpl> EncodingParams;
38 typedef uint64_t PlaintextModulus;
59 uint32_t batchSize = 0, uint32_t plaintextGenerator = 0,
63 m_plaintextModulus = plaintextModulus;
64 m_plaintextRootOfUnity = plaintextRootOfUnity;
65 m_plaintextBigModulus = plaintextBigModulus;
66 m_plaintextBigRootOfUnity = plaintextBigRootOfUnity;
67 m_batchSize = batchSize;
68 m_plaintextGenerator = plaintextGenerator;
77 m_plaintextModulus = rhs.m_plaintextModulus;
78 m_plaintextRootOfUnity = rhs.m_plaintextRootOfUnity;
79 m_plaintextBigModulus = rhs.m_plaintextBigModulus;
80 m_plaintextBigRootOfUnity = rhs.m_plaintextBigRootOfUnity;
81 m_plaintextGenerator = rhs.m_plaintextGenerator;
82 m_batchSize = rhs.m_batchSize;
91 m_plaintextModulus = std::move(rhs.m_plaintextModulus);
92 m_plaintextRootOfUnity = std::move(rhs.m_plaintextRootOfUnity);
93 m_plaintextBigModulus = std::move(rhs.m_plaintextBigModulus);
94 m_plaintextBigRootOfUnity = std::move(rhs.m_plaintextBigRootOfUnity);
95 m_plaintextGenerator = std::move(rhs.m_plaintextGenerator);
96 m_batchSize = rhs.m_batchSize;
106 m_plaintextModulus = rhs.m_plaintextModulus;
107 m_plaintextRootOfUnity = rhs.m_plaintextRootOfUnity;
108 m_plaintextBigModulus = rhs.m_plaintextBigModulus;
109 m_plaintextBigRootOfUnity = rhs.m_plaintextBigRootOfUnity;
110 m_plaintextGenerator = rhs.m_plaintextGenerator;
111 m_batchSize = rhs.m_batchSize;
129 return m_plaintextModulus;
136 m_plaintextModulus = plaintextModulus;
144 return m_plaintextRootOfUnity;
151 m_plaintextRootOfUnity = plaintextRootOfUnity;
159 return m_plaintextBigModulus;
166 m_plaintextBigModulus = plaintextBigModulus;
174 return m_plaintextBigRootOfUnity;
182 m_plaintextBigRootOfUnity = plaintextBigRootOfUnity;
195 m_plaintextGenerator = plaintextGenerator;
218 return item.doprint(out);
227 return m_plaintextModulus == other.m_plaintextModulus &&
228 m_plaintextRootOfUnity == other.m_plaintextRootOfUnity &&
229 m_plaintextBigModulus == other.m_plaintextBigModulus &&
230 m_plaintextBigRootOfUnity == other.m_plaintextBigRootOfUnity &&
231 m_plaintextGenerator == other.m_plaintextGenerator &&
232 m_batchSize == other.m_batchSize;
241 return !(*
this == other);
245 std::ostream &doprint(std::ostream &out)
const {
246 out <<
"[p=" << m_plaintextModulus <<
" rootP =" << m_plaintextRootOfUnity
247 <<
" bigP =" << m_plaintextBigModulus
248 <<
" rootBigP =" << m_plaintextBigRootOfUnity
249 <<
" g=" << m_plaintextGenerator <<
" L=" << m_batchSize <<
"]";
254 PlaintextModulus m_plaintextModulus;
263 uint32_t m_plaintextGenerator;
265 uint32_t m_batchSize;
268 template <
class Archive>
269 void save(Archive &ar, std::uint32_t
const version)
const {
270 ar(::cereal::make_nvp(
"m", m_plaintextModulus));
271 ar(::cereal::make_nvp(
"ru", m_plaintextRootOfUnity));
272 ar(::cereal::make_nvp(
"bm", m_plaintextBigModulus));
273 ar(::cereal::make_nvp(
"bru", m_plaintextBigRootOfUnity));
274 ar(::cereal::make_nvp(
"g", m_plaintextGenerator));
275 ar(::cereal::make_nvp(
"bs", m_batchSize));
278 template <
class Archive>
279 void load(Archive &ar, std::uint32_t
const version) {
280 if (version > SerializedVersion()) {
282 "serialized object version " + std::to_string(version) +
283 " is from a later version of the library");
285 ar(::cereal::make_nvp(
"m", m_plaintextModulus));
286 ar(::cereal::make_nvp(
"ru", m_plaintextRootOfUnity));
287 ar(::cereal::make_nvp(
"bm", m_plaintextBigModulus));
288 ar(::cereal::make_nvp(
"bru", m_plaintextBigRootOfUnity));
289 ar(::cereal::make_nvp(
"g", m_plaintextGenerator));
290 ar(::cereal::make_nvp(
"bs", m_batchSize));
293 std::string SerializedObjectName()
const {
return "EncodingParms"; }
294 static uint32_t SerializedVersion() {
return 1; }
297 inline std::ostream &
operator<<(std::ostream &out,
298 std::shared_ptr<EncodingParamsImpl> o) {
302 inline bool operator==(std::shared_ptr<EncodingParamsImpl> o1,
303 std::shared_ptr<EncodingParamsImpl> o2) {
304 if (o1 && o2)
return *o1 == *o2;
305 if (!o1 && !o2)
return true;
Base class for PALISADE serialization.
Definition: serializable.h:76
bool operator==(const EncodingParamsImpl &other) const
Equality operator for the parameters. Tests that all the parameters are equal.
Definition: encodingparams.h:226
EncodingParamsImpl(const EncodingParamsImpl &&rhs)
Definition: encodingparams.h:90
void SetPlaintextGenerator(usint &plaintextGenerator)
Setter for the plaintext generator.
Definition: encodingparams.h:194
void SetPlaintextBigModulus(const NativeInteger &plaintextBigModulus)
Setter for the big plaintext modulus.
Definition: encodingparams.h:165
All parameters for plaintext encodings into ciphertext space.
Definition: encodingparams.h:44
void SetPlaintextModulus(PlaintextModulus plaintextModulus)
Setter for the plaintext modulus.
Definition: encodingparams.h:135
EncodingParamsImpl(const EncodingParamsImpl &rhs)
Definition: encodingparams.h:76
uint32_t GetBatchSize() const
Getter for the plaintext batch size.
Definition: encodingparams.h:202
Definition: exception.h:147
void SetPlaintextRootOfUnity(const NativeInteger &plaintextRootOfUnity)
Setter for the plaintext modulus root of unity.
Definition: encodingparams.h:150
usint GetPlaintextGenerator() const
Getter for the plaintext generator.
Definition: encodingparams.h:189
void SetBatchSize(usint batchSize)
Setter for the batch size.
Definition: encodingparams.h:207
const PlaintextModulus & GetPlaintextModulus() const
Getter for the plaintext modulus.
Definition: encodingparams.h:128
friend std::ostream & operator<<(std::ostream &out, const EncodingParamsImpl &item)
output stream operator.
Definition: encodingparams.h:216
const NativeInteger & GetPlaintextBigModulus() const
Getter for the big plaintext modulus.
Definition: encodingparams.h:158
const NativeInteger & GetPlaintextRootOfUnity() const
Getter for the plaintext modulus root of unity.
Definition: encodingparams.h:143
const EncodingParamsImpl & operator=(const EncodingParamsImpl &rhs)
Definition: encodingparams.h:105
virtual ~EncodingParamsImpl()
Definition: encodingparams.h:118
const NativeInteger & GetPlaintextBigRootOfUnity() const
Getter for the big plaintext modulus root of unity.
Definition: encodingparams.h:173
EncodingParamsImpl(PlaintextModulus plaintextModulus=0, uint32_t batchSize=0, uint32_t plaintextGenerator=0, NativeInteger plaintextRootOfUnity=0, NativeInteger plaintextBigModulus=0, NativeInteger plaintextBigRootOfUnity=0)
Definition: encodingparams.h:58
void SetPlaintextBigRootOfUnity(const NativeInteger &plaintextBigRootOfUnity)
Setter for the big plaintext modulus root of unity.
Definition: encodingparams.h:180
Definition: binfhecontext.h:36
bool operator!=(const EncodingParamsImpl &other) const
Inequality operator for the parameters. Tests that all the parameters are not equal.
Definition: encodingparams.h:240
Main class for big integers represented as an array of native (primitive) unsigned integers...
Definition: backend.h:60