Template Class DCRTPolyImpl

Inheritance Relationships

Base Type

Template Parameter Order

  1. typename VecType

Class Documentation

template<typename VecType>
class lbcrypto::DCRTPolyImpl : public lbcrypto::DCRTPolyInterface<DCRTPolyImpl<VecType>, VecType, NativeVector, PolyImpl>

Inheritence diagram for lbcrypto::DCRTPolyImpl:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="lbcrypto::DCRTPolyImpl< VecType >" tooltip="lbcrypto::DCRTPolyImpl< VecType >" fillcolor="#BFBFBF"] "2" [label="lbcrypto::DCRTPolyInterface< DCRTPolyImpl< VecType >, VecType, NativeVector, PolyImpl >" tooltip="lbcrypto::DCRTPolyInterface< DCRTPolyImpl< VecType >, VecType, NativeVector, PolyImpl >"] "4" [label="lbcrypto::Serializable" tooltip="lbcrypto::Serializable"] "3" [label="lbcrypto::ILElement< DCRTPolyImpl< VecType >, VecType >" tooltip="lbcrypto::ILElement< DCRTPolyImpl< VecType >, VecType >"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "2" -> "3" [dir=forward tooltip="public-inheritance"] "3" -> "4" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for lbcrypto::DCRTPolyImpl:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="lbcrypto::DCRTPolyImpl< VecType >" tooltip="lbcrypto::DCRTPolyImpl< VecType >" fillcolor="#BFBFBF"] "2" [label="lbcrypto::DCRTPolyInterface< DCRTPolyImpl< VecType >, VecType, NativeVector, PolyImpl >" tooltip="lbcrypto::DCRTPolyInterface< DCRTPolyImpl< VecType >, VecType, NativeVector, PolyImpl >"] "4" [label="lbcrypto::Serializable" tooltip="lbcrypto::Serializable"] "3" [label="lbcrypto::ILElement< DCRTPolyImpl< VecType >, VecType >" tooltip="lbcrypto::ILElement< DCRTPolyImpl< VecType >, VecType >"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "2" -> "3" [dir=forward tooltip="public-inheritance"] "3" -> "4" [dir=forward tooltip="public-inheritance"] }

Public Types

using Vector = VecType
using Integer = typename VecType::Integer
using Params = ILDCRTParams<Integer>
using PolyType = PolyImpl<NativeVector>
using PolyLargeType = PolyImpl<VecType>
using DCRTPolyType = DCRTPolyImpl<VecType>
using DCRTPolyInterfaceType = DCRTPolyInterface<DCRTPolyImpl<VecType>, VecType, NativeVector, PolyImpl>
using Precomputations = typename DCRTPolyInterfaceType::CRTBasisExtensionPrecomputations
using DggType = typename DCRTPolyInterfaceType::DggType
using DugType = typename DCRTPolyInterfaceType::DugType
using TugType = typename DCRTPolyInterfaceType::TugType
using BugType = typename DCRTPolyInterfaceType::BugType

Public Functions

DCRTPolyImpl() = default
inline DCRTPolyImpl(const DCRTPolyType &e) noexcept
inline virtual DCRTPolyType &operator=(const DCRTPolyType &rhs) noexcept override

Assignment Operator.

Parameters

&rhs – the copied element.

Returns

the resulting element.

DCRTPolyImpl(const PolyLargeType &e, const std::shared_ptr<Params> &params) noexcept
DCRTPolyType &operator=(const PolyLargeType &rhs) noexcept
DCRTPolyImpl(const PolyType &e, const std::shared_ptr<Params> &params) noexcept
DCRTPolyType &operator=(const PolyType &rhs) noexcept
inline DCRTPolyImpl(DCRTPolyType &&e) noexcept
inline virtual DCRTPolyType &operator=(DCRTPolyType &&rhs) noexcept override

Move Assignment Operator.

Parameters

&rhs – the copied element.

Returns

the resulting element.

