src/snark patches for windows build
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "common/profiling.hpp"
|
||||
#include "common/utils.hpp"
|
||||
#include "common/assert_except.hpp"
|
||||
#include "algebra/scalar_multiplication/wnaf.hpp"
|
||||
|
||||
namespace libsnark {
|
||||
@@ -40,7 +41,7 @@ public:
|
||||
#if defined(__x86_64__) && defined(USE_ASM)
|
||||
if (n == 3)
|
||||
{
|
||||
long res;
|
||||
int64_t res;
|
||||
__asm__
|
||||
("// check for overflow \n\t"
|
||||
"mov $0, %[res] \n\t"
|
||||
@@ -58,7 +59,7 @@ public:
|
||||
}
|
||||
else if (n == 4)
|
||||
{
|
||||
long res;
|
||||
int64_t res;
|
||||
__asm__
|
||||
("// check for overflow \n\t"
|
||||
"mov $0, %[res] \n\t"
|
||||
@@ -77,7 +78,7 @@ public:
|
||||
}
|
||||
else if (n == 5)
|
||||
{
|
||||
long res;
|
||||
int64_t res;
|
||||
__asm__
|
||||
("// check for overflow \n\t"
|
||||
"mov $0, %[res] \n\t"
|
||||
@@ -119,7 +120,7 @@ T naive_exp(typename std::vector<T>::const_iterator vec_start,
|
||||
bigint<FieldT::num_limbs> scalar_bigint = scalar_it->as_bigint();
|
||||
result = result + opt_window_wnaf_exp(*vec_it, scalar_bigint, scalar_bigint.num_bits());
|
||||
}
|
||||
assert(scalar_it == scalar_end);
|
||||
assert_except(scalar_it == scalar_end);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -139,7 +140,7 @@ T naive_plain_exp(typename std::vector<T>::const_iterator vec_start,
|
||||
{
|
||||
result = result + (*scalar_it) * (*vec_it);
|
||||
}
|
||||
assert(scalar_it == scalar_end);
|
||||
assert_except(scalar_it == scalar_end);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -185,15 +186,15 @@ T multi_exp_inner(typename std::vector<T>::const_iterator vec_start,
|
||||
opt_q.emplace_back(ordered_exponent<n>(i, scalar_it->as_bigint()));
|
||||
}
|
||||
std::make_heap(opt_q.begin(),opt_q.end());
|
||||
assert(scalar_it == scalar_end);
|
||||
assert_except(scalar_it == scalar_end);
|
||||
|
||||
if (vec_len != odd_vec_len)
|
||||
{
|
||||
g.emplace_back(T::zero());
|
||||
opt_q.emplace_back(ordered_exponent<n>(odd_vec_len - 1, bigint<n>(0ul)));
|
||||
opt_q.emplace_back(ordered_exponent<n>(odd_vec_len - 1, bigint<n>(UINT64_C(0))));
|
||||
}
|
||||
assert(g.size() % 2 == 1);
|
||||
assert(opt_q.size() == g.size());
|
||||
assert_except(g.size() % 2 == 1);
|
||||
assert_except(opt_q.size() == g.size());
|
||||
|
||||
T opt_result = T::zero();
|
||||
|
||||
@@ -214,7 +215,7 @@ T multi_exp_inner(typename std::vector<T>::const_iterator vec_start,
|
||||
const size_t bbits = b.r.num_bits();
|
||||
const size_t limit = (abits-bbits >= 20 ? 20 : abits-bbits);
|
||||
|
||||
if (bbits < 1ul<<limit)
|
||||
if (bbits < UINT64_C(1)<<limit)
|
||||
{
|
||||
/*
|
||||
In this case, exponentiating to the power of a is cheaper than
|
||||
@@ -329,7 +330,7 @@ T multi_exp_with_mixed_addition(typename std::vector<T>::const_iterator vec_star
|
||||
const size_t chunks,
|
||||
const bool use_multiexp)
|
||||
{
|
||||
assert(std::distance(vec_start, vec_end) == std::distance(scalar_start, scalar_end));
|
||||
assert_except(std::distance(vec_start, vec_end) == std::distance(scalar_start, scalar_end));
|
||||
enter_block("Process scalar vector");
|
||||
auto value_it = vec_start;
|
||||
auto scalar_it = scalar_start;
|
||||
@@ -389,7 +390,7 @@ size_t get_exp_window_size(const size_t num_scalars)
|
||||
#endif
|
||||
}
|
||||
size_t window = 1;
|
||||
for (long i = T::fixed_base_exp_window_table.size()-1; i >= 0; --i)
|
||||
for (int64_t i = T::fixed_base_exp_window_table.size()-1; i >= 0; --i)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (!inhibit_profiling_info)
|
||||
@@ -420,9 +421,9 @@ window_table<T> get_window_table(const size_t scalar_size,
|
||||
const size_t window,
|
||||
const T &g)
|
||||
{
|
||||
const size_t in_window = 1ul<<window;
|
||||
const size_t in_window = UINT64_C(1)<<window;
|
||||
const size_t outerc = (scalar_size+window-1)/window;
|
||||
const size_t last_in_window = 1ul<<(scalar_size - (outerc-1)*window);
|
||||
const size_t last_in_window = UINT64_C(1)<<(scalar_size - (outerc-1)*window);
|
||||
#ifdef DEBUG
|
||||
if (!inhibit_profiling_info)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user