Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit ec524b6

Browse files
committed
All blueprint branches for zkEVM circutis were merged here #325
1 parent e1ac7ce commit ec524b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+19492
-479
lines changed

libs/blueprint/include/nil/blueprint/basic_non_native_policy.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
#include <nil/crypto3/algebra/curves/pallas.hpp>
3030
#include <nil/crypto3/algebra/curves/vesta.hpp>
3131
#include <nil/crypto3/algebra/curves/ed25519.hpp>
32-
#include <nil/crypto3/algebra/fields/bls12/base_field.hpp>
33-
#include <nil/crypto3/algebra/fields/bls12/scalar_field.hpp>
3432

3533
#include <boost/multiprecision/cpp_int.hpp>
3634
#include <nil/crypto3/zk/snark/arithmetization/plonk/constraint_system.hpp>
@@ -253,6 +251,8 @@ namespace nil {
253251
typedef std::array<var, ratio> non_native_var_type;
254252
};
255253

254+
255+
256256
/*
257257
* Native element type.
258258
*/

libs/blueprint/include/nil/blueprint/blueprint/plonk/assignment_proxy.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ namespace nil {
9292
return used_selector_rows;
9393
}
9494

95+
void make_all_rows_used() {
96+
for (std::uint32_t i = 0; i < rows_amount(); ++i) {
97+
used_rows.insert(i);
98+
}
99+
}
95100
std::uint32_t rows_amount() const override {
96101
return assignment_ptr->rows_amount();
97102
}

