Skip to content

Commit

Permalink
Remove init_raw_base from zero-init big_mod
Browse files Browse the repository at this point in the history
  • Loading branch information
ioxid committed Dec 9, 2024
1 parent 54af2d8 commit 3012c13
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ namespace nil::crypto3::multiprecision {
init_raw_base(m_raw_base, b, ops());
}

constexpr big_mod_impl(const modular_ops_storage_t& modular_ops_storage)
: m_modular_ops_storage(modular_ops_storage) {}

public:
// Components

Expand Down Expand Up @@ -105,12 +108,16 @@ namespace nil::crypto3::multiprecision {
using typename base_type::modular_ops_storage_t;
using typename base_type::modular_ops_t;

constexpr big_mod_ct_impl() : base_type(big_uint_t{}, {}) {}
constexpr big_mod_ct_impl() : base_type({}) {}

template<typename T, std::enable_if_t<detail::is_integral_v<T>, int> = 0>
constexpr big_mod_ct_impl(const T& b) : base_type(b, {}) {}

// For generic code

constexpr big_mod_ct_impl(const modular_ops_storage_t& ops_storage)
: base_type(ops_storage) {}

template<typename T, std::enable_if_t<detail::is_integral_v<T>, int> = 0>
constexpr big_mod_ct_impl(const T& b, const modular_ops_storage_t& ops_storage)
: base_type(b, ops_storage) {}
Expand All @@ -127,11 +134,18 @@ namespace nil::crypto3::multiprecision {
using typename base_type::modular_ops_storage_t;
using typename base_type::modular_ops_t;

template<typename T, std::enable_if_t<detail::is_integral_v<T>, int> = 0>
constexpr big_mod_rt_impl(const T& m) : base_type(m) {}

template<typename T1, typename T2,
std::enable_if_t<detail::is_integral_v<T1> && detail::is_integral_v<T1>, int> = 0>
std::enable_if_t<detail::is_integral_v<T1> && detail::is_integral_v<T2>, int> = 0>
constexpr big_mod_rt_impl(const T1& b, const T2& m) : base_type(b, m) {}

// For generic code

constexpr big_mod_rt_impl(const modular_ops_storage_t& ops_storage)
: base_type(ops_storage) {}

template<typename T, std::enable_if_t<detail::is_integral_v<T>, int> = 0>
constexpr big_mod_rt_impl(const T& b, const modular_ops_storage_t& ops_storage)
: base_type(b, ops_storage) {}
Expand Down Expand Up @@ -229,7 +243,7 @@ namespace nil::crypto3::multiprecision {
typename big_mod_t = std::conditional_t<detail::is_big_mod_v<T1>, T1, T2>> \
constexpr auto operator OP_(const T1& a, const T2& b) noexcept { \
const auto& ops_storage = detail::get_ops_storage_from_operands(a, b); \
big_mod_t result(0u, ops_storage); \
big_mod_t result(ops_storage); \
result.raw_base() = detail::convert_to_raw_base(a, ops_storage.ops()); \
ops_storage.ops().METHOD_(result.raw_base(), \
detail::convert_to_raw_base(b, ops_storage.ops())); \
Expand Down

0 comments on commit 3012c13

Please sign in to comment.