diff --git a/src/core/include/lattice/hal/default/poly-impl.h b/src/core/include/lattice/hal/default/poly-impl.h index 48c47d24d..db07fd9e8 100644 --- a/src/core/include/lattice/hal/default/poly-impl.h +++ b/src/core/include/lattice/hal/default/poly-impl.h @@ -43,7 +43,6 @@ #include "utils/inttypes.h" #include -#include #include #include #include diff --git a/src/core/include/lattice/hal/elemparams.h b/src/core/include/lattice/hal/elemparams.h index 0538c60b7..ca1d4321c 100644 --- a/src/core/include/lattice/hal/elemparams.h +++ b/src/core/include/lattice/hal/elemparams.h @@ -43,7 +43,6 @@ #include "utils/inttypes.h" #include "utils/serializable.h" -#include #include #include diff --git a/src/core/include/math/hal/bigintdyn/mubintvecdyn.h b/src/core/include/math/hal/bigintdyn/mubintvecdyn.h index f42da182f..cddd4ff95 100644 --- a/src/core/include/math/hal/bigintdyn/mubintvecdyn.h +++ b/src/core/include/math/hal/bigintdyn/mubintvecdyn.h @@ -47,7 +47,6 @@ #include "utils/serializable.h" #include - #include #include #include #include diff --git a/src/core/include/math/hal/bigintdyn/ubintdyn.h b/src/core/include/math/hal/bigintdyn/ubintdyn.h index cffc6fcaa..e8c8c2c16 100644 --- a/src/core/include/math/hal/bigintdyn/ubintdyn.h +++ b/src/core/include/math/hal/bigintdyn/ubintdyn.h @@ -51,14 +51,10 @@ #include "utils/serializable.h" #include "utils/utilities.h" - // #include #include - #include #include - // #include #include #include - // #include #include #include @@ -882,21 +878,7 @@ class ubint final : public lbcrypto::BigIntegerInterface> { /** * 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 void save(Archive& ar, std::uint32_t const version) const { diff --git a/src/core/include/math/hal/bigintfxd/mubintvecfxd.h b/src/core/include/math/hal/bigintfxd/mubintvecfxd.h index ca1911ff2..37e66ecc5 100644 --- a/src/core/include/math/hal/bigintfxd/mubintvecfxd.h +++ b/src/core/include/math/hal/bigintfxd/mubintvecfxd.h @@ -39,7 +39,6 @@ #ifndef LBCRYPTO_MATH_HAL_BIGINTFXD_MUBINVECFXD_H #define LBCRYPTO_MATH_HAL_BIGINTFXD_MUBINVECFXD_H - #include #include #include "utils/inttypes.h" diff --git a/src/core/include/math/hal/bigintfxd/ubintfxd.h b/src/core/include/math/hal/bigintfxd/ubintfxd.h index b917c4c36..46f6bdec5 100644 --- a/src/core/include/math/hal/bigintfxd/ubintfxd.h +++ b/src/core/include/math/hal/bigintfxd/ubintfxd.h @@ -48,13 +48,11 @@ #include #include #include - #include #include #include #include #include #include - #include #include "math/hal/basicint.h" #include "math/hal/integer.h" diff --git a/src/core/include/math/hal/bigintntl/mubintvecntl.h b/src/core/include/math/hal/bigintntl/mubintvecntl.h index 2c8262c37..5061f7431 100644 --- a/src/core/include/math/hal/bigintntl/mubintvecntl.h +++ b/src/core/include/math/hal/bigintntl/mubintvecntl.h @@ -48,7 +48,6 @@ #include #include - #include #include #include diff --git a/src/core/include/math/hal/bigintntl/ubintntl.h b/src/core/include/math/hal/bigintntl/ubintntl.h index f0199582f..0f4f0b5a6 100644 --- a/src/core/include/math/hal/bigintntl/ubintntl.h +++ b/src/core/include/math/hal/bigintntl/ubintntl.h @@ -60,7 +60,6 @@ #include #include #include - #include #include #include #include diff --git a/src/core/include/math/hal/intnat/mubintvecnat.h b/src/core/include/math/hal/intnat/mubintvecnat.h index abc48d847..38483830d 100644 --- a/src/core/include/math/hal/intnat/mubintvecnat.h +++ b/src/core/include/math/hal/intnat/mubintvecnat.h @@ -47,7 +47,6 @@ #include #include -#include #include #include #include diff --git a/src/core/include/math/hal/intnat/ubintnat.h b/src/core/include/math/hal/intnat/ubintnat.h index c5b6216a5..e2daf3ba7 100644 --- a/src/core/include/math/hal/intnat/ubintnat.h +++ b/src/core/include/math/hal/intnat/ubintnat.h @@ -48,16 +48,10 @@ #include "utils/serializable.h" #include -// #include -// #include #include -#include #include -// #include -// #include #include #include -// #include #include #include diff --git a/src/core/include/math/matrix.h b/src/core/include/math/matrix.h index 1e30837c7..aae726200 100644 --- a/src/core/include/math/matrix.h +++ b/src/core/include/math/matrix.h @@ -50,7 +50,6 @@ #include #include -// #include #include #include #include diff --git a/src/core/include/math/matrixstrassen.h b/src/core/include/math/matrixstrassen.h index efabc6cd7..d4c36a07f 100644 --- a/src/core/include/math/matrixstrassen.h +++ b/src/core/include/math/matrixstrassen.h @@ -41,9 +41,7 @@ #include "utils/exception.h" #include "utils/parallel.h" -// #include #include -// #include #include #include #include diff --git a/src/core/include/utils/debug.h b/src/core/include/utils/debug.h index 33a4818f6..d1e8979cc 100644 --- a/src/core/include/utils/debug.h +++ b/src/core/include/utils/debug.h @@ -37,9 +37,6 @@ #ifndef __dbg_h__ #define __dbg_h__ -// include -// include - /* 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 diff --git a/src/core/include/utils/exception.h b/src/core/include/utils/exception.h index 3517d81ac..f457d3a00 100644 --- a/src/core/include/utils/exception.h +++ b/src/core/include/utils/exception.h @@ -38,7 +38,6 @@ #include "utils/get-call-stack.h" #include -#include #include #include #include @@ -185,12 +184,12 @@ class OpenFHEException : public std::exception { return m_errorMessage.c_str(); } - std::vector getCallStackAsVector() { + std::vector 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(); } }; diff --git a/src/core/include/utils/hashutil.h b/src/core/include/utils/hashutil.h index 4e62a2b6f..84407e079 100644 --- a/src/core/include/utils/hashutil.h +++ b/src/core/include/utils/hashutil.h @@ -37,7 +37,6 @@ #define _SRC_LIB_UTILS_HASHUTIL_H #include -#include #include #include diff --git a/src/core/include/utils/memory.h b/src/core/include/utils/memory.h index d8c081649..ccd71cd2a 100644 --- a/src/core/include/utils/memory.h +++ b/src/core/include/utils/memory.h @@ -36,38 +36,13 @@ #ifndef LBCRYPTO_UTILS_MEMORY_H #define LBCRYPTO_UTILS_MEMORY_H -#include -#include -#include +#include +#include #include #include -#include 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 \ - inline std::unique_ptr make_unique(LIST(_TYPE_REFREF_ARG)) { \ - return std::unique_ptr(new T(LIST(_FORWARD_ARG))); \ - } -_VARIADIC_EXPAND_0X(_MAKE_UNIQUE, , , , ) - #undef _MAKE_UNIQUE - -#else - -// *nix implementation -template -std::unique_ptr make_unique(Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -#endif - template void MoveAppend(std::vector& dst, std::vector& src) { if (dst.empty()) { diff --git a/src/core/include/utils/serial.h b/src/core/include/utils/serial.h index dad6612ad..ca7807f00 100644 --- a/src/core/include/utils/serial.h +++ b/src/core/include/utils/serial.h @@ -82,7 +82,6 @@ #endif #include -#include #include #include diff --git a/src/core/include/utils/serializable.h b/src/core/include/utils/serializable.h index f5e4917a8..5745cd9fc 100644 --- a/src/core/include/utils/serializable.h +++ b/src/core/include/utils/serializable.h @@ -68,7 +68,7 @@ #pragma clang diagnostic pop #endif -#include +#include #include #include diff --git a/src/core/include/utils/type_name.h b/src/core/include/utils/type_name.h index 648688fc2..ab20da07e 100644 --- a/src/core/include/utils/type_name.h +++ b/src/core/include/utils/type_name.h @@ -33,7 +33,6 @@ #include "utils/demangle.h" #include -#include #include #include diff --git a/src/core/lib/math/hal/bigintdyn/ubintdyn.cpp b/src/core/lib/math/hal/bigintdyn/ubintdyn.cpp index 21717ee54..51fa77392 100644 --- a/src/core/lib/math/hal/bigintdyn/ubintdyn.cpp +++ b/src/core/lib/math/hal/bigintdyn/ubintdyn.cpp @@ -1008,6 +1008,23 @@ uschar ubint::GetBitAtIndex(usint index) const { template class bigintdyn::ubint; +template +void ubint::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<<(std::ostream& os, const std::vector& v); diff --git a/src/pke/include/constants.h b/src/pke/include/constants.h index 92cca1376..299f9c1d5 100644 --- a/src/pke/include/constants.h +++ b/src/pke/include/constants.h @@ -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 #include diff --git a/src/pke/include/encoding/plaintext.h b/src/pke/include/encoding/plaintext.h index efd18cc85..e4c06861c 100644 --- a/src/pke/include/encoding/plaintext.h +++ b/src/pke/include/encoding/plaintext.h @@ -43,7 +43,6 @@ #include "scheme/scheme-id.h" #include -#include #include #include #include diff --git a/src/pke/include/scheme/ckksrns/ckksrns-utils.h b/src/pke/include/scheme/ckksrns/ckksrns-utils.h index 4dbf2ab48..2992d2da2 100644 --- a/src/pke/include/scheme/ckksrns/ckksrns-utils.h +++ b/src/pke/include/scheme/ckksrns/ckksrns-utils.h @@ -34,7 +34,6 @@ #include #include -#include #include #include diff --git a/src/pke/include/scheme/gen-cryptocontext-params.h b/src/pke/include/scheme/gen-cryptocontext-params.h index c78a8edcf..84fc5700d 100644 --- a/src/pke/include/scheme/gen-cryptocontext-params.h +++ b/src/pke/include/scheme/gen-cryptocontext-params.h @@ -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 diff --git a/src/pke/include/schemebase/rlwe-cryptoparameters.h b/src/pke/include/schemebase/rlwe-cryptoparameters.h index cb8c2c557..ef5b15cfc 100644 --- a/src/pke/include/schemebase/rlwe-cryptoparameters.h +++ b/src/pke/include/schemebase/rlwe-cryptoparameters.h @@ -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" diff --git a/src/pke/lib/encoding/packedencoding.cpp b/src/pke/lib/encoding/packedencoding.cpp index 632eeeaa2..8f800e712 100644 --- a/src/pke/lib/encoding/packedencoding.cpp +++ b/src/pke/lib/encoding/packedencoding.cpp @@ -54,8 +54,6 @@ 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; @@ -63,7 +61,7 @@ bool PackedEncoding::Encode() { 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)); @@ -119,13 +117,13 @@ bool PackedEncoding::Encode() { const std::vector>& 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)); @@ -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) @@ -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().SetValues(std::move(temp), Format::EVALUATION);