Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

871 remove includes and some obsolete code #898

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/core/include/lattice/hal/default/poly-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "utils/inttypes.h"

#include <cmath>
#include <iostream>
#include <limits>
#include <memory>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion src/core/include/lattice/hal/elemparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "utils/inttypes.h"
#include "utils/serializable.h"

#include <iostream>
#include <string>
#include <utility>

Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/hal/bigintdyn/mubintvecdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "utils/serializable.h"

#include <initializer_list>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
Expand Down
20 changes: 1 addition & 19 deletions src/core/include/math/hal/bigintdyn/ubintdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@
#include "utils/serializable.h"
#include "utils/utilities.h"

// #include <fstream>
#include <functional>
#include <iostream>
#include <limits>
// #include <memory>
#include <string>
#include <type_traits>
// #include <typeinfo>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -882,21 +878,7 @@ class ubint final : public lbcrypto::BigIntegerInterface<ubint<limb_t>> {
/**
* documentation function, prints sizes of constats.
*/
static void PrintIntegerConstants() {
std::cout << "sizeof UINT8_C " << sizeof(UINT8_C(1)) << std::endl;
std::cout << "sizeof UINT16_C " << sizeof(UINT16_C(1)) << std::endl;
std::cout << "sizeof UINT32_C " << sizeof(UINT32_C(1)) << std::endl;
std::cout << "sizeof UINT64_C " << sizeof(UINT64_C(1)) << std::endl;
std::cout << "sizeof uint8_t " << sizeof(uint8_t) << std::endl;
std::cout << "sizeof uint16_t " << sizeof(uint16_t) << std::endl;
std::cout << "sizeof uint32_t " << sizeof(uint32_t) << std::endl;
std::cout << "sizeof uint64_t " << sizeof(uint64_t) << std::endl;
#if defined(HAVE_INT128)
// std::cout << "sizeof UINT128_C "<< sizeof (UINT128_C(1)) << std::endl;
// dbc commented out unsupported on some machines
std::cout << "sizeof uint128_t " << sizeof(uint128_t) << std::endl;
#endif
}
static void PrintIntegerConstants();

