Skip to content

Commit d6ca063

Browse files
Added the missing m_ prefix to class data members in src/pke
1 parent 6ba4130 commit d6ca063

20 files changed

Lines changed: 371 additions & 370 deletions

src/pke/include/cryptocontext.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ class CryptoContextImpl : public Serializable {
242242
const std::string& keyTag, const std::vector<uint32_t>& indexList);
243243

244244
// cached evalmult keys, by secret key UID
245-
static std::map<std::string, std::vector<EvalKey<Element>>> s_evalMultKeyMap;
245+
static std::map<std::string, std::vector<EvalKey<Element>>> m_evalMultKeyMap;
246246
// cached evalautomorphism keys, by secret key UID
247-
static std::map<std::string, std::shared_ptr<std::map<uint32_t, EvalKey<Element>>>> s_evalAutomorphismKeyMap;
247+
static std::map<std::string, std::shared_ptr<std::map<uint32_t, EvalKey<Element>>>> m_evalAutomorphismKeyMap;
248248

249249
protected:
250250
// crypto parameters
@@ -3613,15 +3613,14 @@ class CryptoContextImpl : public Serializable {
36133613
const std::vector<uint32_t>& dim1, const std::vector<uint32_t>& levelBudget,
36143614
uint32_t lvlsAfterBoot = 0, uint32_t depthLeveledComputation = 0, size_t order = 1) {
36153615
m_scheme->EvalFBTSetup(*this, coeffs, numSlots, PIn, POut, Bigq, pubKey, dim1, levelBudget, lvlsAfterBoot,
3616-
depthLeveledComputation, order);
3616+
depthLeveledComputation, order);
36173617
}
36183618

36193619
template <typename VectorDataType>
36203620
Ciphertext<Element> EvalFBT(ConstCiphertext<Element>& ciphertext, const std::vector<VectorDataType>& coeffs,
36213621
uint32_t digitBitSize, const BigInteger& initialScaling, uint64_t postScaling,
36223622
uint32_t levelToReduce = 0, size_t order = 1) {
3623-
return m_scheme->EvalFBT(ciphertext, coeffs, digitBitSize, initialScaling, postScaling, levelToReduce,
3624-
order);
3623+
return m_scheme->EvalFBT(ciphertext, coeffs, digitBitSize, initialScaling, postScaling, levelToReduce, order);
36253624
}
36263625

36273626
template <typename VectorDataType>
@@ -3892,7 +3891,7 @@ class CryptoContextImpl : public Serializable {
38923891
ValidateCiphertext(ciphertext1);
38933892
ValidateCiphertext(ciphertext2);
38943893
return m_scheme->EvalCompareSchemeSwitching(ciphertext1, ciphertext2, numCtxts, numSlots, pLWE, scaleSign,
3895-
unit);
3894+
unit);
38963895
}
38973896