explicit DCRTPolyImpl(const std::vector<PolyType> &elements)
inline DCRTPolyImpl(const std::shared_ptr<Params> &params, Format format = Format::EVALUATION, bool initializeElementToZero = false) noexcept
DCRTPolyImpl(const DggType &dgg, const std::shared_ptr<Params> &p, Format f = Format::EVALUATION)
DCRTPolyImpl(const BugType &bug, const std::shared_ptr<Params> &p, Format f = Format::EVALUATION)
DCRTPolyImpl(const TugType &tug, const std::shared_ptr<Params> &p, Format f = Format::EVALUATION, uint32_t h = 0)
DCRTPolyImpl(DugType &dug, const std::shared_ptr<Params> &p, Format f = Format::EVALUATION)
virtual DCRTPolyType &operator=(std::initializer_list<uint64_t> rhs) noexcept override

Initalizer list.

Parameters

&rhs – the list to initalized the element.

Returns

the resulting element.

DCRTPolyType &operator=(uint64_t val) noexcept
DCRTPolyType &operator=(const std::vector<int64_t> &rhs) noexcept
DCRTPolyType &operator=(const std::vector<int32_t> &rhs) noexcept
DCRTPolyType &operator=(std::initializer_list<std::string> rhs) noexcept
virtual DCRTPolyType CloneWithNoise(const DiscreteGaussianGeneratorImpl<VecType> &dgg, Format format) const override

Clone with noise. This method creates a new DCRTPoly and clones the params. The tower values will be filled up with noise based on the discrete gaussian.

Parameters
  • &dgg – the input discrete Gaussian generator. The dgg will be the seed to populate the towers of the DCRTPoly with random numbers.

  • format – the input format fixed to EVALUATION. Format is a enum type that indicates if the polynomial is in Evaluation representation or Coefficient representation. It is defined in inttypes.h.

DCRTPolyType CloneTowers(uint32_t startTower, uint32_t endTower) const
virtual bool operator==(const DCRTPolyType &rhs) const override

Equality operator.

Parameters

&rhs – is the specified element to be compared with this element.

Returns

true if this element represents the same values as the specified element, false otherwise.

virtual DCRTPolyType &operator+=(const DCRTPolyType &rhs) override

Performs an entry-wise addition over all elements of each tower with the towers of the element on the right hand side.

Parameters

&rhs – is the element to add with.

Returns

is the result of the addition.

virtual DCRTPolyType &operator+=(const Integer &rhs) override

Performs += operation with a BigInteger and returns the result.

Parameters

&element – is the element to add

Returns

is the result of the addition.

DCRTPolyType &operator+=(const NativeInteger &rhs) override
virtual DCRTPolyType &operator-=(const DCRTPolyType &rhs) override

Performs an entry-wise subtraction over all elements of each tower with the towers of the element on the right hand side.

Parameters

&rhs – is the element to subtract from.

Returns

is the result of the addition.

virtual DCRTPolyType &operator-=(const Integer &rhs) override

Performs -= operation with a BigInteger and returns the result.

Parameters

&element – is the element to subtract

Returns

is the result of the addition.

DCRTPolyType &operator-=(const NativeInteger &rhs) override
inline virtual DCRTPolyType &operator*=(const DCRTPolyType &rhs) override

Performs a multiplication operation and returns the result.

Parameters

&element – is the element to multiply with.

Returns

is the result of the multiplication.

virtual DCRTPolyType &operator*=(const Integer &rhs) override

Performs *= operation with a BigInteger and returns the result.

Parameters

&element – is the element to multiply by

Returns

is the result of the multiplication.

DCRTPolyType &operator*=(const NativeInteger &rhs) override
virtual DCRTPolyType Negate() const override

Performs a negation operation and returns the result.

Returns

is the result of the negation.

virtual DCRTPolyType operator-() const override

Unary minus on a element.

Returns

additive inverse of the an element.

virtual std::vector<DCRTPolyType> BaseDecompose(usint baseBits, bool evalModeAnswer) const override

