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

280 andrey depth limitations hps #392

Closed
wants to merge 4 commits into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 30 additions & 7 deletions src/core/include/lattice/hal/dcrtpoly-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1095,12 +1095,35 @@ class DCRTPolyInterface : public ILElement<DerivedType, BigVecType> {
* @return the result of computation as a polynomial with native 64-bit
* coefficients
*/
virtual TowerType 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 = 0;
virtual TowerType ScaleAndRound(const NativeInteger& t,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModt,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModtPrecon,
const std::vector<std::vector<double>>& tQHatInvModqDivqFrac) const = 0;

/**
* @brief 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)
*
* @param &t often corresponds to the plaintext modulus
* @param &tQHatInvModqDivqModt precomputed values for [Floor{t*QHatInv_i*B^d/q_i}]_t
* @param &tQHatInvModqDivqModtPrecon NTL-specific precomputations
* @param &tQHatInvModqDivqMantissa precomputed values for Frac{t*QHatInv_i*B^d/q_i} * 2^54
* @return the result of computation as a polynomial with native 64-bit
* coefficients
*/
virtual TowerType ScaleAndRound(const NativeInteger& t, const NativeInteger& tInvMantissa,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModt,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModtPrecon,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqMantissa) const = 0;

/**
* @brief Computes approximate scale and round:
Expand Down Expand Up @@ -1156,7 +1179,7 @@ class DCRTPolyInterface : public ILElement<DerivedType, BigVecType> {
*/
virtual DerivedType ScaleAndRound(const std::shared_ptr<Params> paramsOutput,
const std::vector<std::vector<NativeInteger>>& tOSHatInvModsDivsModo,
const std::vector<double>& tOSHatInvModsDivsFrac,
const std::vector<NativeInteger>& tOSHatInvModsDivsFrac,
const std::vector<DoubleNativeInt>& modoBarretMu) const = 0;

/**
Expand Down
39 changes: 32 additions & 7 deletions src/core/include/lattice/hal/default/dcrtpoly.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@

namespace lbcrypto {

// Double Precision
const int32_t DOUBLE_PRECISION = 54;

/**
* @brief Ideal lattice for the double-CRT representation.
* The implementation contains a vector of underlying native-integer lattices
Expand Down Expand Up @@ -1072,12 +1075,34 @@ class DCRTPolyImpl : public DCRTPolyInterface<DCRTPolyImpl<VecType>, VecType, Na
* @return the result of computation as a polynomial with native 64-bit
* coefficients
*/
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;
PolyType ScaleAndRound(const NativeInteger& t, const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModt,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModtPrecon,
const std::vector<std::vector<double>>& tQHatInvModqDivqFrac) const override;

/**
* @brief 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*B^i/q_i]_t + Round(\sum_i x_i*{t*QHatInv_i*B^d/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)
*
* @param &t often corresponds to the plaintext modulus
* @param &tQHatInvModqDivqModt precomputed values for [Floor{t*QHatInv_i*B^d/q_i}]_t
* @param &tQHatInvModqDivqModtPrecon NTL-specific precomputations
* @param &tQHatInvModqDivqMantissa precomputed values for Frac{t*QHatInv_i*B^d/q_i} * 2^54
* @return the result of computation as a polynomial with native 64-bit
* coefficients
*/
PolyType ScaleAndRound(const NativeInteger& t, const NativeInteger& tInvMantissa,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModt,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqModtPrecon,
const std::vector<std::vector<NativeInteger>>& tQHatInvModqDivqMantissa) const override;

/**
* @brief Computes approximate scale and round:
Expand Down Expand Up @@ -1133,7 +1158,7 @@ class DCRTPolyImpl : public DCRTPolyInterface<DCRTPolyImpl<VecType>, VecType, Na
*/
DCRTPolyType ScaleAndRound(const std::shared_ptr<Params> paramsOutput,
const std::vector<std::vector<NativeInteger>>& tOSHatInvModsDivsModo,
const std::vector<double>& tOSHatInvModsDivsFrac,
const std::vector<NativeInteger>& tOSHatInvModsDivsFrac,
const std::vector<DoubleNativeInt>& modoBarretMu) const override;

/**
Expand Down