Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nilfoundation/crypto3-multiprecision
Browse files Browse the repository at this point in the history
  • Loading branch information
nemothenoone committed Jul 31, 2022
2 parents d39aa72 + 8d0e5c0 commit 1eec83f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
11 changes: 4 additions & 7 deletions include/nil/crypto3/multiprecision/modular/asm_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ namespace nil {
template<typename Limb1, typename Limb2, typename Limb3>
void sub_mod_asm(size_t n, Limb1 *x, const Limb2 *y, const Limb3 *mod) {
__asm__ volatile(
"movq $1, %%rbx \n\t"
"movq (%[y]), %%rax \n\t"
"subq %%rax, (%[x]) \n\t"
"pushf \n\t"
// Start circle sub from 1st limb
"movq $0, %%rbx \n\t"
// Start circle sub from 0st limb
"1: \n\t"
"popf \n\t"
"movq (%[y], %%rbx, 8), %%rax \n\t"
Expand All @@ -142,10 +140,9 @@ namespace nil {
// If it's more than zero (no carry bit) just go to end
"jnc 4f \n\t"
// Else add mod to result
"movq (%[mod]), %%rax \n\t"
"addq %%rax, (%[x]) \n\t"
"clc \n\t"
"pushf \n\t"
"movq $1, %%rbx \n\t"
"movq $0, %%rbx \n\t"
"2: \n\t"
"popf \n\t"
"movq (%[mod], %%rbx, 8), %%rax \n\t"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,12 @@ namespace nil {
0, typename cpp_int_backend<MinBits, MaxBits, SignType, Checked>::unsigned_types>::type;
using default_ops::eval_lt;
#if BOOST_ARCH_X86_64
auto limbs_count = get_limbs_count<cpp_int_backend<MinBits, MaxBits, SignType, Checked>>();
if (!BOOST_MP_IS_CONST_EVALUATED(result.base_data().limbs() &&
!is_trivial_cpp_int<Backend1>::value) &&
auto limbs_count = result.base_data().size();
if (!BOOST_MP_IS_CONST_EVALUATED(result.base_data().limbs()) &&
!is_trivial_cpp_int<cpp_int_backend<MinBits, MaxBits, SignType, Checked>>::value &&
result.base_data().size() == o.base_data().size() &&
result.base_data().size() == result.mod_data().get_mod().backend().size()) {

sub_mod_asm(limbs_count, result.base_data().limbs(), o.base_data().limbs(),
result.mod_data().get_mod().backend().limbs());
result.base_data().resize(limbs_count, limbs_count);
Expand Down
2 changes: 1 addition & 1 deletion test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ template <class E>
void report_unexpected_exception(const E& e, int severity, const char* file, int line, const char* function)
{
report_where(file, line, function) << " Unexpected exception of type " << typeid(e).name() << std::endl;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Errot message was: " << e.what() << std::endl;
BOOST_LIGHTWEIGHT_TEST_OSTREAM << "Error message was: " << e.what() << std::endl;
BOOST_MP_REPORT_SEVERITY(severity);
}

Expand Down
4 changes: 0 additions & 4 deletions test/test_modular_adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ BOOST_DATA_TEST_CASE(base_opeartions, numbers_size * (boost::unit_test::data::ma
std::string b_string = big_numbers_b.substr(0, num);
std::string mod_string = exp;

std::cout << a_string << std::endl;
std::cout << b_string << std::endl;
std::cout << mod_string << std::endl;

standart_number a_s(a_string), b_s(b_string), mod_s(mod_string), result_s(0);

params_number mod(mod_s);
Expand Down
4 changes: 2 additions & 2 deletions test/test_native_integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void test() {
I i(0);

#ifndef BOOST_NO_EXCEPTIONS
BOOST_CHECK_THROW(lsb(i), std::range_error);
BOOST_CHECK_THROW(lsb(i), std::domain_error);
#endif
BOOST_CHECK(bit_test(bit_set(i, 0), 0));
BOOST_CHECK_EQUAL(bit_set(i, 0), 1);
Expand All @@ -47,7 +47,7 @@ void test() {
#ifndef BOOST_NO_EXCEPTIONS
if (std::numeric_limits<I>::is_signed) {
i = static_cast<I>(-1);
BOOST_CHECK_THROW(lsb(i), std::range_error);
BOOST_CHECK_THROW(lsb(i), std::domain_error);
}
#endif
H mx = (std::numeric_limits<H>::max)();
Expand Down

0 comments on commit 1eec83f

Please sign in to comment.