Write the element as \sum\limits{i=0}^{\lfloor {\log q/base} \rfloor} {(base^i u_i)} and return the vector of \left\{u_0, u_1,...,u_{\lfloor {\log q/base} \rfloor} \right\} \in R_{{base}^{\lceil {\log q/base} \rceil}}; This is used as a subroutine in the relinearization procedure.

Warning

not efficient and not fast, uses multiprecision arithmetic and will be removed in future. Use

Parameters

baseBits – is the number of bits in the base, i.e., base = 2^{baseBits}.

Returns

is the pointer where the base decomposition vector is stored

virtual std::vector<DCRTPolyType> PowersOfBase(usint baseBits) const override

Generate a vector of PolyImpl’s as \left\{x, {base}*x, {base}^2*x, ..., {base}^{\lfloor {\log q/{base}} \rfloor} \right\}*x, where x is the current PolyImpl object; used as a subroutine in the relinearization procedure to get powers of a certain “base” for the secret key element.

Warning

not efficient and not fast, uses multiprecision arithmetic and will be removed in future. Use

Parameters

baseBits – is the number of bits in the base, i.e., base = 2^{baseBits}.

Returns

is the pointer where the base decomposition vector is stored

std::vector<DCRTPolyType> CRTDecompose(uint32_t baseBits) const
virtual DCRTPolyType AutomorphismTransform(uint32_t i) const override

Permutes coefficients in a polynomial. Moves the ith index to the first one, it only supports odd indices.

Parameters

&i – is the element to perform the automorphism transform with.

Returns

is the result of the automorphism transform.

virtual DCRTPolyType AutomorphismTransform(uint32_t i, const std::vector<uint32_t> &vec) const override

Performs an automorphism transform operation using precomputed bit reversal indices.

Parameters
  • &i – is the element to perform the automorphism transform with.

  • &vec – a vector with precomputed indices

Returns

is the result of the automorphism transform.

virtual DCRTPolyType Plus(const Integer &rhs) const override

Scalar addition - add an element to the first index only. This operation is only allowed in COEFFICIENT format.

Parameters

&element – is the element to add entry-wise.

Returns

is the return of the addition operation.

DCRTPolyType Plus(const std::vector<Integer> &rhs) const
inline virtual DCRTPolyType Plus(const DCRTPolyType &rhs) const override

Performs an addition operation and returns the result.

Parameters

&element – is the element to add with.

Returns

is the result of the addition.

virtual DCRTPolyType Minus(const DCRTPolyType &rhs) const override

Performs a subtraction operation and returns the result.

Parameters

&element – is the element to subtract from.

Returns

is the result of the subtraction.

virtual DCRTPolyType Minus(const Integer &rhs) const override

Scalar subtraction - subtract an element frp, all entries.

Parameters

&element – is the element to subtract entry-wise.

Returns

is the return value of the minus operation.

DCRTPolyType Minus(const std::vector<Integer> &rhs) const
inline virtual DCRTPolyType Times(const DCRTPolyType &rhs) const override

Performs a multiplication operation and returns the result.

Parameters

&element – is the element to multiply with.

Returns

is the result of the multiplication.

virtual DCRTPolyType Times(const Integer &rhs) const override

Scalar multiplication - multiply all entries.

Parameters

&element – is the element to multiply entry-wise.

Returns

is the return value of the times operation.

DCRTPolyType Times(const std::vector<Integer> &rhs) const
virtual DCRTPolyType Times(NativeInteger::SignedNativeInt rhs) const override

Scalar multiplication - multiply by a signed integer.

Parameters

&element – is the element to multiply entry-wise.

Returns

is the return value of the times operation.

inline DCRTPolyType Times(int64_t rhs) const
DCRTPolyType Times(const std::vector<NativeInteger> &rhs) const
DCRTPolyType TimesNoCheck(const std::vector<NativeInteger> &rhs) const
virtual DCRTPolyType MultiplicativeInverse() const override

Performs a multiplicative inverse operation and returns the result.

