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

Commit deefeb0

Browse files
ETatuzovankaskov
authored andcommitted
Proof generating is syncronized with marshalling-zk #21
1 parent 0bd4a24 commit deefeb0

File tree

3 files changed

+38
-23
lines changed

3 files changed

+38
-23
lines changed

include/nil/blueprint/transpiler/evm_verifier_gen.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ namespace nil {
148148
std::size_t permutation_size,
149149
std::string folder_name
150150
){
151+
std::filesystem::create_directory(folder_name);
151152
std::string test_name;
152153
std::size_t found = folder_name.rfind("/");
153154
if( found == std::string::npos ){

test/detail/circuits.hpp

+32-18
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
// SOFTWARE.
2727
//---------------------------------------------------------------------------//
2828

29-
#ifndef CRYPTO3_ZK_MARSHALLING_TEST_PLONK_CIRCUITS_HPP
30-
#define CRYPTO3_ZK_MARSHALLING_TEST_PLONK_CIRCUITS_HPP
29+
#ifndef CRYPTO3_ZK_TEST_PLONK_CIRCUITS_HPP
30+
#define CRYPTO3_ZK_TEST_PLONK_CIRCUITS_HPP
3131

3232
#define _RND_ algebra::random_element<FieldType>();
3333

@@ -105,7 +105,8 @@ namespace nil {
105105

106106
template<typename FieldType>
107107
circuit_description<FieldType, placeholder_circuit_params<FieldType, arithmetization_params_1>, 4, 4> circuit_test_1(
108-
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>()
108+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
109+
boost::random::mt11213b rnd = boost::random::mt11213b()
109110
) {
110111
using assignment_type = typename FieldType::value_type;
111112

@@ -242,7 +243,11 @@ namespace nil {
242243

243244
template<typename FieldType>
244245
circuit_description<FieldType, placeholder_circuit_params<FieldType, arithmetization_params_t>, 4, 4>
245-
circuit_test_t(typename FieldType::value_type pi0 = FieldType::value_type::zero()) {
246+
circuit_test_t(
247+
typename FieldType::value_type pi0 = 0,
248+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
249+
boost::random::mt11213b rnd = boost::random::mt11213b()
250+
) {
246251
using assignment_type = typename FieldType::value_type;
247252

248253
constexpr static const std::size_t rows_log = 4;
@@ -372,7 +377,10 @@ namespace nil {
372377
public_columns_3, constant_columns_3, selector_columns_3>;
373378

374379
template<typename FieldType>
375-
circuit_description<FieldType, placeholder_circuit_params<FieldType, arithmetization_params_3>, 3, 3> circuit_test_3() {
380+
circuit_description<FieldType, placeholder_circuit_params<FieldType, arithmetization_params_3>, 3, 3> circuit_test_3(
381+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
382+
boost::random::mt11213b rnd = boost::random::mt11213b()
383+
) {
376384
using assignment_type = typename FieldType::value_type;
377385
using field_type = typename FieldType::value_type;
378386

@@ -489,7 +497,10 @@ namespace nil {
489497

490498
template<typename FieldType>
491499
circuit_description<FieldType, placeholder_circuit_params<FieldType,
492-
arithmetization_params_4>, 3, 3> circuit_test_4() {
500+
arithmetization_params_4>, 3, 3> circuit_test_4(
501+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
502+
boost::random::mt11213b rnd = boost::random::mt11213b()
503+
) {
493504
using assignment_type = typename FieldType::value_type;
494505

495506
constexpr static const std::size_t rows_log = 3;
@@ -511,12 +522,11 @@ namespace nil {
511522
table[j].resize(test_circuit.table_rows);
512523
}
513524

514-
srand(time(NULL));
515525
// lookup inputs
516526
typename FieldType::value_type one = FieldType::value_type::one();
517527
typename FieldType::value_type zero = FieldType::value_type::zero();
518-
table[0] = {rand() % 2, rand() % 2, rand(), rand() % 2, rand() % 2, 0, 0, 0};
519-
table[1] = {rand() % 2, rand() % 2, rand(), rand() % 2, rand() % 2, 0, 0, 0};;
528+
table[0] = {rnd() % 2, rnd() % 2, rnd(), rnd() % 2, rnd() % 2, 0, 0, 0};
529+
table[1] = {rnd() % 2, rnd() % 2, rnd(), rnd() % 2, rnd() % 2, 0, 0, 0};;
520530
table[2] = {table[0][0] * table[1][0], table[0][1] * table[1][1], table[0][2] * table[1][2], table[0][3] * table[1][3], table[0][4] * table[1][4], 0, 0, 0};
521531

522532

@@ -883,7 +893,10 @@ namespace nil {
883893

884894
template<typename FieldType>
885895
circuit_description<FieldType, placeholder_circuit_params<FieldType,
886-
arithmetization_params_6>, 3, 3> circuit_test_6() {
896+
arithmetization_params_6>, 3, 3> circuit_test_6(
897+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
898+
boost::random::mt11213b rnd = boost::random::mt11213b()
899+
) {
887900
using assignment_type = typename FieldType::value_type;
888901

889902
constexpr static const std::size_t rows_log = 3;
@@ -905,11 +918,10 @@ namespace nil {
905918
table[j].resize(test_circuit.table_rows);
906919
}
907920

908-
srand(time(NULL));
909921
// lookup inputs
910922
typename FieldType::value_type one = FieldType::value_type::one();
911923
typename FieldType::value_type zero = FieldType::value_type::zero();
912-
table[0] = {rand() % 5 + 2, rand() % 5 + 2, rand() % 5 + 2, rand() % 5 + 2, rand() % 5 + 2, rand() % 5 + 2, 0, 0};
924+
table[0] = {rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, 0, 0};
913925
table[1] = {7, table[0][0] + table[0][1], table[0][1] + table[0][2], table[0][2] + table[0][3], table[0][3] + table[0][4], table[0][4] + table[0][5], 0, 0};;
914926

915927

@@ -1030,7 +1042,10 @@ namespace nil {
10301042

10311043
template<typename FieldType>
10321044
circuit_description<FieldType, placeholder_circuit_params<FieldType,
1033-
arithmetization_params_7>, 4, 3> circuit_test_7() {
1045+
arithmetization_params_7>, 4, 3> circuit_test_7(
1046+
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
1047+
boost::random::mt11213b rnd = boost::random::mt11213b()
1048+
) {
10341049
using assignment_type = typename FieldType::value_type;
10351050

10361051
constexpr static const std::size_t rows_log = 4;
@@ -1052,12 +1067,11 @@ namespace nil {
10521067
table[j].resize(test_circuit.table_rows);
10531068
}
10541069

1055-
srand(time(NULL));
10561070
// lookup inputs
10571071
typename FieldType::value_type one = FieldType::value_type::one();
10581072
typename FieldType::value_type zero = FieldType::value_type::zero();
10591073

1060-
auto r = rand() % 8;
1074+
auto r = rnd() % 7;
10611075
table[0] = std::vector<typename FieldType::value_type>(16);
10621076
std::size_t j = 0;
10631077
for( std::size_t i = 0; i < 7; i++){
@@ -1088,8 +1102,8 @@ namespace nil {
10881102
constant_assignment[2] = {0, 3, 3, 3, 2, 2, 2, 2, 6, 7, 7, 7, 7, 7, 0, 0 }; // Lookup tables
10891103
constant_assignment[3] = {0, 4, 4, 4, 4, 3, 3, 3, 64, 128, 128, 128, 128, 128, 0, 0 }; // Lookup tables
10901104
constant_assignment[4] = {0, 5, 5, 5, 5, 5, 4, 4, 1, 2, 4, 8, 16, 32, 0, 0 }; // Lookup tables
1091-
constant_assignment[5] = {0, 6, 6, 6, 6, 6, 5, 5, 64, 128, 256, 512, 1024, 2048, 0, 0 }; // Lookup tables
1092-
constant_assignment[6] = {0, 7, 7, 7, 7, 7, 7, 6,4096,8192,16384,16384,16384,16384, 0, 0 }; // Lookup tables
1105+
constant_assignment[5] = {0, 6, 6, 6, 6, 6, 6, 5, 64, 128, 256, 512, 1024, 2048, 0, 0 }; // Lookup tables
1106+
constant_assignment[6] = {0, 7, 7, 7, 7, 7, 7, 7,4096,8192,16384,16384,16384,16384, 0, 0 }; // Lookup tables
10931107

10941108
std::array<plonk_column<FieldType>, witness_columns> private_assignment;
10951109
for (std::size_t i = 0; i < witness_columns; i++) {
@@ -1182,4 +1196,4 @@ namespace nil {
11821196
} // namespace nil
11831197

11841198

1185-
#endif // CRYPTO3_MARSHALLING_ZK_TEST_PLONK_CIRCUITS_HPP
1199+
#endif // CRYPTO3_ZK_TEST_PLONK_CIRCUITS_HPP

test/transpiler.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit2)
290290

291291
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_t_params>;
292292
BOOST_FIXTURE_TEST_CASE(transpiler_test, test_initializer) {
293-
auto pi0 = nil::crypto3::algebra::random_element<field_type>();
294-
auto circuit = circuit_test_t<field_type>(pi0);
293+
auto pi0 = test_global_alg_rnd_engine<field_type>();
294+
auto circuit = circuit_test_t<field_type>(pi0, test_global_alg_rnd_engine<field_type>, test_global_rnd_engine);
295295

296296
plonk_table_description<field_type, typename circuit_t_params::arithmetization_params> desc;
297297
desc.rows_amount = table_rows;
@@ -441,7 +441,7 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit4)
441441
using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
442442
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_params>;
443443
BOOST_FIXTURE_TEST_CASE(transpiler_test, test_initializer) {
444-
auto circuit = circuit_test_4<field_type>();
444+
auto circuit = circuit_test_4<field_type>(test_global_alg_rnd_engine<field_type>, test_global_rnd_engine);
445445

446446
plonk_table_description<field_type, typename circuit_params::arithmetization_params> desc;
447447
desc.rows_amount = table_rows;
@@ -515,7 +515,7 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit6)
515515
using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
516516
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_params>;
517517
BOOST_FIXTURE_TEST_CASE(transpiler_test, test_initializer) {
518-
auto circuit = circuit_test_6<field_type>();
518+
auto circuit = circuit_test_6<field_type>(test_global_alg_rnd_engine<field_type>, test_global_rnd_engine);
519519

520520
plonk_table_description<field_type, typename circuit_params::arithmetization_params> desc;
521521
desc.rows_amount = table_rows;
@@ -589,7 +589,7 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit7)
589589
using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params<circuit_params, lpc_scheme_type>;
590590
using policy_type = zk::snark::detail::placeholder_policy<field_type, circuit_params>;
591591
BOOST_FIXTURE_TEST_CASE(transpiler_test, test_initializer) {
592-
auto circuit = circuit_test_7<field_type>();
592+
auto circuit = circuit_test_7<field_type>(test_global_alg_rnd_engine<field_type>, test_global_rnd_engine);
593593

594594
plonk_table_description<field_type, typename circuit_params::arithmetization_params> desc;
595595
desc.rows_amount = table_rows;

0 commit comments

Comments
 (0)