libs/blueprint/include/nil/blueprint/blueprint/plonk/circuit_proxy.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,20 @@ namespace nil {
7373

7474
circuit_proxy(std::shared_ptr<circuit<ArithmetizationType>> circuit, std::uint32_t _id) :
7575
circuit_ptr(circuit),
76-
id(_id) {}
76+
id(_id) {
77+
for (std::uint32_t i = 0; i < circuit->num_gates(); ++i)
78+
used_gates.insert(i);
79+
std::cout << "In constructor of circuit_proxy adding " << circuit->num_gates() << " gates" << std::endl;
80+
for (std::uint32_t i = 0; i < circuit->num_lookup_gates(); ++i)
81+
used_lookup_gates.insert(i);
82+
std::cout << "In constructor of circuit_proxy adding " << circuit->num_lookup_gates() << " lookup gates" << std::endl;
83+
for (std::uint32_t i = 0; i < circuit->lookup_tables().size(); ++i)
84+
used_lookup_tables.insert(i);
85+
std::cout << "In constructor of circuit_proxy adding " << circuit->lookup_tables().size() << " lookup tables" << std::endl;
86+
for (std::uint32_t i = 0; i < circuit->copy_constraints().size(); ++i)
87+
used_copy_constraints.insert(i);
88+
std::cout << "In constructor of circuit_proxy adding " << circuit->copy_constraints().size() << " copy constraints" << std::endl;
89+
}
7790

7891
circuit_proxy() = delete;
7992

libs/blueprint/include/nil/blueprint/components/algebra/curves/pasta/plonk/endo_scalar.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace nil {
220220
std::array<bool, BlueprintFieldType::modulus_bits> bits_msb_all =
221221
nil::marshalling::pack<nil::marshalling::option::big_endian>(integral_scalar, status);
222222

223-
THROW_IF_ERROR_STATUS(status, "plonk_endo_scalar::generate_assignments");
223+
assert(status == nil::marshalling::status_type::success);
224224

225225
std::copy(bits_msb_all.end() - component.scalar_size, bits_msb_all.end(), bits_msb.begin());
226226

libs/blueprint/include/nil/blueprint/components/algebra/curves/pasta/plonk/variable_base_endo_scalar_mul_15_wires.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ namespace nil {
177177
nil::marshalling::status_type status;
178178
std::array<bool, 255> bits_all =
179179
nil::marshalling::pack<nil::marshalling::option::big_endian>(integral_b, status);
180-
THROW_IF_ERROR_STATUS(status, "curve_element_variable_base_endo_scalar_mul::generate_assignments");
181180
std::copy(bits_all.end() - 128, bits_all.end(), bits.begin());
182181
}
183182

libs/blueprint/include/nil/blueprint/components/algebra/curves/pasta/plonk/variable_base_scalar_mul.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ namespace nil {
248248
nil::marshalling::status_type status;
249249
std::array<bool, scalar_size> bits =
250250
nil::marshalling::pack<nil::marshalling::option::big_endian>(integral_b, status);
251-
THROW_IF_ERROR_STATUS(status, "curve_element_variable_base_scalar_mul::generate_assignments");
252251

253252
typename BlueprintFieldType::value_type z_n2;
254253
typename BlueprintFieldType::value_type aux;
@@ -268,7 +267,6 @@ namespace nil {
268267
const std::size_t base_size = 255;
269268
std::array<bool, base_size> aux_bits =
270269
nil::marshalling::pack<nil::marshalling::option::big_endian>(integral_aux, status);
271-
THROW_IF_ERROR_STATUS(status, "curve_element_variable_base_scalar_mul::generate_assignments");
272270

273271
typename BlueprintFieldType::value_type n = 0;
274272
typename BlueprintFieldType::value_type n_next = 0;

libs/blueprint/include/nil/blueprint/components/algebra/fields/plonk/non_native/bit_decomposition.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ namespace nil {
193193
nil::marshalling::status_type status;
194194
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
195195
nil::marshalling::pack<nil::marshalling::option::big_endian>(input, status);
196-
THROW_IF_ERROR_STATUS(status, "bit_decomposition::calculate");
197196
std::copy(bytes_all.end() - bits_amount, bytes_all.end(), bits.begin());
197+
assert(status == nil::marshalling::status_type::success);
198198
}
199199
std::vector<bool> true_bits(bits_amount);
200200
for (std::size_t i = 0; i < bits_amount; i++) {
@@ -225,8 +225,8 @@ namespace nil {
225225
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
226226
nil::marshalling::pack<nil::marshalling::option::big_endian>(
227227
var_value(assignment, instance_input.input), status);
228-
THROW_IF_ERROR_STATUS(status, "bit_decomposition::generate_assignments");
229228
std::copy(bytes_all.end() - component.bits_amount, bytes_all.end(), input_bits.begin());
229+
assert(status == nil::marshalling::status_type::success);
230230
}
231231
// calling bit_builder_component's generate_assignments
232232
generate_assignments<BlueprintFieldType>(
@@ -324,4 +324,4 @@ namespace nil {
324324
} // namespace blueprint
325325
} // namespace nil
326326

327-
#endif // CRYPTO3_BLUEPRINT_COMPONENTS_VARIABLE_BASE_MULTIPLICATION_EDWARD25519_HPP
327+
#endif // CRYPTO3_BLUEPRINT_COMPONENTS_VARIABLE_BASE_MULTIPLICATION_EDWARD25519_HPP

libs/blueprint/include/nil/blueprint/components/algebra/fields/plonk/non_native/comparison_checked.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,9 +497,9 @@ namespace nil {
497497
nil::marshalling::status_type status;
498498
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
499499
nil::marshalling::pack<nil::marshalling::option::big_endian>(integrals[i], status);
500-
THROW_IF_ERROR_STATUS(status, "comparison_checked::generate_assignments");
501500
std::copy(bytes_all.end() - component.bits_amount, bytes_all.end(),
502501
bits[i].begin() + component.padding_bits);
502+
assert(status == nil::marshalling::status_type::success);
503503
}
504504

505505
std::array<std::vector<chunk_type>, 2> chunks;

libs/blueprint/include/nil/blueprint/components/algebra/fields/plonk/non_native/comparison_flag.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,9 @@ namespace nil {
314314
nil::marshalling::status_type status;
315315
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
316316
nil::marshalling::pack<nil::marshalling::option::big_endian>(integrals[i], status);
317-
THROW_IF_ERROR_STATUS(status, "comparison_flag::calculate");
318-
319317
std::copy(bytes_all.end() - arg_bits_amount, bytes_all.end(),
320318
bits[i].begin() + padding_bits);
319+
assert(status == nil::marshalling::status_type::success);
321320
}
322321

323322
BOOST_ASSERT(padded_chunks * chunk_size ==
@@ -471,9 +470,9 @@ namespace nil {
471470
nil::marshalling::status_type status;
472471
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
473472
nil::marshalling::pack<nil::marshalling::option::big_endian>(integrals[i], status);
474-
THROW_IF_ERROR_STATUS(status, "comparison_flag::generate_assignments");
475473
std::copy(bytes_all.end() - component.bits_amount, bytes_all.end(),
476474
bits[i].begin() + component.padding_bits);
475+
assert(status == nil::marshalling::status_type::success);
477476
}
478477

479478
BOOST_ASSERT(component.padded_chunks * component.chunk_size ==

libs/blueprint/include/nil/blueprint/components/algebra/fields/plonk/range_check.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ namespace nil {
267267
nil::marshalling::status_type status;
268268
std::array<bool, BlueprintFieldType::modulus_bits> bytes_all =
269269
nil::marshalling::pack<nil::marshalling::option::big_endian>(x_integral, status);
270-
THROW_IF_ERROR_STATUS(status, "range_check::generate_assignments");
271270
std::copy(bytes_all.end() - component.bits_amount, bytes_all.end(),
272271
bits.begin() + component.padding_bits);
272+
assert(status == nil::marshalling::status_type::success);
273273
}
274274

275275
BOOST_ASSERT(component.chunk_size <= 8);
@@ -404,4 +404,4 @@ namespace nil {
404404
} // namespace blueprint
405405
} // namespace nil
406406

407-
#endif // CRYPTO3_ZK_BLUEPRINT_PLONK_FIELD_RANGE_CHECK_HPP
407+
#endif // CRYPTO3_ZK_BLUEPRINT_PLONK_FIELD_RANGE_CHECK_HPP

0 commit comments

Comments
 (0)