Returns

is the result of the multiplicative inverse.

virtual bool InverseExists() const override

Determines if inverse exists.

Returns

is the Boolean representation of the existence of multiplicative inverse.

virtual bool IsEmpty() const override

Returns true if ALL the tower(s) are empty.

Returns

true if all towers are empty

virtual void SetValuesToZero() override

Sets all values of element to zero.

virtual void AddILElementOne() override

Adds “1” to every entry in every tower.

virtual void DropLastElement() override

Drops the last element in the double-CRT representation. The resulting DCRTPoly element will have one less tower.

virtual void DropLastElements(size_t i) override

Drops the last i elements in the double-CRT representation.

virtual void DropLastElementAndScale(const std::vector<NativeInteger> &QlQlInvModqlDivqlModq, const std::vector<NativeInteger> &qlInvModq) override

Drops the last element in the double-CRT representation and scales down by the last CRT modulus. The resulting DCRTPoly element will have one less tower.

Parameters
  • &QlQlInvModqlDivqlModq – precomputed values for [Q^(l)*[Q^(l)^{-1}]_{q_l}/q_l]_{q_i}

  • &QlQlInvModqlDivqlModqPrecon – NTL-specific precomputations

  • &qlInvModq – precomputed values for [q_l^{-1}]_{q_i}

  • &qlInvModqPrecon – NTL-specific precomputations

virtual void ModReduce(const NativeInteger &t, const std::vector<NativeInteger> &tModqPrecon, const NativeInteger &negtInvModq, const NativeInteger &negtInvModqPrecon, const std::vector<NativeInteger> &qlInvModq, const std::vector<NativeInteger> &qlInvModqPrecon) override

Used for BGVrns modulus switching This function performs ModReduce on ciphertext element and private key element. The algorithm computes ct’ <- round( ct/qt ).

Modulus reduction reduces a ciphertext from modulus q to a smaller modulus q/qt where qt is generally the last moduli of the tower. ModReduce is written for DCRTPolyImpl and it drops the last tower while updating the necessary parameters.

The rounding is actually computed as a flooring by computing delta such that delta = -ct mod qt and delta = 0 [t]

The steps taken here are as follows:

  1. compute delta <- -ct/ptm mod qt

  2. compute delta <- ptm*delta in Z. E.g., all of delta’s integer coefficients can be in the range [-ptm*qt/2, ptm*qt/2).

  3. let d’ = c + delta mod q/qt. By construction, d’ is divisible by qt and congruent to 0 mod ptm.

  4. output (d’/q’) in R(q/q’).

virtual PolyLargeType CRTInterpolate() const override

Interpolates the DCRTPoly to a Poly based on the Chinese Remainder Transform Interpolation. and then returns a Poly with that single element.

Returns

the interpolated ring element as a Poly object.

virtual PolyType DecryptionCRTInterpolate(PlaintextModulus ptm) const override
virtual PolyType ToNativePoly() const override

If the values are small enough this is used for efficiency.

Warning

This will be replaced with a non-member utility function.

Returns

NativePoly

virtual PolyLargeType CRTInterpolateIndex(usint i) const override

Interpolates the DCRTPoly to a Poly based on the Chinese Remainder Transform Interpolation, only at element index i, all other elements are zero. and then returns a Poly with that single element.

Returns

the interpolated ring element as a Poly object.

virtual Integer GetWorkingModulus() const override

Computes and returns the product of primes in the current moduli chain. Compared to GetModulus, which always returns the product of all primes in the crypto parameters, this method will return a different modulus, based on the towers/moduli that are currently in the chain (some towers are dropped along the way).

Returns

the product of moduli in the current towers.

virtual void SetValuesModSwitch(const DCRTPolyType &element, const NativeInteger &modulus) override

Sets values with a different modulus.

