Skip to content
Merged
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
3 changes: 2 additions & 1 deletion shell_encryption/error_params.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class ErrorParams {
// decomposition modulus.
int num_digits = (log_decomposition_modulus + log_modulus_ - 1) /
log_decomposition_modulus;
int decomposition_modulus = 1 << log_decomposition_modulus;
double decomposition_modulus = static_cast<double>(
static_cast<typename ModularInt::Int>(1) << log_decomposition_modulus);
return (8.0 / sqrt(3.0)) * ExportDoubleT() * num_digits * sigma_ *
dimension_ * decomposition_modulus * num_components;
}
Expand Down
23 changes: 23 additions & 0 deletions shell_encryption/error_params_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ TYPED_TEST(ErrorParamsTest, RelinearizationErrorScalesWithNumComponents) {
}
}

// Test that the relinearization error can be computed when
// log_decomposition_modulus is equal to log(modulus) which is the largest
// possible value.
TYPED_TEST(ErrorParamsTest,
RelinearizationErrorForLargeLogDecompositionModulus) {
for (const auto& params :
rlwe::testing::ContextParameters<TypeParam>::Value()) {
ASSERT_OK_AND_ASSIGN(auto context,
rlwe::RlweContext<TypeParam>::Create(params));
const int k_decomposition_modulus =
context->GetModulusParams()->log_modulus;
constexpr int k_num_components = 2;
// When log_decomposition_modulus = log(modulus), we are effectively
// not decomposing the ciphertext coefficients, and so the error can be
// much larger than the ciphertext modulus. In practice, we would never use
// such a large decomposition modulus, but we test it here to make sure the
// error computation does not fail.
EXPECT_GT(context->GetErrorParams()->B_relinearize(k_num_components,
k_decomposition_modulus),
0.0);
}
}

} // namespace

#endif // RLWE_ERROR_PARAMS_TEST_H_
Loading