38983897
/**

src/pke/include/cryptocontextfactory.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class CryptoParametersBase;
5454
*/
5555
template <typename Element>
5656
class CryptoContextFactory {
57-
static std::vector<CryptoContext<Element>> AllContexts;
57+
static std::vector<CryptoContext<Element>> m_AllContexts;
5858

5959
protected:
6060
static CryptoContext<Element> FindContext(std::shared_ptr<CryptoParametersBase<Element>> params,
@@ -63,13 +63,13 @@ class CryptoContextFactory {
6363

6464
public:
6565
static void ReleaseAllContexts() {
66-
if (AllContexts.size() > 0)
67-
AllContexts[0]->ClearStaticMapsAndVectors();
68-
AllContexts.clear();
66+
if (m_AllContexts.size() > 0)
67+
m_AllContexts[0]->ClearStaticMapsAndVectors();
68+
m_AllContexts.clear();
6969
}
7070

7171
static int GetContextCount() {
72-
return AllContexts.size();
72+
return m_AllContexts.size();
7373
}
7474

7575
static CryptoContext<Element> GetContext(std::shared_ptr<CryptoParametersBase<Element>> params,
@@ -82,12 +82,12 @@ class CryptoContextFactory {
8282
static CryptoContext<Element> GetFullContextByDeserializedContext(const CryptoContext<Element> context);
8383

8484
static const std::vector<CryptoContext<Element>>& GetAllContexts() {
85-
return AllContexts;
85+
return m_AllContexts;
8686
}
8787
};
8888

8989
template <>
90-
std::vector<CryptoContext<DCRTPoly>> CryptoContextFactory<DCRTPoly>::AllContexts;
90+
std::vector<CryptoContext<DCRTPoly>> CryptoContextFactory<DCRTPoly>::m_AllContexts;
9191

9292
} // namespace lbcrypto
9393

src/pke/include/cryptoobject.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ namespace lbcrypto {
5252
template <typename Element>
5353
class CryptoObject {
5454
protected:
55-
CryptoContext<Element> context; // crypto context belongs to the tag used to find the evaluation key needed
56-
// for SHE/FHE operations
57-
std::string keyTag;
55+
CryptoContext<Element> m_context; // crypto context belongs to the tag used to find the evaluation key needed
56+
// for SHE/FHE operations
57+
std::string m_keyTag;
5858

5959
public:
6060
CryptoObject() = default;
6161

62-
explicit CryptoObject(const CryptoContext<Element>& cc, const std::string& tag = "") : context(cc), keyTag(tag) {}
62+
explicit CryptoObject(const CryptoContext<Element>& cc, const std::string& tag = "")
63+
: m_context(cc), m_keyTag(tag) {}
6364

6465
CryptoObject(const CryptoObject& rhs) = default;
6566

@@ -68,51 +69,51 @@ class CryptoObject {
6869
virtual ~CryptoObject() = default;
6970

7071
CryptoObject& operator=(const CryptoObject& rhs) {
71-
context = rhs.context;
72-
keyTag = rhs.keyTag;
72+
m_context = rhs.m_context;
73+
m_keyTag = rhs.m_keyTag;
7374
return *this;
7475
}
7576

7677
CryptoObject& operator=(CryptoObject&& rhs) noexcept {
77-
context = std::move(rhs.context);
78-
keyTag = std::move(rhs.keyTag);
78+
m_context = std::move(rhs.m_context);
79+
m_keyTag = std::move(rhs.m_keyTag);
7980
return *this;
8081
}
8182

8283
bool operator==(const CryptoObject& rhs) const {
83-
return context.get() == rhs.context.get() && keyTag == rhs.keyTag;
84+
return m_context.get() == rhs.m_context.get() && m_keyTag == rhs.m_keyTag;
8485
}
8586

8687
CryptoContext<Element> GetCryptoContext() const {
87-
return context;
88+
return m_context;
8889
}
8990

9091
const std::shared_ptr<CryptoParametersBase<Element>> GetCryptoParameters() const;
9192

9293
const EncodingParams GetEncodingParameters() const;
9394

9495
const std::string& GetKeyTag() const {
95-
return keyTag;
96+
return m_keyTag;
9697
}
9798

9899
void SetKeyTag(const std::string& tag) {
99-
keyTag = tag;
100+
m_keyTag = tag;
100101
}
101102

102103
template <class Archive>
103104
void save(Archive& ar, std::uint32_t const version) const {
104-
ar(::cereal::make_nvp("cc", context));
105-
ar(::cereal::make_nvp("kt", keyTag));
105+
ar(::cereal::make_nvp("cc", m_context));
106+
ar(::cereal::make_nvp("kt", m_keyTag));
106107
}
107108

108109
template <class Archive>
109110
void load(Archive& ar, std::uint32_t const version) {
110111
if (version > SerializedVersion())
111112
OPENFHE_THROW("serialized object version " + std::to_string(version) +
112113
" is from a later version of the library");
113-
ar(::cereal::make_nvp("cc", context));
114-
ar(::cereal::make_nvp("kt", keyTag));
115-
context = CryptoContextFactory<Element>::GetFullContextByDeserializedContext(context);
114+
ar(::cereal::make_nvp("cc", m_context));
115+
ar(::cereal::make_nvp("kt", m_keyTag));
116+
m_context = CryptoContextFactory<Element>::GetFullContextByDeserializedContext(m_context);
116117
}
117118

118119
std::string SerializedObjectName() const {

src/pke/include/encoding/ckkspackedencoding.h

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace lbcrypto {
6060

6161
class CKKSPackedEncoding : public PlaintextImpl {
6262
private:
63-
std::vector<std::complex<double>> value;
63+
std::vector<std::complex<double>> m_value;
6464
double m_logError = 0.;
6565

6666
public:
@@ -71,8 +71,8 @@ class CKKSPackedEncoding : public PlaintextImpl {
7171
bool>::type = true>
7272
CKKSPackedEncoding(std::shared_ptr<T> vp, EncodingParams ep, CKKSDataType ckksdt = REAL)
7373
: PlaintextImpl(vp, ep, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME) {
74-
ckksDataType = ckksdt;
75-
slots = GetDefaultSlotSize();
74+
m_ckksDataType = ckksdt;
75+
m_slots = GetDefaultSlotSize();
7676
}
7777

7878
/*
@@ -87,16 +87,16 @@ class CKKSPackedEncoding : public PlaintextImpl {
8787
bool>::type = true>
8888
CKKSPackedEncoding(std::shared_ptr<T> vp, EncodingParams ep, const std::vector<std::complex<double>>& v,
8989
size_t nsdeg, uint32_t lvl, double scFact, uint32_t slts, CKKSDataType ckksdt = REAL)
90-
: PlaintextImpl(vp, ep, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME), value(v) {
91-
ckksDataType = ckksdt;
92-
scalingFactor = scFact;
93-
level = lvl;
94-
noiseScaleDeg = nsdeg;
95-
slots = GetDefaultSlotSize(slts, v.size());
96-
97-
if (ckksDataType == REAL) {
98-
auto* rvptr = reinterpret_cast<double*>(value.data()) + 1;
99-
auto* limit = rvptr + 2 * value.size();
90+
: PlaintextImpl(vp, ep, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME), m_value(v) {
91+
m_ckksDataType = ckksdt;
92+
m_scalingFactor = scFact;
93+
m_level = lvl;
94+
m_noiseScaleDeg = nsdeg;
95+
m_slots = GetDefaultSlotSize(slts, v.size());
96+
97+
if (m_ckksDataType == REAL) {
98+
auto* rvptr = reinterpret_cast<double*>(m_value.data()) + 1;
99+
auto* limit = rvptr + 2 * m_value.size();
100100
for (; rvptr < limit; rvptr += 2)
101101
*rvptr = 0;
102102
}
@@ -108,12 +108,12 @@ class CKKSPackedEncoding : public PlaintextImpl {
108108
* @param v - The input object to copy.
109109
*/
110110
explicit CKKSPackedEncoding(const std::vector<std::complex<double>>& v, uint32_t s)
111-
: PlaintextImpl(std::shared_ptr<Poly::Params>(0), nullptr, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME), value(v) {
112-
slots = GetDefaultSlotSize(s, v.size());
111+
: PlaintextImpl(std::shared_ptr<Poly::Params>(0), nullptr, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME), m_value(v) {
112+
m_slots = GetDefaultSlotSize(s, v.size());
113113

114-
// Assumes ckksDataType = REAL
115-
auto* rvptr = reinterpret_cast<double*>(value.data()) + 1;
116-
auto* limit = rvptr + 2 * value.size();
114+
// Assumes m_ckksDataType = REAL
115+
auto* rvptr = reinterpret_cast<double*>(m_value.data()) + 1;
116+
auto* limit = rvptr + 2 * m_value.size();
117117
for (; rvptr < limit; rvptr += 2)
118118
*rvptr = 0;
119119
}
@@ -123,14 +123,14 @@ class CKKSPackedEncoding : public PlaintextImpl {
123123
*/
124124
CKKSPackedEncoding()
125125
: PlaintextImpl(std::shared_ptr<Poly::Params>(0), nullptr, CKKS_PACKED_ENCODING, CKKSRNS_SCHEME) {
126-
slots = GetDefaultSlotSize();
126+
m_slots = GetDefaultSlotSize();
127127
}
128128

129129
CKKSPackedEncoding(const CKKSPackedEncoding& rhs)
130-
: PlaintextImpl(rhs), value(rhs.value), m_logError(rhs.m_logError) {}
130+
: PlaintextImpl(rhs), m_value(rhs.m_value), m_logError(rhs.m_logError) {}
131131

132132
CKKSPackedEncoding(CKKSPackedEncoding&& rhs) noexcept
133-
: PlaintextImpl(std::move(rhs)), value(std::move(rhs.value)), m_logError(rhs.m_logError) {}
133+
: PlaintextImpl(std::move(rhs)), m_value(std::move(rhs.m_value)), m_logError(rhs.m_logError) {}
134134

135135
bool Encode() override;
136136

@@ -141,13 +141,13 @@ class CKKSPackedEncoding : public PlaintextImpl {
141141
bool Decode(size_t depth, double scalingFactor, ScalingTechnique scalTech, ExecutionMode executionMode) override;
142142

143143
const std::vector<std::complex<double>>& GetCKKSPackedValue() const override {
144-
return value;
144+
return m_value;
145145
}
146146

147147
std::vector<double> GetRealPackedValue() const override {
148-
std::vector<double> realValue(value.size());
148+
std::vector<double> realValue(m_value.size());
149149
auto* rvptr = realValue.data();
150-
for (auto vit = value.cbegin(); vit != value.cend(); ++vit, ++rvptr)
150+
for (auto vit = m_value.cbegin(); vit != m_value.cend(); ++vit, ++rvptr)
151151
*rvptr = vit->real();
152152
return realValue;
153153
}
@@ -180,7 +180,7 @@ class CKKSPackedEncoding : public PlaintextImpl {
180180
* @return the length of the plaintext in terms of the number of bits.
181181
*/
182182
size_t GetLength() const override {
183-
return value.size();
183+
return m_value.size();
184184
}
185185

186186
/**
@@ -195,17 +195,17 @@ class CKKSPackedEncoding : public PlaintextImpl {
195195
* Get method to return log2 of estimated precision
196196
*/
197197
double GetLogPrecision() const override {
198-
if (ckksDataType == COMPLEX)
198+
if (m_ckksDataType == COMPLEX)
199199
OPENFHE_THROW("GetLogPrecision for complex numbers is not implemented.");
200-
return encodingParams->GetPlaintextModulus() - m_logError;
200+
return m_encodingParams->GetPlaintextModulus() - m_logError;
201201
}
202202

203203
/**
204204
* SetLength of the plaintext to the given size
205205
* @param siz
206206
*/
207207
void SetLength(size_t siz) override {
208-
value.resize(siz);
208+
m_value.resize(siz);
209209
}
210210

211211
/**
@@ -223,23 +223,24 @@ class CKKSPackedEncoding : public PlaintextImpl {
223223
ss << "(";
224224

225225
// for sanity's sake: get rid of all trailing zeroes and print "..." instead
226-
size_t i = value.size();
226+
size_t i = m_value.size();
227227
bool allZeroes = true;
228228
while (i > 0) {
229-
if (value[--i] != std::complex<double>(0, 0)) {
229+
if (m_value[--i] != std::complex<double>(0, 0)) {
230230
allZeroes = false;
231231
break;
232232
}
233233
}
234234
if (!allZeroes) {
235-
if (ckksDataType == REAL) {
235+
if (m_ckksDataType == REAL) {
236236
for (size_t j = 0; j <= i; ++j)
237-
ss << std::setprecision(precision) << value[j].real() << ", ";
237+
ss << std::setprecision(precision) << m_value[j].real() << ", ";
238238
ss << "... ); Estimated precision: " << GetLogPrecision() << " bits";
239239
}
240240
else {
241241
for (size_t j = 0; j <= i; ++j)
242-
ss << std::setprecision(precision) << " (" << value[j].real() << ", " << value[j].imag() << "), ";
242+
ss << std::setprecision(precision) << " (" << m_value[j].real() << ", " << m_value[j].imag()
243+
<< "), ";
243244
ss << "... )";
244245
}
245246
}
@@ -277,7 +278,7 @@ class CKKSPackedEncoding : public PlaintextImpl {
277278
return false;
278279

279280
const auto& el = static_cast<const CKKSPackedEncoding&>(rhs);
280-
return value == el.value;
281+
return m_value == el.m_value;
281282
}
282283

283284
/**

0 commit comments

Comments
 (0)