std::shared_ptr<Params> GetExtendedCRTBasis(const std::shared_ptr<Params> &paramsP) const override
void TimesQovert(const std::shared_ptr<Params> &paramsQ, const std::vector<NativeInteger> &tInvModq, const NativeInteger &t, const NativeInteger &NegQModt, const NativeInteger &NegQModtPrecon) override
DCRTPolyType ApproxSwitchCRTBasis(const std::shared_ptr<Params> &paramsQ, const std::shared_ptr<Params> &paramsP, const std::vector<NativeInteger> &QHatInvModq, const std::vector<NativeInteger> &QHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModp, const std::vector<DoubleNativeInt> &modpBarrettMu) const override
void ApproxModUp(const std::shared_ptr<Params> &paramsQ, const std::shared_ptr<Params> &paramsP, const std::shared_ptr<Params> &paramsQP, const std::vector<NativeInteger> &QHatInvModq, const std::vector<NativeInteger> &QHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModp, const std::vector<DoubleNativeInt> &modpBarrettMu) override
DCRTPolyType ApproxModDown(const std::shared_ptr<Params> &paramsQ, const std::shared_ptr<Params> &paramsP, const std::vector<NativeInteger> &PInvModq, const std::vector<NativeInteger> &PInvModqPrecon, const std::vector<NativeInteger> &PHatInvModp, const std::vector<NativeInteger> &PHatInvModpPrecon, const std::vector<std::vector<NativeInteger>> &PHatModq, const std::vector<DoubleNativeInt> &modqBarrettMu, const std::vector<NativeInteger> &tInvModp, const std::vector<NativeInteger> &tInvModpPrecon, const NativeInteger &t, const std::vector<NativeInteger> &tModqPrecon) const override
DCRTPolyType SwitchCRTBasis(const std::shared_ptr<Params> &paramsP, const std::vector<NativeInteger> &QHatInvModq, const std::vector<NativeInteger> &QHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModp, const std::vector<std::vector<NativeInteger>> &alphaQModp, const std::vector<DoubleNativeInt> &modpBarrettMu, const std::vector<double> &qInv) const override
void ExpandCRTBasis(const std::shared_ptr<Params> &paramsQP, const std::shared_ptr<Params> &paramsP, const std::vector<NativeInteger> &QHatInvModq, const std::vector<NativeInteger> &QHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModp, const std::vector<std::vector<NativeInteger>> &alphaQModp, const std::vector<DoubleNativeInt> &modpBarrettMu, const std::vector<double> &qInv, Format resultFormat) override
void ExpandCRTBasisReverseOrder(const std::shared_ptr<Params> &paramsQP, const std::shared_ptr<Params> &paramsP, const std::vector<NativeInteger> &QHatInvModq, const std::vector<NativeInteger> &QHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModp, const std::vector<std::vector<NativeInteger>> &alphaQModp, const std::vector<DoubleNativeInt> &modpBarrettMu, const std::vector<double> &qInv, Format resultFormat) override
void FastExpandCRTBasisPloverQ(const Precomputations &precomputed) override
void ExpandCRTBasisQlHat(const std::shared_ptr<Params> &paramsQ, const std::vector<NativeInteger> &QlHatModq, const std::vector<NativeInteger> &QlHatModqPrecon, const usint sizeQ) override
virtual PolyType ScaleAndRound(const NativeInteger &t, const std::vector<NativeInteger> &tQHatInvModqDivqModt, const std::vector<NativeInteger> &tQHatInvModqDivqModtPrecon, const std::vector<NativeInteger> &tQHatInvModqBDivqModt, const std::vector<NativeInteger> &tQHatInvModqBDivqModtPrecon, const std::vector<double> &tQHatInvModqDivqFrac, const std::vector<double> &tQHatInvModqBDivqFrac) const override

Performs scale and round: {X}_{Q} -> {\round(t/Q*X)}_t {Q} = {q_1,…,q_l} {P} = {p_1,…,p_k}.

Brief algorithm: [\sum_i x_i*[t*QHatInv_i/q_i]_t + Round(\sum_i x_i*{t*QHatInv_i/q_i})]_t

