Skip to content

Commit

Permalink
Split placeholder tests #330
Browse files Browse the repository at this point in the history
tests update

cmake bump #330

Updated circuit_description, keccak-256, sha2-256 #330

Updates for test suite #330

Added quotient polynomial chunks test #330

rm placeholder.cpp #330
  • Loading branch information
vo-nil committed May 24, 2024
1 parent ca5f455 commit bf751c7
Show file tree
Hide file tree
Showing 15 changed files with 1,807 additions and 1,639 deletions.
10 changes: 9 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ set(TESTS_NAMES
"systems/plonk/pickles/to_field"
"systems/plonk/pickles/to_group"

"systems/plonk/placeholder/placeholder"
"systems/plonk/placeholder/placeholder_circuits"
"systems/plonk/placeholder/placeholder_goldilocks"
"systems/plonk/placeholder/placeholder_lookup_argument"
"systems/plonk/placeholder/placeholder_gate_argument"
"systems/plonk/placeholder/placeholder_permutation_argument"
"systems/plonk/placeholder/placeholder_kzg"
"systems/plonk/placeholder/placeholder_hashes"
"systems/plonk/placeholder/placeholder_curves"
"systems/plonk/placeholder/placeholder_quotient_polynomial_chunks"

# "systems/pcd/r1cs_pcd/r1cs_mp_ppzkpcd/r1cs_mp_ppzkpcd"
# "systems/pcd/r1cs_pcd/r1cs_sp_ppzkpcd/r1cs_sp_ppzkpcd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#ifndef CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP
#define CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP

#include <boost/test/included/unit_test.hpp>
#include <regex>

#include <nil/crypto3/algebra/random_element.hpp>
#include <nil/crypto3/random/algebraic_random_device.hpp>
#include <nil/crypto3/random/algebraic_engine.hpp>
Expand Down
53 changes: 28 additions & 25 deletions test/systems/plonk/placeholder/circuits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

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

#include <map>

#include <nil/crypto3/algebra/random_element.hpp>

#include <nil/crypto3/math/polynomial/polynomial.hpp>
Expand All @@ -54,7 +56,7 @@ namespace nil {
namespace crypto3 {
namespace zk {
namespace snark {
template<typename FieldType, typename ParamsType, std::size_t usable_rows_amount>
template<typename FieldType, typename ParamsType>
class circuit_description {
typedef zk::snark::detail::placeholder_policy<FieldType, ParamsType> policy_type;

Expand All @@ -63,7 +65,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;

Expand Down Expand Up @@ -96,14 +98,12 @@ namespace nil {
const std::size_t rows_amount_1 = 13;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, rows_amount_1> circuit_test_1(
circuit_description<FieldType, placeholder_circuit_params<FieldType>> circuit_test_1(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
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;
Expand All @@ -112,7 +112,8 @@ namespace nil {
witness_columns + public_columns + constant_columns;

typedef placeholder_circuit_params<FieldType> circuit_params;
circuit_description<FieldType, circuit_params, usable_rows> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.usable_rows = rows_amount_1;
std::vector<std::vector<typename FieldType::value_type>> table(table_columns);

std::vector<typename FieldType::value_type> q_add(test_circuit.usable_rows);
Expand Down Expand Up @@ -229,15 +230,14 @@ namespace nil {
constexpr static const std::size_t usable_rows_t = 5;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows_t>
circuit_description<FieldType, placeholder_circuit_params<FieldType>>
circuit_test_t(
typename FieldType::value_type pi0 = 0u,
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
boost::random::mt11213b rnd = boost::random::mt11213b()
) {
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;
Expand All @@ -247,8 +247,9 @@ namespace nil {

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.public_input_sizes = {3};
test_circuit.usable_rows = usable_rows_t;

std::vector<std::vector<typename FieldType::value_type>> table(table_columns);

Expand Down Expand Up @@ -362,7 +363,7 @@ namespace nil {
constexpr static const std::size_t usable_rows_3 = 4;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows_3> circuit_test_3(
circuit_description<FieldType, placeholder_circuit_params<FieldType>> circuit_test_3(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
boost::random::mt11213b rnd = boost::random::mt11213b()
) {
Expand All @@ -374,11 +375,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<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.usable_rows = usable_rows_3;

std::vector<std::vector<typename FieldType::value_type>> table(table_columns);
for (std::size_t j = 0; j < table_columns; j++) {
Expand Down Expand Up @@ -467,7 +468,7 @@ namespace nil {
constexpr static const std::size_t selector_columns_4 = 3;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, 5> circuit_test_4(
circuit_description<FieldType, placeholder_circuit_params<FieldType>> circuit_test_4(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
boost::random::mt11213b rnd = boost::random::mt11213b()
) {
Expand All @@ -484,8 +485,9 @@ namespace nil {

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, 5> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.table_rows = 1 << rows_log;
test_circuit.usable_rows = 5;

std::vector<std::vector<typename FieldType::value_type>> table(table_columns);
for (std::size_t j = 0; j < table_columns; j++) {
Expand Down Expand Up @@ -579,25 +581,23 @@ namespace nil {
constexpr static const std::size_t usable_rows_5 = 30;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows_5>
circuit_description<FieldType, placeholder_circuit_params<FieldType>>
circuit_test_5(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
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;
constexpr static const std::size_t selector_columns = selector_columns_5;
constexpr static const std::size_t table_columns =
witness_columns + public_input_columns + constant_columns;

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.public_input_sizes = {witness_columns};
test_circuit.usable_rows = usable_rows_5;

std::vector<std::vector<typename FieldType::value_type>> private_assignment(witness_columns);
std::vector<std::vector<typename FieldType::value_type>> public_input_assignment(public_input_columns);
Expand Down Expand Up @@ -657,7 +657,7 @@ namespace nil {
constexpr static const std::size_t selector_columns_fib = 1;

template<typename FieldType, std::size_t usable_rows>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows>
circuit_description<FieldType, placeholder_circuit_params<FieldType> >
circuit_test_fib(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>()
) {
Expand All @@ -672,7 +672,8 @@ namespace nil {

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.usable_rows = usable_rows;
std::vector<std::vector<typename FieldType::value_type>> table(table_columns);

std::vector<typename FieldType::value_type> q_add(test_circuit.usable_rows);
Expand Down Expand Up @@ -774,7 +775,7 @@ namespace nil {
constexpr static const std::size_t usable_rows_6 = 6;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows_6> circuit_test_6(
circuit_description<FieldType, placeholder_circuit_params<FieldType>> circuit_test_6(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
boost::random::mt11213b rnd = boost::random::mt11213b()
) {
Expand All @@ -789,7 +790,8 @@ namespace nil {

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows_6> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.usable_rows = usable_rows_6;

std::vector<std::vector<typename FieldType::value_type>> table(table_columns);
for (std::size_t j = 0; j < table_columns; j++) {
Expand Down Expand Up @@ -914,7 +916,7 @@ namespace nil {
constexpr static const std::size_t usable_rows_7 = 14;

template<typename FieldType>
circuit_description<FieldType, placeholder_circuit_params<FieldType>, usable_rows_7> circuit_test_7(
circuit_description<FieldType, placeholder_circuit_params<FieldType>> circuit_test_7(
typename nil::crypto3::random::algebraic_engine<FieldType> alg_rnd = nil::crypto3::random::algebraic_engine<FieldType>(),
boost::random::mt11213b rnd = boost::random::mt11213b()
) {
Expand All @@ -929,7 +931,8 @@ namespace nil {

typedef placeholder_circuit_params<FieldType> circuit_params;

circuit_description<FieldType, circuit_params, usable_rows_7> test_circuit;
circuit_description<FieldType, circuit_params> test_circuit;
test_circuit.usable_rows = usable_rows_7;

std::vector<std::vector<typename FieldType::value_type>> table(table_columns);
for (std::size_t j = 0; j < table_columns; j++) {
Expand Down
Loading

0 comments on commit bf751c7

Please sign in to comment.