Skip to content
Closed
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
4 changes: 1 addition & 3 deletions src/core/include/lattice/hal/dcrtpoly-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ class DCRTPolyInterface : public ILElement<DerivedType, BigVecType> {
* @brief returns the element's root of unity.
* @return the element's root of unity.
*/
// TODO: this doesn't look right
const BigIntType GetRootOfUnity() const {
// return BigIntType(0);
const BigIntType& GetRootOfUnity() const {
return this->GetDerived().GetParams()->GetRootOfUnity();
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/include/lattice/hal/default/poly.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class PolyImpl final : public PolyInterface<PolyImpl<VecType>, VecType, PolyImpl
return m_values->at(i);
}

inline const Integer& at(usint i) const final {
inline Integer at(usint i) const final {
if (m_values == nullptr)
OPENFHE_THROW("No values in PolyImpl");
return m_values->at(i);
Expand All @@ -215,7 +215,7 @@ class PolyImpl final : public PolyInterface<PolyImpl<VecType>, VecType, PolyImpl
return (*m_values)[i];
}

inline const Integer& operator[](usint i) const final {
inline Integer operator[](usint i) const final {
return (*m_values)[i];
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/include/lattice/hal/elemparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class ElemParams : public Serializable {
* ciphertext modulus.
* @return The ciphertext modulus, not the big ciphertext modulus.
*/
const IntegerType& GetModulus() const {
IntegerType GetModulus() const {
return m_ciphertextModulus;
}

Expand All @@ -174,7 +174,7 @@ class ElemParams : public Serializable {
* This is not relevant for all applications.
* @return The big ciphertext modulus.
*/
const IntegerType& GetBigModulus() const {
IntegerType GetBigModulus() const {
return m_bigCiphertextModulus;
}

Expand All @@ -183,15 +183,15 @@ class ElemParams : public Serializable {
* unity.
* @return The root of unity, not the big root of unity.
*/
const IntegerType& GetRootOfUnity() const {
IntegerType GetRootOfUnity() const {
return m_rootOfUnity;
}

/**
* @brief Simple getter method for the big root of unity.
* @return The the big root of unity.
*/
const IntegerType& GetBigRootOfUnity() const {
IntegerType GetBigRootOfUnity() const {
return m_bigRootOfUnity;
}

Expand Down
10 changes: 5 additions & 5 deletions src/core/include/lattice/hal/poly-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ class PolyInterface : public ILElement<DerivedType, VecType> {
* @brief returns the element's root of unity.
* @return the element's root of unity.
*/
const Integer& GetRootOfUnity() const {
Integer GetRootOfUnity() const {
return this->GetDerived().GetParams()->GetRootOfUnity();
}

/**
* @brief returns the element's modulus
* @return returns the modulus of the element.
*/
const Integer& GetModulus() const final {
Integer GetModulus() const final {
return this->GetDerived().GetParams()->GetModulus();
}

Expand Down Expand Up @@ -218,8 +218,8 @@ class PolyInterface : public ILElement<DerivedType, VecType> {
* Note this operation is computationally intense. Does bound checking
* @return interpolated value at index i.
*/
Integer& at(usint i) override = 0;
const Integer& at(usint i) const override = 0;
Integer& at(usint i) override = 0;
Integer at(usint i) const override = 0;

/**
* @brief Get interpolated value of element at index i.
Expand All @@ -230,7 +230,7 @@ class PolyInterface : public ILElement<DerivedType, VecType> {
return this->GetDerived()[i];
}

const Integer& operator[](usint i) const override {
Integer operator[](usint i) const override {
return this->GetDerived()[i];
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/include/lattice/ilelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ILElement : public Serializable {
*
* @return the modulus.
*/
virtual const IntType& GetModulus() const = 0;
virtual IntType GetModulus() const = 0;

/**
* @brief Get the values for the element
Expand All @@ -155,13 +155,13 @@ class ILElement : public Serializable {
virtual IntType& at(usint i) {
OPENFHE_THROW("at() not implemented");
}
virtual const IntType& at(usint i) const {
virtual IntType at(usint i) const {
OPENFHE_THROW("const at() not implemented");
}
virtual IntType& operator[](usint i) {
OPENFHE_THROW("[] not implemented");
}
virtual const IntType& operator[](usint i) const {
virtual IntType operator[](usint i) const {
OPENFHE_THROW("const [] not implemented");
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/include/math/hal/bigintdyn/mubintvecdyn.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class mubintvec final : public lbcrypto::BigVectorInterface<mubintvec<ubint_el_t
return m_data[i];
}

const ubint_el_t& at(size_t i) const {
ubint_el_t at(size_t i) const {
if (!mubintvec::IndexCheck(i))
OPENFHE_THROW("index out of range");
return m_data[i];
Expand All @@ -252,7 +252,7 @@ class mubintvec final : public lbcrypto::BigVectorInterface<mubintvec<ubint_el_t
return m_data[i];
}

const ubint_el_t& operator[](size_t i) const {
ubint_el_t operator[](size_t i) const {
return m_data[i];
}

Expand Down Expand Up @@ -326,7 +326,7 @@ class mubintvec final : public lbcrypto::BigVectorInterface<mubintvec<ubint_el_t
*
* @return the vector modulus.
*/
const ubint_el_t& GetModulus() const {
ubint_el_t GetModulus() const {
if (m_modulus_state != State::INITIALIZED)
OPENFHE_THROW("GetModulus() on uninitialized mubintvec");
return m_modulus;
Expand Down
6 changes: 3 additions & 3 deletions src/core/include/math/hal/bigintfxd/mubintvecfxd.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class BigVectorFixedT final : public lbcrypto::BigVectorInterface<BigVectorFixed
return this->m_data[i];
}

const IntegerType& at(size_t i) const {
IntegerType at(size_t i) const {
if (!this->IndexCheck(i)) {
OPENFHE_THROW("BigVector index out of range");
}
Expand All @@ -214,7 +214,7 @@ class BigVectorFixedT final : public lbcrypto::BigVectorInterface<BigVectorFixed
return (this->m_data[idx]);
}

const IntegerType& operator[](size_t idx) const {
IntegerType operator[](size_t idx) const {
return (this->m_data[idx]);
}

Expand Down Expand Up @@ -243,7 +243,7 @@ class BigVectorFixedT final : public lbcrypto::BigVectorInterface<BigVectorFixed
*
* @return the vector modulus.
*/
const IntegerType& GetModulus() const {
IntegerType GetModulus() const {
return this->m_modulus;
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/include/math/hal/bigintntl/mubintvecntl.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ class myVecP : public NTL::Vec<myT>,
return this->NTL::Vec<myT>::at(i);
}

const myT& at(size_t i) const {
myT at(size_t i) const {
return this->NTL::Vec<myT>::at(i);
}

myT& operator[](size_t idx) {
return this->at(idx);
}

const myT& operator[](size_t idx) const {
myT operator[](size_t idx) const {
return this->at(idx);
}

Expand Down Expand Up @@ -230,7 +230,7 @@ class myVecP : public NTL::Vec<myT>,
this->m_modulus_state = INITIALIZED;
}

const myT& GetModulus() const {
myT GetModulus() const {
if (this->isModulusSet()) {
return (this->m_modulus);
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/include/math/hal/intnat/mubintvecnat.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class NativeVectorT final : public lbcrypto::BigVectorInterface<NativeVectorT<In
return m_data[i];
}

const IntegerType& at(size_t i) const {
IntegerType at(size_t i) const {
if (!NativeVectorT::IndexCheck(i))
OPENFHE_THROW("NativeVectorT index out of range");
return m_data[i];
Expand All @@ -298,7 +298,7 @@ class NativeVectorT final : public lbcrypto::BigVectorInterface<NativeVectorT<In
return m_data[idx];
}

const IntegerType& operator[](size_t idx) const {
IntegerType operator[](size_t idx) const {
return m_data[idx];
}

Expand Down Expand Up @@ -332,7 +332,7 @@ class NativeVectorT final : public lbcrypto::BigVectorInterface<NativeVectorT<In
*
* @return the vector modulus.
*/
const IntegerType& GetModulus() const {
IntegerType GetModulus() const {
return m_modulus;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/include/math/hal/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class BigVectorInterface {

// The derived class must implement at and operator[]
I& at(size_t idx);
const I& at(size_t idx) const;
I at(size_t idx) const;
I& operator[](size_t idx);
const I& operator[](size_t idx) const;

Expand All @@ -157,7 +157,7 @@ class BigVectorInterface {
*
* @return the vector modulus.
*/
const I& GetModulus() const;
I GetModulus() const;

/**
* Gets the vector length.
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/math/nbtheory-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool MillerRabinPrimalityTest(const IntType& p, const usint niter) {
Output: a factor of n.
*/
template <typename IntType>
const IntType PollardRhoFactorization(const IntType& n) {
IntType PollardRhoFactorization(const IntType& n) {
if (n.Mod(IntType(2)) == IntType(0))
return IntType(2);
IntType divisor(1);
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/math/nbtheory.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ bool MillerRabinPrimalityTest(const IntType& p, const usint niter = 100);
* @return a factor of n, and IntType::ONE if no other factor is found.
*/
template <typename IntType>
const IntType PollardRhoFactorization(const IntType& n);
IntType PollardRhoFactorization(const IntType& n);

/**
* Recursively factorizes to find the distinct primefactors of a number.
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/math/hal/bigintdyn/be4-math-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template M4Integer RootOfUnity<M4Integer>(usint m, const M4Integer& modulo);
template std::vector<M4Integer> RootsOfUnity(usint m, const std::vector<M4Integer>& moduli);
template M4Integer GreatestCommonDivisor(const M4Integer& a, const M4Integer& b);
template bool MillerRabinPrimalityTest(const M4Integer& p, const usint niter);
template const M4Integer PollardRhoFactorization(const M4Integer& n);
template M4Integer PollardRhoFactorization(const M4Integer& n);
template void PrimeFactorize(M4Integer n, std::set<M4Integer>& primeFactors);
template M4Integer FirstPrime(uint32_t nBits, uint64_t m);
template M4Integer LastPrime(uint32_t nBits, uint64_t m);
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/math/hal/bigintfxd/be2-math-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ template M2Integer RootOfUnity<M2Integer>(usint m, const M2Integer& modulo);
template std::vector<M2Integer> RootsOfUnity(usint m, const std::vector<M2Integer>& moduli);
template M2Integer GreatestCommonDivisor(const M2Integer& a, const M2Integer& b);
template bool MillerRabinPrimalityTest(const M2Integer& p, const usint niter);
template const M2Integer PollardRhoFactorization(const M2Integer& n);
template M2Integer PollardRhoFactorization(const M2Integer& n);
template void PrimeFactorize(M2Integer n, std::set<M2Integer>& primeFactors);
template M2Integer FirstPrime(uint32_t nBits, uint64_t m);
template M2Integer LastPrime(uint32_t nBits, uint64_t m);
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/math/hal/bigintntl/be6-math-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ template M6Integer RootOfUnity<M6Integer>(usint m, const M6Integer& modulo);
template std::vector<M6Integer> RootsOfUnity(usint m, const std::vector<M6Integer>& moduli);
template M6Integer GreatestCommonDivisor(const M6Integer& a, const M6Integer& b);
template bool MillerRabinPrimalityTest(const M6Integer& p, const usint niter);
template const M6Integer PollardRhoFactorization(const M6Integer& n);
template M6Integer PollardRhoFactorization(const M6Integer& n);
template void PrimeFactorize(M6Integer n, std::set<M6Integer>& primeFactors);
template M6Integer FirstPrime(uint32_t nBits, uint64_t m);
template M6Integer LastPrime(uint32_t nBits, uint64_t m);
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib/math/hal/intnat/benative-math-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ template NativeInteger RootOfUnity<NativeInteger>(usint m, const NativeInteger&
template std::vector<NativeInteger> RootsOfUnity(usint m, const std::vector<NativeInteger>& moduli);
template NativeInteger GreatestCommonDivisor(const NativeInteger& a, const NativeInteger& b);
template bool MillerRabinPrimalityTest(const NativeInteger& p, const usint niter);
template const NativeInteger PollardRhoFactorization(const NativeInteger& n);
template NativeInteger PollardRhoFactorization(const NativeInteger& n);
template void PrimeFactorize(NativeInteger n, std::set<NativeInteger>& primeFactors);
template NativeInteger FirstPrime(uint32_t nBits, uint64_t m);
template NativeInteger LastPrime(uint32_t nBits, uint64_t m);
Expand Down
4 changes: 2 additions & 2 deletions src/pke/include/cryptocontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1035,15 +1035,15 @@ class CryptoContextImpl : public Serializable {
* @brief Getter for ciphertext modulus
* @return modulus
*/
const IntType& GetModulus() const {
IntType GetModulus() const {
return m_params->GetElementParams()->GetModulus();
}

/**
* @brief Getter for root of unity
* @return RootOfUnity
*/
const IntType& GetRootOfUnity() const {
IntType GetRootOfUnity() const {
return m_params->GetElementParams()->GetRootOfUnity();
}

Expand Down
Loading