Source: Halevi S., Polyakov Y., and Shoup V. An Improved RNS Variant of the BFV Homomorphic Encryption Scheme. Cryptology ePrint Archive, Report 2018/117. (https://eprint.iacr.org/2018/117)

Parameters
  • &t – often corresponds to the plaintext modulus

  • &tQHatInvModqDivqModt – precomputed values for [Floor{t*QHatInv_i/q_i}]_t

  • &tQHatInvModqDivqModtPrecon – NTL-specific precomputations

  • &tQHatInvModqBDivqModt – precomputed values for [Floor{t*QHatInv_i*B/q_i}]_t used when CRT moduli are 45..60 bits long

  • &tQHatInvBDivqModtPrecon – NTL-specific precomputations used when CRT moduli are 45..60 bits long

  • &tQHatInvModqDivqFrac – precomputed values for Frac{t*QHatInv_i/q_i}

  • &tQHatInvBDivqFrac – precomputed values for Frac{t*QHatInv_i*B/q_i} used when CRT moduli are 45..60 bits long

Returns

the result of computation as a polynomial with native 64-bit coefficients

DCRTPolyType ApproxScaleAndRound(const std::shared_ptr<Params> &paramsP, const std::vector<std::vector<NativeInteger>> &tPSHatInvModsDivsModp, const std::vector<DoubleNativeInt> &modpBarretMu) const override
DCRTPolyType ScaleAndRound(const std::shared_ptr<Params> &paramsOutput, const std::vector<std::vector<NativeInteger>> &tOSHatInvModsDivsModo, const std::vector<double> &tOSHatInvModsDivsFrac, const std::vector<DoubleNativeInt> &modoBarretMu) const override
virtual PolyType ScaleAndRound(const std::vector<NativeInteger> &moduliQ, const NativeInteger &t, const NativeInteger &tgamma, const std::vector<NativeInteger> &tgammaQHatModq, const std::vector<NativeInteger> &tgammaQHatModqPrecon, const std::vector<NativeInteger> &negInvqModtgamma, const std::vector<NativeInteger> &negInvqModtgammaPrecon) const override

Computes scale and round for fast rounding: {X}_{Q} -> {\round(t/Q * X)}_t {Q} = {q_1,…,q_l}.

Brief algorithm:

Source: Jean-Claude Bajard and Julien Eynard and Anwar Hasan and Vincent Zucca. A Full RNS Variant of FV like Somewhat Homomorphic Encryption Schemes. Cryptology ePrint Archive: Report 2016/510. (https://eprint.iacr.org/2016/510)

Parameters
  • &moduliQ – moduli {q_1,…,q_l}

  • &t – often corresponds to the plaintext modulus

  • &tgamma – t * gamma : t * 2^26 reduction

  • &tgammaQHatModq – [t*gamma*(Q/q_i)]_{q_i}

  • &tgammaQHatModqPrecon – NTL-specific precomputations

  • &negInvqModtgamma – [-q^{-1}]_{t*gamma}

  • &negInvqModtgammaPrecon – NTL-specific precomputations

Returns

void ScaleAndRoundPOverQ(const std::shared_ptr<Params> &paramsQ, const std::vector<NativeInteger> &pInvModq) override
void FastBaseConvqToBskMontgomery(const std::shared_ptr<Params> &paramsQBsk, const std::vector<NativeInteger> &moduliQ, const std::vector<NativeInteger> &moduliBsk, const std::vector<DoubleNativeInt> &modbskBarrettMu, const std::vector<NativeInteger> &mtildeQHatInvModq, const std::vector<NativeInteger> &mtildeQHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModbsk, const std::vector<uint64_t> &QHatModmtilde, const std::vector<NativeInteger> &QModbsk, const std::vector<NativeInteger> &QModbskPrecon, const uint64_t &negQInvModmtilde, const std::vector<NativeInteger> &mtildeInvModbsk, const std::vector<NativeInteger> &mtildeInvModbskPrecon) override
virtual void FastRNSFloorq(const NativeInteger &t, const std::vector<NativeInteger> &moduliQ, const std::vector<NativeInteger> &moduliBsk, const std::vector<DoubleNativeInt> &modbskBarrettMu, const std::vector<NativeInteger> &tQHatInvModq, const std::vector<NativeInteger> &tQHatInvModqPrecon, const std::vector<std::vector<NativeInteger>> &QHatModbsk, const std::vector<std::vector<NativeInteger>> &qInvModbsk, const std::vector<NativeInteger> &tQInvModbsk, const std::vector<NativeInteger> &tQInvModbskPrecon) override

Computes scale and floor: {X}_{Q,Bsk} -> {\floor{t/Q * X}}_{Bsk} {Q} = {q_1,…,q_l} {Bsk} = {bsk_1,…,bsk_k} Outputs the resulting polynomial in CRT/RNS.

Source: Jean-Claude Bajard and Julien Eynard and Anwar Hasan and Vincent Zucca. A Full RNS Variant of FV like Somewhat Homomorphic Encryption Schemes. Cryptology ePrint Archive: Report 2016/510. (https://eprint.iacr.org/2016/510)

Parameters
  • &t – plaintext modulus

  • &moduliQ – {Q} = {q_1,…,q_l}

  • &moduliBsk – {Bsk} = {bsk_1,…,bsk_k}

  • &modbskBarrettMu – 128-bit Barrett reduction precomputed values for bsk_j

  • &tQHatInvModq – [(Q/q_i)^{-1}]_{q_i}

  • &tQHatInvModqPrecon – NTL-specific precomputations

  • &QHatModbsk – [Q/q_i]_{bsk_i}

  • &qInvModbsk – [(q_i)^{-1}]_{bsk_j}

  • &tQInvModbsk – [t*Q^{-1}]_{bsk_j}

  • &tQInvModbskPrecon – NTL-specific precomputations

void FastBaseConvSK(const std::shared_ptr<Params> &paramsQ, const std::vector<DoubleNativeInt> &modqBarrettMu, const std::vector<NativeInteger> &moduliBsk, const std::vector<DoubleNativeInt> &modbskBarrettMu, const std::vector<NativeInteger> &BHatInvModb, const std::vector<NativeInteger> &BHatInvModbPrecon, const std::vector<NativeInteger> &BHatModmsk, const NativeInteger &BInvModmsk, const NativeInteger &BInvModmskPrecon, const std::vector<std::vector<NativeInteger>> &BHatModq, const std::vector<NativeInteger> &BModq, const std::vector<NativeInteger> &BModqPrecon) override
virtual void SwitchFormat() override

Convert from Coefficient to CRT or vice versa; calls FFT and inverse FFT.

See also

SetFormat(format) instead

Warning

use

void SwitchModulusAtIndex(size_t index, const Integer &modulus, const Integer &rootOfUnity) override
template<class Archive>
inline void save(Archive &ar, std::uint32_t const version) const
template<class Archive>
inline void load(Archive &ar, std::uint32_t const version)
inline virtual std::string SerializedObjectName() const override
inline virtual Format GetFormat() const final

Get method of the format.

Returns

the format, either COEFFICIENT or EVALUATION

inline virtual void OverrideFormat(const Format f) final

Sets format to value without performing NTT. Only use if you know what you’re doing.

inline const std::shared_ptr<Params> &GetParams() const
inline const std::vector<PolyType> &GetAllElements() const
inline std::vector<PolyType> &GetAllElements()
inline void SetElementAtIndex(usint index, const PolyType &element)
inline void SetElementAtIndex(usint index, PolyType &&element)

Public Static Functions

static inline const std::string GetElementName()
static inline uint32_t SerializedVersion()

Protected Attributes

std::shared_ptr<Params> m_params = {std::make_shared<DCRTPolyImpl::Params>()}
Format m_format = {Format::EVALUATION}
std::vector<PolyType> m_vectors