From e364a51544f96b5161a7a0f6737ce40c32144539 Mon Sep 17 00:00:00 2001 From: Vasiliy Olekhov Date: Tue, 28 May 2024 14:00:20 +0300 Subject: [PATCH] Copy circuits.hpp from zk, update placeholder_proof marshalling #235 marshalling tests for common_data and proof #235 rm commented test for kzg commitment #235 --- libs/marshalling/zk/test/detail/circuits.hpp | 203 +++++---- libs/marshalling/zk/test/kzg_commitment.cpp | 53 +-- .../zk/test/placeholder_common_data.cpp | 422 ++++++++---------- .../marshalling/zk/test/placeholder_proof.cpp | 357 ++++----------- 4 files changed, 378 insertions(+), 657 deletions(-) diff --git a/libs/marshalling/zk/test/detail/circuits.hpp b/libs/marshalling/zk/test/detail/circuits.hpp index e9d8a7621..3f97de80a 100644 --- a/libs/marshalling/zk/test/detail/circuits.hpp +++ b/libs/marshalling/zk/test/detail/circuits.hpp @@ -54,7 +54,7 @@ namespace nil { namespace crypto3 { namespace zk { namespace snark { - template + template class circuit_description { typedef zk::snark::detail::placeholder_policy policy_type; @@ -63,7 +63,7 @@ namespace nil { public: std::size_t table_rows; - std::size_t usable_rows = usable_rows_amount; + std::size_t usable_rows; typename policy_type::variable_assignment_type table; @@ -96,14 +96,12 @@ namespace nil { const std::size_t rows_amount_1 = 13; template - circuit_description, rows_amount_1> circuit_test_1( + circuit_description> circuit_test_1( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { using assignment_type = typename FieldType::value_type; - constexpr static const std::size_t usable_rows = rows_amount_1; - constexpr static const std::size_t witness_columns = witness_columns_1; constexpr static const std::size_t public_columns = public_columns_1; constexpr static const std::size_t constant_columns = constant_columns_1; @@ -112,7 +110,8 @@ namespace nil { witness_columns + public_columns + constant_columns; typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; + test_circuit.usable_rows = rows_amount_1; std::vector> table(table_columns); std::vector q_add(test_circuit.usable_rows); @@ -139,9 +138,9 @@ namespace nil { q_add[i] = one; q_mul[i] = FieldType::value_type::zero(); - plonk_variable x(1u, i, false, + plonk_variable x(1, i, false, plonk_variable::column_type::witness); - plonk_variable y(2, i - 1u, false, + plonk_variable y(2, i - 1, false, plonk_variable::column_type::witness); //test_circuit.copy_constraints.push_back(plonk_copy_constraint(x, y)); } @@ -155,9 +154,9 @@ namespace nil { q_add[i] = FieldType::value_type::zero(); q_mul[i] = one; - plonk_variable x(1u, i, false, + plonk_variable x(1, i, false, plonk_variable::column_type::witness); - plonk_variable y(0u, 0u, false, + plonk_variable y(0, 0, false, plonk_variable::column_type::public_input); test_circuit.copy_constraints.push_back(plonk_copy_constraint(x, y)); } @@ -184,9 +183,9 @@ namespace nil { test_circuit.table_rows = zk_padding>(test_circuit.table, alg_rnd); - plonk_variable w0(0u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w1(1u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w2(2, 0u, true, plonk_variable::column_type::witness); + plonk_variable w0(0, 0, true, plonk_variable::column_type::witness); + plonk_variable w1(1, 0, true, plonk_variable::column_type::witness); + plonk_variable w2(2, 0, true, plonk_variable::column_type::witness); plonk_constraint add_constraint; add_constraint += w0; @@ -194,7 +193,7 @@ namespace nil { add_constraint -= w2; std::vector> add_gate_costraints {add_constraint}; - plonk_gate> add_gate(0u, add_gate_costraints); + plonk_gate> add_gate(0, add_gate_costraints); test_circuit.gates.push_back(add_gate); plonk_constraint mul_constraint; @@ -204,7 +203,7 @@ namespace nil { mul_constraint -= w2; std::vector> mul_gate_costraints {mul_constraint}; - plonk_gate> mul_gate(1u, mul_gate_costraints); + plonk_gate> mul_gate(1, mul_gate_costraints); test_circuit.gates.push_back(mul_gate); return test_circuit; @@ -220,7 +219,7 @@ namespace nil { // k-1 | MUL | x | y | z | 0 | 0 | 1 | // // ADD: x + y = z, copy(prev(z), y) - // MUL: x * y + prev(x) = z, copy(p1u, y) + // MUL: x * y + prev(x) = z, copy(p1, y) //---------------------------------------------------------------------------// constexpr static const std::size_t witness_columns_t = 3; constexpr static const std::size_t public_columns_t = 1; @@ -229,7 +228,7 @@ namespace nil { constexpr static const std::size_t usable_rows_t = 5; template - circuit_description, usable_rows_t> + circuit_description> circuit_test_t( typename FieldType::value_type pi0 = 0u, typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), @@ -237,7 +236,6 @@ namespace nil { ) { using assignment_type = typename FieldType::value_type; - constexpr static const std::size_t usable_rows = usable_rows_t; constexpr static const std::size_t witness_columns = witness_columns_t; constexpr static const std::size_t public_columns = public_columns_t; constexpr static const std::size_t constant_columns = constant_columns_t; @@ -247,8 +245,9 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; test_circuit.public_input_sizes = {3}; + test_circuit.usable_rows = usable_rows_t; std::vector> table(table_columns); @@ -276,9 +275,9 @@ namespace nil { q_add[i] = one; q_mul[i] = FieldType::value_type::zero(); - plonk_variable x(1u, i, false, + plonk_variable x(1, i, false, plonk_variable::column_type::witness); - plonk_variable y(2, i - 1u, false, + plonk_variable y(2, i - 1, false, plonk_variable::column_type::witness); test_circuit.copy_constraints.push_back(plonk_copy_constraint(x, y)); } @@ -292,9 +291,9 @@ namespace nil { q_add[i] = FieldType::value_type::zero(); q_mul[i] = one; - plonk_variable x(1u, i, false, + plonk_variable x(1, i, false, plonk_variable::column_type::witness); - plonk_variable y(0u, 0u, false, + plonk_variable y(0, 0, false, plonk_variable::column_type::public_input); test_circuit.copy_constraints.push_back(plonk_copy_constraint(x, y)); } @@ -322,13 +321,13 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); test_circuit.table_rows = zk_padding>(test_circuit.table, alg_rnd); - plonk_variable w0(0u, 0u, true, + plonk_variable w0(0, 0, true, plonk_variable::column_type::witness); - plonk_variable w1(1u, 0u, true, + plonk_variable w1(1, 0, true, plonk_variable::column_type::witness); - plonk_variable w2(2, 0u, true, + plonk_variable w2(2, 0, true, plonk_variable::column_type::witness); - plonk_variable w0_prev(0u, -1u, true, + plonk_variable w0_prev(0, -1, true, plonk_variable::column_type::witness); plonk_constraint add_constraint; @@ -337,7 +336,7 @@ namespace nil { add_constraint -= w2; std::vector> add_gate_costraints {add_constraint}; - plonk_gate> add_gate(0u, add_gate_costraints); + plonk_gate> add_gate(0, add_gate_costraints); test_circuit.gates.push_back(add_gate); plonk_constraint mul_constraint; @@ -348,7 +347,7 @@ namespace nil { mul_constraint += w0_prev; std::vector> mul_gate_costraints {mul_constraint}; - plonk_gate> mul_gate(1u, mul_gate_costraints); + plonk_gate> mul_gate(1, mul_gate_costraints); //test_circuit.gates.push_back(mul_gate); return test_circuit; @@ -362,7 +361,7 @@ namespace nil { constexpr static const std::size_t usable_rows_3 = 4; template - circuit_description, usable_rows_3> circuit_test_3( + circuit_description> circuit_test_3( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { @@ -374,11 +373,11 @@ namespace nil { constexpr static const std::size_t selector_columns = selector_columns_3; constexpr static const std::size_t table_columns = witness_columns + public_columns + constant_columns; - constexpr static const std::size_t usable_rows = usable_rows_3; typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; + test_circuit.usable_rows = usable_rows_3; std::vector> table(table_columns); for (std::size_t j = 0; j < table_columns; j++) { @@ -390,9 +389,9 @@ namespace nil { table[1] = {0u, 0u, 0u, 0u}; table[2] = {0u, 0u, 0u, 0u}; - table[3] = {0u, 1u, 0u, 1u}; //Lookup values - table[4] = {0u, 0u, 1u, 0u}; //Lookup values - table[5] = {0u, 1u, 0u, 0u}; //Lookup values + table[3] = {0u, 1u, 0u, 1u}; //Lookup values + table[4] = {0u, 0u, 1u, 0u}; //Lookup values + table[5] = {0u, 1u, 0u, 0u}; //Lookup values std::vector> private_assignment(witness_columns); for (std::size_t i = 0; i < witness_columns; i++) { @@ -420,13 +419,13 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); test_circuit.table_rows = zk_padding(test_circuit.table, alg_rnd); - plonk_variable w0(0u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w1(1u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w2(2, 0u, true, plonk_variable::column_type::witness); + plonk_variable w0(0, 0, true, plonk_variable::column_type::witness); + plonk_variable w1(1, 0, true, plonk_variable::column_type::witness); + plonk_variable w2(2, 0, true, plonk_variable::column_type::witness); - plonk_variable c0(0u, 0u, true, plonk_variable::column_type::constant); - plonk_variable c1(1u, 0u, true, plonk_variable::column_type::constant); - plonk_variable c2(2, 0u, true, plonk_variable::column_type::constant); + plonk_variable c0(0, 0, true, plonk_variable::column_type::constant); + plonk_variable c1(1, 0, true, plonk_variable::column_type::constant); + plonk_variable c2(2, 0, true, plonk_variable::column_type::constant); plonk_lookup_constraint lookup_constraint; @@ -436,7 +435,7 @@ namespace nil { lookup_constraint.table_id = 1; std::vector> lookup_constraints = {lookup_constraint}; - plonk_lookup_gate> lookup_gate(0u, lookup_constraints); + plonk_lookup_gate> lookup_gate(0, lookup_constraints); test_circuit.lookup_gates.push_back(lookup_gate); // Add constructor for lookup table @@ -467,7 +466,7 @@ namespace nil { constexpr static const std::size_t selector_columns_4 = 3; template - circuit_description, 5> circuit_test_4( + circuit_description> circuit_test_4( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { @@ -484,8 +483,9 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; test_circuit.table_rows = 1 << rows_log; + test_circuit.usable_rows = 5; std::vector> table(table_columns); for (std::size_t j = 0; j < table_columns; j++) { @@ -493,12 +493,9 @@ namespace nil { } // lookup inputs - table[0] = {unsigned(rnd() % 2), unsigned(rnd() % 2), unsigned(rnd() % 2), - unsigned(rnd() % 2), unsigned(rnd() % 2), 0u, 0u, 0u}; - table[1] = {unsigned(rnd() % 2), unsigned(rnd() % 2), unsigned(rnd() % 2), - unsigned(rnd() % 2), unsigned(rnd() % 2), 0u, 0u, 0u};; - 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], 0u, 0u, 0u}; + table[0] = {rnd() % 2, rnd() % 2, rnd(), rnd() % 2, rnd() % 2, 0u, 0u, 0u}; + table[1] = {rnd() % 2, rnd() % 2, rnd(), rnd() % 2, rnd() % 2, 0u, 0u, 0u};; + 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], 0u, 0u, 0u}; //lookup values @@ -529,13 +526,13 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); - plonk_variable w0(0u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w1(1u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w2(2, 0u, true, plonk_variable::column_type::witness); + plonk_variable w0(0, 0, true, plonk_variable::column_type::witness); + plonk_variable w1(1, 0, true, plonk_variable::column_type::witness); + plonk_variable w2(2, 0, true, plonk_variable::column_type::witness); - plonk_variable c0(0u, 0u, true, plonk_variable::column_type::constant); - plonk_variable c1(1u, 0u, true, plonk_variable::column_type::constant); - plonk_variable c2(2, 0u, true, plonk_variable::column_type::constant); + plonk_variable c0(0, 0, true, plonk_variable::column_type::constant); + plonk_variable c1(1, 0, true, plonk_variable::column_type::constant); + plonk_variable c2(2, 0, true, plonk_variable::column_type::constant); plonk_constraint mul_constraint; typename plonk_constraint::term_type w0_term(w0); @@ -544,7 +541,7 @@ namespace nil { mul_constraint -= w2; std::vector> mul_gate_costraints {mul_constraint}; - plonk_gate> mul_gate(1u, mul_gate_costraints); + plonk_gate> mul_gate(1, mul_gate_costraints); test_circuit.gates.push_back(mul_gate); plonk_lookup_constraint lookup_constraint; @@ -582,14 +579,13 @@ namespace nil { constexpr static const std::size_t usable_rows_5 = 30; template - circuit_description, usable_rows_5> + circuit_description> circuit_test_5( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { using assignment_type = typename FieldType::value_type; - constexpr static const std::size_t usable_rows = usable_rows_5; constexpr static const std::size_t witness_columns = witness_columns_5; constexpr static const std::size_t public_input_columns = public_columns_5; constexpr static const std::size_t constant_columns = constant_columns_5; @@ -597,8 +593,9 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; test_circuit.public_input_sizes = {witness_columns}; + test_circuit.usable_rows = usable_rows_5; std::vector> private_assignment(witness_columns); std::vector> public_input_assignment(public_input_columns); @@ -609,10 +606,13 @@ namespace nil { selectors_assignment[0].resize(test_circuit.usable_rows); for(std::size_t i = 0; i < witness_columns; i++) { private_assignment[i].resize(test_circuit.usable_rows); - private_assignment[i][0] = private_assignment[i][2] = public_input_assignment[0][i] = typename FieldType::value_type(rnd() % witness_columns); + private_assignment[i][0] = private_assignment[i][2] = public_input_assignment[0][i] = + typename FieldType::value_type(rnd() % witness_columns); private_assignment[i][1] = 1u; - plonk_variable pi(0u, i, false, plonk_variable::column_type::public_input); - plonk_variable wi(i, 0u, false, plonk_variable::column_type::witness); + plonk_variable pi( + 0, i, false, plonk_variable::column_type::public_input); + plonk_variable wi( + i, 0, false, plonk_variable::column_type::witness); test_circuit.copy_constraints.push_back(plonk_copy_constraint({pi, wi})); } selectors_assignment[0][1] = 1u; @@ -625,13 +625,13 @@ namespace nil { std::vector> mul_gate_constraints; for( std::size_t i = 0; i < witness_columns; i++){ - plonk_variable w0(i, -1u, true, plonk_variable::column_type::witness); - plonk_variable w1(i, 0u, true, plonk_variable::column_type::witness); - plonk_variable w2(i, 1u, true, plonk_variable::column_type::witness); + plonk_variable w0(i, -1, true, plonk_variable::column_type::witness); + plonk_variable w1(i, 0, true, plonk_variable::column_type::witness); + plonk_variable w2(i, 1, true, plonk_variable::column_type::witness); mul_gate_constraints.push_back(w0 - w1 * w2); } - plonk_gate> mul_gate(0u, mul_gate_constraints); + plonk_gate> mul_gate(0, mul_gate_constraints); test_circuit.gates.push_back(mul_gate); return test_circuit; @@ -655,7 +655,7 @@ namespace nil { constexpr static const std::size_t selector_columns_fib = 1; template - circuit_description, usable_rows> + circuit_description > circuit_test_fib( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine() ) { @@ -670,7 +670,8 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; + test_circuit.usable_rows = usable_rows; std::vector> table(table_columns); std::vector q_add(test_circuit.usable_rows); @@ -693,13 +694,13 @@ namespace nil { table[2][0] = zero; table[2][1] = one; - plonk_variable x0(0u, 0u, false, plonk_variable::column_type::witness); - plonk_variable x1(0u, 1u, false, plonk_variable::column_type::witness); - plonk_variable p0(1u, 0u, false, plonk_variable::column_type::public_input); - plonk_variable p1(1u, 1u, false, plonk_variable::column_type::public_input); + plonk_variable x0(0, 0, false, plonk_variable::column_type::witness); + plonk_variable x1(0, 1, false, plonk_variable::column_type::witness); + plonk_variable p0(1, 0, false, plonk_variable::column_type::public_input); + plonk_variable p1(1, 1, false, plonk_variable::column_type::public_input); -// test_circuit.copy_constraints.push_back(plonk_copy_constraint(x0u, p0)); -// test_circuit.copy_constraints.push_back(plonk_copy_constraint(x1u, p1)); +// test_circuit.copy_constraints.push_back(plonk_copy_constraint(x0, p0)); +// test_circuit.copy_constraints.push_back(plonk_copy_constraint(x1, p1)); for (std::size_t i = 2; i < test_circuit.usable_rows - 1; i++) { table[0][i] = table[0][i-2] + table[0][i-1]; @@ -726,9 +727,9 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); test_circuit.table_rows = zk_padding>(test_circuit.table, alg_rnd); - plonk_variable w0(0u, -1u, true, plonk_variable::column_type::witness); - plonk_variable w1(0u, 0u, true, plonk_variable::column_type::witness); - plonk_variable w2(0u, 1u, true, plonk_variable::column_type::witness); + plonk_variable w0(0, -1, true, plonk_variable::column_type::witness); + plonk_variable w1(0, 0, true, plonk_variable::column_type::witness); + plonk_variable w2(0, 1, true, plonk_variable::column_type::witness); typename plonk_constraint::term_type w0_term(w0); typename plonk_constraint::term_type w1_term(w1); @@ -740,7 +741,7 @@ namespace nil { fib_constraint -= w2_term; std::vector> fib_costraints {fib_constraint}; - plonk_gate> fib_gate(0u, fib_costraints); + plonk_gate> fib_gate(0, fib_costraints); test_circuit.gates.push_back(fib_gate); return test_circuit; @@ -772,7 +773,7 @@ namespace nil { constexpr static const std::size_t usable_rows_6 = 6; template - circuit_description, usable_rows_6> circuit_test_6( + circuit_description> circuit_test_6( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { @@ -787,7 +788,8 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; + test_circuit.usable_rows = usable_rows_6; std::vector> table(table_columns); for (std::size_t j = 0; j < table_columns; j++) { @@ -795,10 +797,8 @@ namespace nil { } // lookup inputs - table[0] = {unsigned(rnd() % 5 + 2), unsigned(rnd() % 5 + 2), unsigned(rnd() % 5 + 2), - unsigned(rnd() % 5 + 2), unsigned(rnd() % 5 + 2), unsigned(rnd() % 5 + 2)}; - table[1] = {7u, 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]}; + table[0] = {rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2, rnd() % 5 + 2}; + table[1] = {7u, 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]}; // selectors // Reserved zero row for unselected lookup input rows @@ -833,9 +833,9 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); test_circuit.table_rows = zk_padding(test_circuit.table, alg_rnd); - plonk_variable w0 (0, 0, true, plonk_variable::column_type::witness); + plonk_variable w0( 0, 0, true, plonk_variable::column_type::witness); plonk_variable w0_1(0,-1, true, plonk_variable::column_type::witness); - plonk_variable w1 (1, 0, true, plonk_variable::column_type::witness); + plonk_variable w1( 1, 0, true, plonk_variable::column_type::witness); plonk_variable c0(0, 0, true, plonk_variable::column_type::constant); plonk_variable c1(1, 0, true, plonk_variable::column_type::constant); @@ -850,7 +850,7 @@ namespace nil { lookup_constraint2.table_id = 2; std::vector> lookup_constraints = {lookup_constraint1, lookup_constraint2}; - plonk_lookup_gate> lookup_gate(1u, lookup_constraints); + plonk_lookup_gate> lookup_gate(1, lookup_constraints); test_circuit.lookup_gates.push_back(lookup_gate); @@ -866,11 +866,11 @@ namespace nil { test_circuit.lookup_gates.push_back(lookup_gate2); // Add constructor for lookup table - plonk_lookup_table table1(1u, 0u); // 2 -- selector_id, 3 -- number of columns; + plonk_lookup_table table1(1, 0); // 2 -- selector_id, 3 -- number of columns; table1.append_option({c0}); test_circuit.lookup_tables.push_back(table1); - plonk_lookup_table table2(1u, 0u); // 2 -- selector_id, 3 -- number of columns; + plonk_lookup_table table2(1, 0); // 2 -- selector_id, 3 -- number of columns; table2.append_option({c0}); table2.append_option({c1}); table2.append_option({c2}); @@ -880,8 +880,8 @@ namespace nil { } // Big columns rotations check: - // Table 1: LT1 options: {L1u, L2, L3, L4, L5, L6, L7} - // Table 2: LT2 options: {L1u, L2} || { L3, L4 } + // Table 1: LT1 options: {L1, L2, L3, L4, L5, L6, L7} + // Table 2: LT2 options: {L1, L2} || { L3, L4 } // Table 3: LT2 options: {L5} || {L6} || {L7} // Lookup gate1: // w1{-3}, w1{-2}, w1{-1}, w1, w1{+1}, w1{+2},w1{+3}, \in Table 1 selector s2 @@ -914,7 +914,7 @@ namespace nil { constexpr static const std::size_t usable_rows_7 = 14; template - circuit_description, usable_rows_7> circuit_test_7( + circuit_description> circuit_test_7( typename nil::crypto3::random::algebraic_engine alg_rnd = nil::crypto3::random::algebraic_engine(), boost::random::mt11213b rnd = boost::random::mt11213b() ) { @@ -929,7 +929,8 @@ namespace nil { typedef placeholder_circuit_params circuit_params; - circuit_description test_circuit; + circuit_description test_circuit; + test_circuit.usable_rows = usable_rows_7; std::vector> table(table_columns); for (std::size_t j = 0; j < table_columns; j++) { @@ -984,17 +985,15 @@ namespace nil { public_input_assignment, constant_assignment, selectors_assignment)); test_circuit.table_rows = zk_padding(test_circuit.table, alg_rnd); - plonk_variable w0(0, 0, true, - plonk_variable::column_type::witness); - plonk_variable w0__7(0, -7, true, - plonk_variable::column_type::witness); + plonk_variable w0( 0, 0, true, plonk_variable::column_type::witness); + plonk_variable w0__7(0,-7, true, plonk_variable::column_type::witness); plonk_constraint add_constraint; add_constraint += w0; add_constraint -= w0__7; std::vector> add_gate_costraints {add_constraint}; - plonk_gate> add_gate(0u, add_gate_costraints); + plonk_gate> add_gate(0, add_gate_costraints); test_circuit.gates.push_back(add_gate); plonk_variable w0__3( 0,-3, true, plonk_variable::column_type::witness); @@ -1018,10 +1017,10 @@ namespace nil { lookup_constraint1.table_id = 1; std::vector> lookup_constraints = {lookup_constraint1}; - plonk_lookup_gate> lookup_gate(1u, lookup_constraints); + plonk_lookup_gate> lookup_gate(1, lookup_constraints); test_circuit.lookup_gates.push_back(lookup_gate); - plonk_variable w1(1, 0, true, plonk_variable::column_type::witness); + plonk_variable w1( 1, 0, true, plonk_variable::column_type::witness); plonk_lookup_constraint lookup_constraint2; lookup_constraint2.lookup_input = {w0, w1}; lookup_constraint2.table_id = 2; @@ -1030,7 +1029,7 @@ namespace nil { plonk_lookup_gate> lookup_gate2(2, lookup_constraints2); test_circuit.lookup_gates.push_back(lookup_gate2); - plonk_variable w1__1( 1u, -1u, true, plonk_variable::column_type::witness); + plonk_variable w1__1( 1, -1, true, plonk_variable::column_type::witness); plonk_lookup_constraint lookup_constraint3; typename plonk_constraint::term_type w1__1_term(w1__1); typename plonk_constraint::term_type w1_term(w1); diff --git a/libs/marshalling/zk/test/kzg_commitment.cpp b/libs/marshalling/zk/test/kzg_commitment.cpp index c9fe14995..891bdc678 100644 --- a/libs/marshalling/zk/test/kzg_commitment.cpp +++ b/libs/marshalling/zk/test/kzg_commitment.cpp @@ -25,7 +25,6 @@ // SOFTWARE. //---------------------------------------------------------------------------// -#include "nil/crypto3/zk/commitments/batched_commitment.hpp" #define BOOST_TEST_MODULE crypto3_marshalling_kzg_commitment_test #include @@ -74,6 +73,7 @@ #include #include #include +#include #include #include @@ -83,8 +83,6 @@ #include "detail/circuits.hpp" - - template< typename curve_type, typename transcript_hash_type @@ -155,52 +153,3 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(placeholder_class_test, F, TestFixtures) { } BOOST_AUTO_TEST_SUITE_END() - -/* -template< - typename curve_type, - typename transcript_hash_type - > -struct batched_kzg_test_initializer { - bool run_test() { - typedef typename curve_type::scalar_field_type::value_type scalar_value_type; - - using kzg_type = zk::commitments::batched_kzg; - typedef typename kzg_type::transcript_type transcript_type; - using endianness = nil::marshalling::option::big_endian; - - scalar_value_type alpha = 7; - typename kzg_type::params_type params(8, 8, alpha); - - typename kzg_type::polynomial_type poly; - - poly.template from_coefficients>({{ 1, 2, 3, 4, 5, 6, 7, 8}}); - - auto commitment = zk::algorithms::commit_one(params, poly); - - auto filled_commitment = marshalling::types::fill_commitment(commitment); - auto _commitment = marshalling::types::make_commitment(filled_commitment); - - bool result = commitment == _commitment; - BOOST_CHECK( result ); - - std::cout << "test completed for [" << typeid(curve_type).name() << "]" < >, - batched_kzg_test_initializer< algebra::curves::mnt4_298, hashes::keccak_1600<256> >, - batched_kzg_test_initializer< algebra::curves::mnt6_298, hashes::keccak_1600<256> > - >; - -BOOST_AUTO_TEST_CASE_TEMPLATE(batched_kzg_test, F, TestFixtures) { - F fixture; - BOOST_CHECK(fixture.run_test()); -} - -BOOST_AUTO_TEST_SUITE_END() -*/ diff --git a/libs/marshalling/zk/test/placeholder_common_data.cpp b/libs/marshalling/zk/test/placeholder_common_data.cpp index 7cf32bf6d..3bc0ba514 100644 --- a/libs/marshalling/zk/test/placeholder_common_data.cpp +++ b/libs/marshalling/zk/test/placeholder_common_data.cpp @@ -1,3 +1,31 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov +// Copyright (c) 2021 Ilias Khairullin +// Copyright (c) 2022-2023 Elena Tatuzova +// Copyright (c) 2024 Vasiliy Olekhov +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + #define BOOST_TEST_MODULE crypto3_marshalling_placeholder_common_data_test #include @@ -5,11 +33,9 @@ #include #include #include -#include #include #include -#include -#include +#include #include #include @@ -19,14 +45,10 @@ #include #include -#include -#include -#include - -//#include -//#include -//#include +#include +#include +#include #include #include @@ -36,16 +58,18 @@ #include #include -#include -#include -#include - +#include +#include +#include #include #include #include #include +#include +#include + #include #include #include @@ -53,19 +77,21 @@ #include #include #include +#include #include -#include -#include -#include - #include #include #include #include -#include "./detail/circuits.hpp" +#include +#include +#include + +#include "./detail/circuits.hpp" +using namespace nil; using namespace nil::crypto3; using namespace nil::crypto3::zk; using namespace nil::crypto3::zk::snark; @@ -156,15 +182,11 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1_poseidon) using curve_type = algebra::curves::pallas; using field_type = typename curve_type::base_field_type; using poseidon_type = hashes::poseidon>; + using merkle_hash_type = poseidon_type; using transcript_hash_type = poseidon_type; struct placeholder_test_params { - constexpr static const std::size_t witness_columns = witness_columns_1; - constexpr static const std::size_t public_input_columns = public_columns_1; - constexpr static const std::size_t constant_columns = constant_columns_1; - constexpr static const std::size_t selector_columns = selector_columns_1; - constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -182,26 +204,29 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1_poseidon) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_AUTO_TEST_CASE(prover_test) { +BOOST_AUTO_TEST_CASE(common_data_marshalling_test) { auto circuit = circuit_test_1(); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); - typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); + typename policy_type::constraint_system_type constraint_system( + circuit.gates, + circuit.copy_constraints, + circuit.lookup_gates, + circuit.lookup_tables + ); typename policy_type::variable_assignment_type assignments = circuit.table; std::vector columns_with_copy_constraints = {0, 1, 2, 3}; - typename lpc_type::fri_type::params_type fri_params( 1, table_rows_log, placeholder_test_params::lambda, 4, true ); @@ -226,15 +251,11 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1) using curve_type = algebra::curves::pallas; using field_type = typename curve_type::base_field_type; - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - struct placeholder_test_params { - constexpr static const std::size_t witness_columns = witness_columns_1; - constexpr static const std::size_t public_input_columns = public_columns_1; - constexpr static const std::size_t constant_columns = constant_columns_1; - constexpr static const std::size_t selector_columns = selector_columns_1; + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; + struct placeholder_test_params { constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -252,21 +273,25 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_AUTO_TEST_CASE(prover_test) { +BOOST_AUTO_TEST_CASE(common_data_marshalling_test) { auto circuit = circuit_test_1(); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); - typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); + typename policy_type::constraint_system_type constraint_system( + circuit.gates, + circuit.copy_constraints, + circuit.lookup_gates, + circuit.lookup_tables + ); typename policy_type::variable_assignment_type assignments = circuit.table; std::vector columns_with_copy_constraints = {0, 1, 2, 3}; @@ -298,14 +323,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit2) using field_type = typename curve_type::scalar_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = 3; - constexpr static const std::size_t public_input_columns = 1; - constexpr static const std::size_t constant_columns = 0; - constexpr static const std::size_t selector_columns = 2; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 1; constexpr static const std::size_t m = 2; }; @@ -334,16 +353,21 @@ BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_in ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); + std::size_t table_rows_log = std::log2(desc.rows_amount); + + typename policy_type::constraint_system_type constraint_system( + circuit.gates, + circuit.copy_constraints, + circuit.lookup_gates, + circuit.lookup_tables + ); typename policy_type::variable_assignment_type assignments = circuit.table; std::vector columns_with_copy_constraints = {0, 1, 2, 3}; @@ -367,7 +391,6 @@ BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_in } BOOST_AUTO_TEST_SUITE_END() - BOOST_AUTO_TEST_SUITE(placeholder_circuit3) using Endianness = nil::marshalling::option::big_endian; using TTypeBase = nil::marshalling::field_type; @@ -375,14 +398,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit3) using field_type = typename curve_type::base_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = witness_columns_3; - constexpr static const std::size_t public_input_columns = public_columns_3; - constexpr static const std::size_t constant_columns = constant_columns_3; - constexpr static const std::size_t selector_columns = selector_columns_3; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -400,22 +417,21 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit3) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initializer) { +BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_initializer) { auto circuit = circuit_test_3( alg_random_engines.template get_alg_engine(), generic_random_engine ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -444,7 +460,6 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali } BOOST_AUTO_TEST_SUITE_END() - BOOST_AUTO_TEST_SUITE(placeholder_circuit4) using Endianness = nil::marshalling::option::big_endian; using TTypeBase = nil::marshalling::field_type; @@ -452,14 +467,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit4) using field_type = typename curve_type::base_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = witness_columns_4; - constexpr static const std::size_t public_input_columns = public_columns_4; - constexpr static const std::size_t constant_columns = constant_columns_4; - constexpr static const std::size_t selector_columns = selector_columns_4; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -477,22 +486,21 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit4) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initializer) { +BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_initializer) { auto circuit = circuit_test_4( alg_random_engines.template get_alg_engine(), generic_random_engine ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -529,21 +537,14 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit5) using field_type = typename curve_type::scalar_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = witness_columns_5; - constexpr static const std::size_t public_input_columns = public_columns_5; - constexpr static const std::size_t constant_columns = constant_columns_5; - constexpr static const std::size_t selector_columns = selector_columns_5; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 1; constexpr static const std::size_t m = 2; }; - using circuit_t_params = placeholder_circuit_params; + using circuit_t_params = placeholder_circuit_params; using transcript_type = typename transcript::fiat_shamir_heuristic_sequential; - using lpc_params_type = commitments::list_polynomial_commitment_params< typename placeholder_test_params::merkle_hash_type, typename placeholder_test_params::transcript_hash_type, @@ -553,7 +554,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit5) using lpc_type = commitments::list_polynomial_commitment; using lpc_scheme_type = typename commitments::lpc_commitment_scheme; using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; - using policy_type = zk::snark::detail::placeholder_policy; BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_initializer) { @@ -565,19 +565,22 @@ BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_in ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); - typename policy_type::variable_assignment_type assignments = circuit.table; + std::size_t table_rows_log = std::log2(desc.rows_amount); - bool verifier_res; + typename policy_type::constraint_system_type constraint_system( + circuit.gates, + circuit.copy_constraints, + circuit.lookup_gates, + circuit.lookup_tables + ); + typename policy_type::variable_assignment_type assignments = circuit.table; // LPC commitment scheme typename lpc_type::fri_type::params_type fri_params( @@ -605,14 +608,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit6) using field_type = typename curve_type::base_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = witness_columns_6; - constexpr static const std::size_t public_input_columns = public_columns_6; - constexpr static const std::size_t constant_columns = constant_columns_6; - constexpr static const std::size_t selector_columns = selector_columns_6; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -630,22 +627,21 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit6) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initializer) { +BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_initializer) { auto circuit = circuit_test_6( alg_random_engines.template get_alg_engine(), generic_random_engine ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -681,14 +677,8 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit7) using field_type = typename curve_type::base_field_type; struct placeholder_test_params { - using merkle_hash_type = hashes::keccak_1600<512>; - using transcript_hash_type = hashes::keccak_1600<512>; - - constexpr static const std::size_t witness_columns = witness_columns_7; - constexpr static const std::size_t public_input_columns = public_columns_7; - constexpr static const std::size_t constant_columns = constant_columns_7; - constexpr static const std::size_t selector_columns = selector_columns_7; - + using merkle_hash_type = hashes::keccak_1600<256>; + using transcript_hash_type = hashes::keccak_1600<256>; constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -706,21 +696,21 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit7) using lpc_placeholder_params_type = nil::crypto3::zk::snark::placeholder_params; using policy_type = zk::snark::detail::placeholder_policy; -BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initializer) { +BOOST_FIXTURE_TEST_CASE(common_data_marshalling_test, test_tools::random_test_initializer) { auto circuit = circuit_test_7( alg_random_engines.template get_alg_engine(), generic_random_engine ); + plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -751,23 +741,12 @@ BOOST_AUTO_TEST_SUITE_END() template< typename curve_type, - typename merkle_hash_type, typename transcript_hash_type, - std::size_t WitnessColumns, - std::size_t PublicInputColumns, - std::size_t ConstantColumns, - std::size_t SelectorColumns, - std::size_t UsableRowsAmount, bool UseGrinding = false> struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initializer { using field_type = typename curve_type::scalar_field_type; struct placeholder_test_params { - constexpr static const std::size_t witness_columns = WitnessColumns; - constexpr static const std::size_t public_input_columns = PublicInputColumns; - constexpr static const std::size_t constant_columns = ConstantColumns; - constexpr static const std::size_t selector_columns = SelectorColumns; - constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -784,23 +763,20 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali using circuit_type = circuit_description, - UsableRowsAmount>; - - placeholder_kzg_test_fixture_v2() - : desc(WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns) + placeholder_circuit_params >; + + placeholder_kzg_test_fixture_v2(circuit_type const& circuit_in) + : circuit(circuit_in), + desc(circuit_in.table.witnesses().size(), + circuit_in.table.public_inputs().size(), + circuit_in.table.constants().size(), + circuit_in.table.selectors().size(), + circuit_in.usable_rows, + circuit_in.table_rows) { } bool run_test() { - typename field_type::value_type pi0 = this->alg_random_engines.template get_alg_engine()(); - circuit_type circuit = circuit_test_t( - pi0, - this->alg_random_engines.template get_alg_engine(), - this->generic_random_engine - ); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; std::size_t table_rows_log = std::log2(circuit.table_rows); typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); @@ -808,10 +784,8 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali std::vector columns_with_copy_constraints = {0, 1, 2, 3}; - bool verifier_res; - // KZG commitment scheme - typename kzg_type::field_type::value_type alpha (7); + typename kzg_type::field_type::value_type alpha(7u); auto kzg_params = kzg_scheme_type::create_params(1 << table_rows_log, alpha); kzg_scheme_type kzg_scheme(kzg_params); @@ -834,72 +808,30 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali return true; } + circuit_type circuit; plonk_table_description desc; }; -/* + BOOST_AUTO_TEST_SUITE(placeholder_circuit2_kzg_v2) using TestFixtures = boost::mpl::list< - // placeholder_kzg_test_fixture_v2< - // algebra::curves::bls12_381, - // hashes::keccak_1600<256>, - // hashes::keccak_1600<256>, - // witness_columns_t, - // public_columns_t, - // constant_columns_t, - // selector_columns_t, - // usable_rows_t, - // permutation_t, true>, - placeholder_kzg_test_fixture_v2< - algebra::curves::alt_bn128_254, - hashes::keccak_1600<256>, - hashes::keccak_1600<256>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - 4, true> -// , placeholder_kzg_test_fixture_v2< -// algebra::curves::mnt4_298, -// hashes::keccak_1600<256>, -// hashes::keccak_1600<256>, -// witness_columns_t, -// public_columns_t, -// constant_columns_t, -// selector_columns_t, -// usable_rows_t, -// permutation_t, true> -// , placeholder_kzg_test_fixture_v2< -// algebra::curves::mnt6_298, -// hashes::keccak_1600<256>, -// hashes::keccak_1600<256>, -// witness_columns_t, -// public_columns_t, -// constant_columns_t, -// selector_columns_t, -// usable_rows_t, -// permutation_t, true> - // *, -- Not yet implemented - // placeholder_kzg_test_fixture< - // algebra::curves::mnt6_298, - // hashes::poseidon>, - // hashes::poseidon>, - // witness_columns_t, - // public_columns_t, - // constant_columns_t, - // selector_columns_t, - //usable_rows_t, - // 4, - // true> - // + placeholder_kzg_test_fixture_v2< algebra::curves::bls12_381, hashes::keccak_1600<256>, true>, + placeholder_kzg_test_fixture_v2< algebra::curves::mnt4_298, hashes::keccak_1600<256>, true>, + placeholder_kzg_test_fixture_v2< algebra::curves::mnt6_298, hashes::keccak_1600<256>, true> >; -BOOST_AUTO_TEST_CASE_TEMPLATE(prover_test, F, TestFixtures) { - F fixture; +BOOST_AUTO_TEST_CASE_TEMPLATE(common_data_marshalling_test, F, TestFixtures) { + using field_type = typename F::field_type; + test_tools::random_test_initializer random_test_initializer; + typename field_type::value_type pi0 = random_test_initializer.alg_random_engines.template get_alg_engine()(); + auto circuit = circuit_test_t( + pi0, + random_test_initializer.alg_random_engines.template get_alg_engine(), + random_test_initializer.generic_random_engine + ); + F fixture(circuit); BOOST_CHECK(fixture.run_test()); } BOOST_AUTO_TEST_SUITE_END() -*/ diff --git a/libs/marshalling/zk/test/placeholder_proof.cpp b/libs/marshalling/zk/test/placeholder_proof.cpp index 2eb144053..1e5a1c6c0 100644 --- a/libs/marshalling/zk/test/placeholder_proof.cpp +++ b/libs/marshalling/zk/test/placeholder_proof.cpp @@ -3,6 +3,7 @@ // Copyright (c) 2021 Nikita Kaskov // Copyright (c) 2021 Ilias Khairullin // Copyright (c) 2022-2023 Elena Tatuzova +// Copyright (c) 2024 Vasiliy Olekhov // // MIT License // @@ -31,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -58,10 +58,7 @@ #include #include #include -/* -#include -#include -*/ + #include #include #include @@ -143,53 +140,6 @@ void print_placeholder_proof(ProofIterator proof_begin, ProofIterator proof_end, out.close(); } -template -void print_field_element(std::ostream &os, - const typename nil::crypto3::algebra::fields::detail::element_fp &e, - bool endline = true) { - os << e.data; - if (endline) { - os << std::endl; - } -} - -template -void print_field_element(std::ostream &os, - const typename nil::crypto3::algebra::fields::detail::element_fp2 &e, - bool endline = true) { - os << e.data[0].data << ", " << e.data[1].data; - if (endline) { - os << std::endl; - } -} - -template -typename std::enable_if::value>::type -print_curve_point(std::ostream &os, - const nil::crypto3::algebra::curves::detail::curve_element &p) { - os << "( X: ["; - print_field_element(os, p.X, false); - os << "], Y: ["; - print_field_element(os, p.Y, false); - os << "] )" << std::endl; -} - -template -typename std::enable_if::value || - std::is_same::value - // || std::is_same::value ->::type -print_curve_point(std::ostream &os, - const nil::crypto3::algebra::curves::detail::curve_element &p) { - os << "( X: ["; - print_field_element(os, p.X, false); - os << "], Y: ["; - print_field_element(os, p.Y, false); - os << "], Z:["; - print_field_element(os, p.Z, false); - os << "] )" << std::endl; -} - template void test_placeholder_proof(const ProofType &proof, const CommitmentParamsType& params, std::string output_file = "") { @@ -274,11 +224,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1_poseidon) using transcript_hash_type = poseidon_type; struct placeholder_test_params { - constexpr static const std::size_t witness_columns = witness_columns_1; - constexpr static const std::size_t public_input_columns = public_columns_1; - constexpr static const std::size_t constant_columns = constant_columns_1; - constexpr static const std::size_t selector_columns = selector_columns_1; - constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -304,15 +249,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -367,11 +311,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit1) using transcript_hash_type = hashes::keccak_1600<256>; struct placeholder_test_params { - constexpr static const std::size_t witness_columns = witness_columns_1; - constexpr static const std::size_t public_input_columns = public_columns_1; - constexpr static const std::size_t constant_columns = constant_columns_1; - constexpr static const std::size_t selector_columns = selector_columns_1; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -397,15 +336,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -463,12 +401,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit2) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_t; - constexpr static const std::size_t public_input_columns = public_columns_t; - constexpr static const std::size_t constant_columns = constant_columns_t; - constexpr static const std::size_t selector_columns = selector_columns_t; - constexpr static const std::size_t lambda = 1; constexpr static const std::size_t m = 2; }; @@ -497,14 +429,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); + + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -561,12 +493,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit3) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_3; - constexpr static const std::size_t public_input_columns = public_columns_3; - constexpr static const std::size_t constant_columns = constant_columns_3; - constexpr static const std::size_t selector_columns = selector_columns_3; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -591,15 +517,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -650,12 +575,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit4) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_4; - constexpr static const std::size_t public_input_columns = public_columns_4; - constexpr static const std::size_t constant_columns = constant_columns_4; - constexpr static const std::size_t selector_columns = selector_columns_4; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -680,15 +599,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -739,12 +657,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit5) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_5; - constexpr static const std::size_t public_input_columns = public_columns_5; - constexpr static const std::size_t constant_columns = constant_columns_5; - constexpr static const std::size_t selector_columns = selector_columns_5; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -769,15 +681,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test100, test_tools::random_test_initi ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -825,15 +736,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -884,12 +794,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit6) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_6; - constexpr static const std::size_t public_input_columns = public_columns_6; - constexpr static const std::size_t constant_columns = constant_columns_6; - constexpr static const std::size_t selector_columns = selector_columns_6; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -914,15 +818,14 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali ); plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::ceil(std::log2(circuit.table_rows)); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -972,12 +875,6 @@ BOOST_AUTO_TEST_SUITE(placeholder_circuit7) struct placeholder_test_params { using merkle_hash_type = hashes::keccak_1600<256>; using transcript_hash_type = hashes::keccak_1600<256>; - - constexpr static const std::size_t witness_columns = witness_columns_7; - constexpr static const std::size_t public_input_columns = public_columns_7; - constexpr static const std::size_t constant_columns = constant_columns_7; - constexpr static const std::size_t selector_columns = selector_columns_7; - constexpr static const std::size_t lambda = 10; constexpr static const std::size_t m = 2; }; @@ -1000,16 +897,16 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test, test_tools::random_test_initiali alg_random_engines.template get_alg_engine(), generic_random_engine ); + plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::log2(circuit.table_rows); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -1053,16 +950,16 @@ BOOST_FIXTURE_TEST_CASE(proof_marshalling_test10, test_tools::random_test_initia alg_random_engines.template get_alg_engine(), generic_random_engine ); + plonk_table_description desc( - placeholder_test_params::witness_columns, - placeholder_test_params::public_input_columns, - placeholder_test_params::constant_columns, - placeholder_test_params::selector_columns - ); + circuit.table.witnesses().size(), + circuit.table.public_inputs().size(), + circuit.table.constants().size(), + circuit.table.selectors().size(), + circuit.usable_rows, + circuit.table_rows); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; - std::size_t table_rows_log = std::log2(circuit.table_rows); + std::size_t table_rows_log = std::log2(desc.rows_amount); typename policy_type::constraint_system_type constraint_system( circuit.gates, @@ -1105,24 +1002,13 @@ BOOST_AUTO_TEST_SUITE_END() template< typename curve_type, - typename merkle_hash_type, typename transcript_hash_type, - std::size_t WitnessColumns, - std::size_t PublicInputColumns, - std::size_t ConstantColumns, - std::size_t SelectorColumns, - std::size_t usable_rows_amount, bool UseGrinding = false> struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initializer { // TODO: move to common file using field_type = typename curve_type::scalar_field_type; struct placeholder_test_params { - constexpr static const std::size_t witness_columns = WitnessColumns; - constexpr static const std::size_t public_input_columns = PublicInputColumns; - constexpr static const std::size_t constant_columns = ConstantColumns; - constexpr static const std::size_t selector_columns = SelectorColumns; - constexpr static const std::size_t lambda = 40; constexpr static const std::size_t m = 2; }; @@ -1139,23 +1025,21 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali using circuit_type = circuit_description, - usable_rows_amount>; - - placeholder_kzg_test_fixture_v2() - : desc(WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns) + placeholder_circuit_params >; + + placeholder_kzg_test_fixture_v2(circuit_type const& circuit_in) + : circuit(circuit_in), + desc(circuit_in.table.witnesses().size(), + circuit_in.table.public_inputs().size(), + circuit_in.table.constants().size(), + circuit_in.table.selectors().size(), + circuit_in.usable_rows, + circuit_in.table_rows) { } bool run_test() { typename field_type::value_type pi0 = this->alg_random_engines.template get_alg_engine()(); - circuit_type circuit = circuit_test_t( - pi0, - this->alg_random_engines.template get_alg_engine(), - this->generic_random_engine - ); - desc.rows_amount = circuit.table_rows; - desc.usable_rows_amount = circuit.usable_rows; std::size_t table_rows_log = std::log2(circuit.table_rows); typename policy_type::constraint_system_type constraint_system(circuit.gates, circuit.copy_constraints, circuit.lookup_gates); @@ -1202,6 +1086,7 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali return true; } + circuit_type circuit; plonk_table_description desc; }; @@ -1209,65 +1094,21 @@ struct placeholder_kzg_test_fixture_v2 : public test_tools::random_test_initiali BOOST_AUTO_TEST_SUITE(placeholder_circuit2_kzg_v2) using TestFixtures = boost::mpl::list< - placeholder_kzg_test_fixture_v2< - algebra::curves::bls12_381, - hashes::keccak_1600<256>, - hashes::keccak_1600<256>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - true> - /* - , placeholder_kzg_test_fixture< - algebra::curves::alt_bn128_254, - hashes::keccak_1600<256>, - hashes::keccak_1600<256>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - 4, true> - */ - , placeholder_kzg_test_fixture_v2< - algebra::curves::mnt4_298, - hashes::keccak_1600<256>, - hashes::keccak_1600<256>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - true> - , placeholder_kzg_test_fixture_v2< - algebra::curves::mnt6_298, - hashes::keccak_1600<256>, - hashes::keccak_1600<256>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - true> - /*, -- Not yet implemented - placeholder_kzg_test_fixture< - algebra::curves::mnt6_298, - hashes::poseidon>, - hashes::poseidon>, - witness_columns_t, - public_columns_t, - constant_columns_t, - selector_columns_t, - usable_rows_t, - 4, - true> - */ + placeholder_kzg_test_fixture_v2< algebra::curves::bls12_381, hashes::keccak_1600<256>, true>, + placeholder_kzg_test_fixture_v2< algebra::curves::mnt4_298, hashes::keccak_1600<256>, true>, + placeholder_kzg_test_fixture_v2< algebra::curves::mnt6_298, hashes::keccak_1600<256>, true> >; -BOOST_AUTO_TEST_CASE_TEMPLATE(prover_test, F, TestFixtures) { - F fixture; +BOOST_AUTO_TEST_CASE_TEMPLATE(proof_marshalling_test, F, TestFixtures) { + using field_type = typename F::field_type; + test_tools::random_test_initializer random_test_initializer; + typename field_type::value_type pi0 = random_test_initializer.alg_random_engines.template get_alg_engine()(); + auto circuit = circuit_test_t( + pi0, + random_test_initializer.alg_random_engines.template get_alg_engine(), + random_test_initializer.generic_random_engine + ); + F fixture(circuit); BOOST_CHECK(fixture.run_test()); }