Major updates integration from all upstreams
This commit is contained in:
@@ -585,9 +585,9 @@ void loose_multiplexing_gadget<FieldT>::generate_r1cs_constraints()
|
||||
template<typename FieldT>
|
||||
void loose_multiplexing_gadget<FieldT>::generate_r1cs_witness()
|
||||
{
|
||||
/* assumes that idx can be fit in ulong; true for our purposes for now */
|
||||
/* assumes that idx can be fit in uint64_t; true for our purposes for now */
|
||||
const bigint<FieldT::num_limbs> valint = this->pb.val(index).as_bigint();
|
||||
uint64_t idx = valint.as_ulong();
|
||||
uint64_t idx = valint.as_uint64();
|
||||
const bigint<FieldT::num_limbs> arrsize(arr.size());
|
||||
|
||||
if (idx >= arr.size() || mpn_cmp(valint.data, arrsize.data, FieldT::num_limbs) >= 0)
|
||||
|
||||
@@ -285,7 +285,7 @@ void majority_gadget<FieldT>::generate_r1cs_witness()
|
||||
{
|
||||
for (size_t i = 0; i < 32; ++i)
|
||||
{
|
||||
const int64_t v = (this->pb.lc_val(X[i]) + this->pb.lc_val(Y[i]) + this->pb.lc_val(Z[i])).as_ulong();
|
||||
const uint64_t v = (this->pb.lc_val(X[i]) + this->pb.lc_val(Y[i]) + this->pb.lc_val(Z[i])).as_uint64();
|
||||
this->pb.val(result_bits[i]) = FieldT(v / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
pb_linear_combination_array<FieldT> g;
|
||||
pb_linear_combination_array<FieldT> h;
|
||||
pb_variable<FieldT> W;
|
||||
int64_t K;
|
||||
uint32_t K;
|
||||
pb_linear_combination_array<FieldT> new_a;
|
||||
pb_linear_combination_array<FieldT> new_e;
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
const pb_linear_combination_array<FieldT> &g,
|
||||
const pb_linear_combination_array<FieldT> &h,
|
||||
const pb_variable<FieldT> &W,
|
||||
const int64_t &K,
|
||||
const uint32_t &K,
|
||||
const pb_linear_combination_array<FieldT> &new_a,
|
||||
const pb_linear_combination_array<FieldT> &new_e,
|
||||
const std::string &annotation_prefix);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace libsnark {
|
||||
|
||||
const uint64_t SHA256_K[64] = {
|
||||
const uint32_t SHA256_K[64] = {
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
@@ -27,7 +27,7 @@ const uint64_t SHA256_K[64] = {
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
||||
};
|
||||
|
||||
const uint64_t SHA256_H[8] = {
|
||||
const uint32_t SHA256_H[8] = {
|
||||
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ sha256_round_function_gadget<FieldT>::sha256_round_function_gadget(protoboard<Fi
|
||||
const pb_linear_combination_array<FieldT> &g,
|
||||
const pb_linear_combination_array<FieldT> &h,
|
||||
const pb_variable<FieldT> &W,
|
||||
const int64_t &K,
|
||||
const uint32_t &K,
|
||||
const pb_linear_combination_array<FieldT> &new_a,
|
||||
const pb_linear_combination_array<FieldT> &new_e,
|
||||
const std::string &annotation_prefix) :
|
||||
|
||||
@@ -117,7 +117,7 @@ void sha256_compression_function_gadget<FieldT>::generate_r1cs_witness()
|
||||
printf("Input:\n");
|
||||
for (size_t j = 0; j < 16; ++j)
|
||||
{
|
||||
printf("%lx ", this->pb.val(packed_W[j]).as_ulong());
|
||||
printf("%lx ", this->pb.val(packed_W[j]).as_uint64());
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
@@ -142,7 +142,7 @@ void sha256_compression_function_gadget<FieldT>::generate_r1cs_witness()
|
||||
printf("Output:\n");
|
||||
for (size_t j = 0; j < 8; ++j)
|
||||
{
|
||||
printf("%lx ", this->pb.val(reduced_output[j]).as_ulong());
|
||||
printf("%lx ", this->pb.val(reduced_output[j]).as_uint64());
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
@@ -175,7 +175,7 @@ void test_merkle_tree_check_read_gadget()
|
||||
ml.generate_r1cs_constraints();
|
||||
|
||||
address_bits_va.fill_with_bits(pb, address_bits);
|
||||
assert(address_bits_va.get_field_element_from_bits(pb).as_ulong() == address);
|
||||
assert(address_bits_va.get_field_element_from_bits(pb).as_uint64() == address);
|
||||
leaf_digest.generate_r1cs_witness(leaf);
|
||||
path_var.generate_r1cs_witness(address, path);
|
||||
ml.generate_r1cs_witness();
|
||||
|
||||
@@ -240,7 +240,7 @@ void test_merkle_tree_check_update_gadget()
|
||||
mls.generate_r1cs_constraints();
|
||||
|
||||
address_bits_va.fill_with_bits(pb, address_bits);
|
||||
assert(address_bits_va.get_field_element_from_bits(pb).as_ulong() == address);
|
||||
assert(address_bits_va.get_field_element_from_bits(pb).as_uint64() == address);
|
||||
prev_leaf_digest.generate_r1cs_witness(loaded_leaf);
|
||||
prev_path_var.generate_r1cs_witness(address, prev_path);
|
||||
next_leaf_digest.generate_r1cs_witness(stored_leaf);
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
void fill_with_field_elements(protoboard<FieldT> &pb, const std::vector<FieldT>& vals) const;
|
||||
void fill_with_bits(protoboard<FieldT> &pb, const bit_vector& bits) const;
|
||||
void fill_with_bits_of_ulong(protoboard<FieldT> &pb, const uint64_t i) const;
|
||||
void fill_with_bits_of_uint64(protoboard<FieldT> &pb, const uint64_t i) const;
|
||||
void fill_with_bits_of_field_element(protoboard<FieldT> &pb, const FieldT &r) const;
|
||||
|
||||
std::vector<FieldT> get_vals(const protoboard<FieldT> &pb) const;
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
|
||||
void fill_with_field_elements(protoboard<FieldT> &pb, const std::vector<FieldT>& vals) const;
|
||||
void fill_with_bits(protoboard<FieldT> &pb, const bit_vector& bits) const;
|
||||
void fill_with_bits_of_ulong(protoboard<FieldT> &pb, const uint64_t i) const;
|
||||
void fill_with_bits_of_uint64(protoboard<FieldT> &pb, const uint64_t i) const;
|
||||
void fill_with_bits_of_field_element(protoboard<FieldT> &pb, const FieldT &r) const;
|
||||
|
||||
std::vector<FieldT> get_vals(const protoboard<FieldT> &pb) const;
|
||||
|
||||
@@ -65,7 +65,7 @@ void pb_variable_array<FieldT>::fill_with_bits_of_field_element(protoboard<Field
|
||||
}
|
||||
|
||||
template<typename FieldT>
|
||||
void pb_variable_array<FieldT>::fill_with_bits_of_ulong(protoboard<FieldT> &pb, const uint64_t i) const
|
||||
void pb_variable_array<FieldT>::fill_with_bits_of_uint64(protoboard<FieldT> &pb, const uint64_t i) const
|
||||
{
|
||||
this->fill_with_bits_of_field_element(pb, FieldT(i, true));
|
||||
}
|
||||
@@ -232,7 +232,7 @@ void pb_linear_combination_array<FieldT>::fill_with_bits_of_field_element(protob
|
||||
}
|
||||
|
||||
template<typename FieldT>
|
||||
void pb_linear_combination_array<FieldT>::fill_with_bits_of_ulong(protoboard<FieldT> &pb, const uint64_t i) const
|
||||
void pb_linear_combination_array<FieldT>::fill_with_bits_of_uint64(protoboard<FieldT> &pb, const uint64_t i) const
|
||||
{
|
||||
this->fill_with_bits_of_field_element(pb, FieldT(i));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user