template <class Archive>
void save(Archive& ar, std::uint32_t const version) const {
Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/hal/bigintfxd/mubintvecfxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#ifndef LBCRYPTO_MATH_HAL_BIGINTFXD_MUBINVECFXD_H
#define LBCRYPTO_MATH_HAL_BIGINTFXD_MUBINVECFXD_H

#include <iostream>
#include <string>

#include "utils/inttypes.h"
Expand Down
2 changes: 0 additions & 2 deletions src/core/include/math/hal/bigintfxd/ubintfxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <string>
#include <type_traits>
#include <typeinfo>
#include <vector>

#include "math/hal/basicint.h"
#include "math/hal/integer.h"
Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/hal/bigintntl/mubintvecntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <NTL/vector.h>

#include <initializer_list>
#include <iostream>
#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/hal/bigintntl/ubintntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <memory>
#include <sstream>
Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/hal/intnat/mubintvecnat.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@

#include <algorithm>
#include <initializer_list>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
Expand Down
6 changes: 0 additions & 6 deletions src/core/include/math/hal/intnat/ubintnat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,10 @@
#include "utils/serializable.h"

#include <cstdint>
// #include <cstdlib>
// #include <fstream>
#include <functional>
#include <iostream>
#include <limits>
// #include <memory>
// #include <sstream>
#include <string>
#include <type_traits>
// #include <typeinfo>
#include <vector>
#include <utility>

Expand Down
1 change: 0 additions & 1 deletion src/core/include/math/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

#include <cmath>
#include <functional>
// #include <iostream>
#include <memory>
#include <string>
#include <utility>
Expand Down
2 changes: 0 additions & 2 deletions src/core/include/math/matrixstrassen.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@
#include "utils/exception.h"
#include "utils/parallel.h"

// #include <cmath>
#include <functional>
// #include <iostream>
#include <memory>
#include <utility>
#include <vector>
Expand Down
3 changes: 0 additions & 3 deletions src/core/include/utils/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#ifndef __dbg_h__
#define __dbg_h__

// include <iostream>
// include <cstdlib.h>

/* defining NDEBUG in the compile line turns everything off.
unless PROFILE is defined in the file before all includes,'
in which case TIC/TOC will still work and PROFILELOG() can be
Expand Down
5 changes: 2 additions & 3 deletions src/core/include/utils/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

#include "utils/get-call-stack.h"
#include <exception>
#include <iostream>
#include <mutex>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -185,12 +184,12 @@ class OpenFHEException : public std::exception {
return m_errorMessage.c_str();
}

std::vector<std::string> getCallStackAsVector() {
std::vector<std::string> getCallStackAsVector() const {
return m_callStack;
}

// getCallStackAsString() was added to be used by JSON logger. the implementtion will follow
std::string getCallStackAsString() {
std::string getCallStackAsString() const {
return std::string();
}
};
Expand Down
1 change: 0 additions & 1 deletion src/core/include/utils/hashutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define _SRC_LIB_UTILS_HASHUTIL_H

#include <utils/exception.h>
#include <iostream>
#include <string>
#include <vector>

Expand Down
29 changes: 2 additions & 27 deletions src/core/include/utils/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,13 @@
#ifndef LBCRYPTO_UTILS_MEMORY_H
#define LBCRYPTO_UTILS_MEMORY_H

#include <algorithm>
#include <iterator>
#include <memory>
#include <cstdint>
#include <cstddef>
#include <utility>
#include <vector>
#include <cstddef>

namespace lbcrypto {

// make_unique was left out of c++11, these are the accepted implementation
#if _MSC_VER == 1700

// MSVC11 does not support variadic templates
#define _MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4) \
\
template <class T COMMA LIST(_CLASS_TYPE)> \
inline std::unique_ptr<T> make_unique(LIST(_TYPE_REFREF_ARG)) { \
return std::unique_ptr<T>(new T(LIST(_FORWARD_ARG))); \
}
_VARIADIC_EXPAND_0X(_MAKE_UNIQUE, , , , )
#undef _MAKE_UNIQUE

#else

// *nix implementation
template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

#endif

template <class X>
void MoveAppend(std::vector<X>& dst, std::vector<X>& src) {
if (dst.empty()) {
Expand Down
1 change: 0 additions & 1 deletion src/core/include/utils/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
#endif

#include <fstream>
#include <iostream>
#include <sstream>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/core/include/utils/serializable.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#pragma clang diagnostic pop
#endif

#include <iostream>
#include <ostream>
#include <string>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion src/core/include/utils/type_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include "utils/demangle.h"
#include <typeinfo>
#include <iostream>
#include <memory>
#include <string>

Expand Down
17 changes: 17 additions & 0 deletions src/core/lib/math/hal/bigintdyn/ubintdyn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,23 @@ uschar ubint<limb_t>::GetBitAtIndex(usint index) const {

template class bigintdyn::ubint<expdtype>;

template <typename limb_t>
void ubint<limb_t>::PrintIntegerConstants() {
std::cout << "sizeof UINT8_C " << sizeof(UINT8_C(1)) << std::endl;
std::cout << "sizeof UINT16_C " << sizeof(UINT16_C(1)) << std::endl;
std::cout << "sizeof UINT32_C " << sizeof(UINT32_C(1)) << std::endl;
std::cout << "sizeof UINT64_C " << sizeof(UINT64_C(1)) << std::endl;
std::cout << "sizeof uint8_t " << sizeof(uint8_t) << std::endl;
std::cout << "sizeof uint16_t " << sizeof(uint16_t) << std::endl;
std::cout << "sizeof uint32_t " << sizeof(uint32_t) << std::endl;
std::cout << "sizeof uint64_t " << sizeof(uint64_t) << std::endl;
#if defined(HAVE_INT128)
// std::cout << "sizeof UINT128_C "<< sizeof (UINT128_C(1)) << std::endl;
// dbc commented out unsupported on some machines
std::cout << "sizeof uint128_t " << sizeof(uint128_t) << std::endl;
#endif
}

#if 0
// to stream internal representation
template std::ostream& operator<<<expdtype>(std::ostream& os, const std::vector<expdtype>& v);
Expand Down
3 changes: 1 addition & 2 deletions src/pke/include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#ifndef _CONSTANTS_H_
#define _CONSTANTS_H_

#include "constants-defs.h" // all enum definitions
#include "lattice/constants-lattice.h" // additional definitions
#include "constants-defs.h" // all enum definitions

#include <iosfwd>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion src/pke/include/encoding/plaintext.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "scheme/scheme-id.h"

#include <initializer_list>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion src/pke/include/scheme/ckksrns/ckksrns-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include <vector>
#include <complex>
#include <iostream>
#include <stdint.h>
#include <memory>

Expand Down
1 change: 1 addition & 0 deletions src/pke/include/scheme/gen-cryptocontext-params.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "scheme/scheme-id.h"
#include "utils/inttypes.h"
#include "constants.h"
#include "lattice/constants-lattice.h"
#include "lattice/stdlatticeparms.h"

#include <iosfwd>
Expand Down
1 change: 1 addition & 0 deletions src/pke/include/schemebase/rlwe-cryptoparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "lattice/lat-hal.h"
#include "schemebase/base-cryptoparameters.h"
#include "constants.h"
#include "lattice/constants-lattice.h"

// TODO - temp include for the SecurityLevel
#include "lattice/stdlatticeparms.h"
Expand Down
20 changes: 8 additions & 12 deletions src/pke/lib/encoding/packedencoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,14 @@ bool PackedEncoding::Encode() {
auto mod = this->encodingParams->GetPlaintextModulus();

if ((this->typeFlag == IsNativePoly) || (this->typeFlag == IsDCRTPoly)) {
size_t i;

NativeVector tempVector = NativeVector(this->GetElementRingDimension(), mod);

NativeInteger originalSF = scalingFactorInt;
for (size_t j = 1; j < noiseScaleDeg; j++) {
scalingFactorInt = scalingFactorInt.ModMul(originalSF, mod);
}

for (i = 0; i < value.size(); i++) {
for (size_t i = 0; i < value.size(); i++) {
if ((PlaintextModulus)llabs(value[i]) >= mod) {
OPENFHE_THROW("Cannot encode integer " + std::to_string(value[i]) + " at position " +
std::to_string(i) + " that is > plaintext modulus " + std::to_string(mod));
Expand Down Expand Up @@ -119,13 +117,13 @@ bool PackedEncoding::Encode() {
const std::vector<std::shared_ptr<ILNativeParams>>& nativeParams = params->GetParams();

// Sets the values for all other RNS limbs
for (size_t ii = 1; ii < nativeParams.size(); ii++) {
for (size_t j = 1; j < nativeParams.size(); j++) {
NativePoly tempPoly(firstElement);

tempPoly.SwitchModulus(nativeParams[ii]->GetModulus(), nativeParams[ii]->GetRootOfUnity(),
nativeParams[ii]->GetBigModulus(), nativeParams[ii]->GetBigRootOfUnity());
tempPoly.SwitchModulus(nativeParams[j]->GetModulus(), nativeParams[j]->GetRootOfUnity(),
nativeParams[j]->GetBigModulus(), nativeParams[j]->GetBigRootOfUnity());

this->encodedVectorDCRT.SetElementAtIndex(ii, std::move(tempPoly));
this->encodedVectorDCRT.SetElementAtIndex(j, std::move(tempPoly));
}
// Setting the first limb at the end make sure firstElement is available during the main loop
this->encodedVectorDCRT.SetElementAtIndex(0, std::move(firstElement));
Expand All @@ -138,8 +136,7 @@ bool PackedEncoding::Encode() {

BigInteger q = this->GetElementModulus();

size_t i;
for (i = 0; i < value.size(); i++) {
for (size_t i = 0; i < value.size(); ++i) {
BigInteger entry;

if ((PlaintextModulus)llabs(value[i]) >= mod)
Expand All @@ -157,9 +154,8 @@ bool PackedEncoding::Encode() {

temp[i] = entry;
}

for (; i < this->GetElementRingDimension(); i++)
temp[i] = BigInteger(0);
for (size_t j = value.size(); j < this->GetElementRingDimension(); ++j)
temp[j] = BigInteger(0);

// the input plaintext data is in the evaluation format
this->GetElement<Poly>().SetValues(std::move(temp), Format::EVALUATION);
Expand Down