Skip to content

Commit

Permalink
Updated circuit_description, keccak-256, sha2-256 #330
Browse files Browse the repository at this point in the history
  • Loading branch information
vo-nil committed May 23, 2024
1 parent 4e8a9d2 commit 1112191
Show file tree
Hide file tree
Showing 11 changed files with 188 additions and 204 deletions.
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ set(TESTS_NAMES
"systems/plonk/pickles/to_field"
"systems/plonk/pickles/to_group"

"systems/plonk/placeholder/placeholder"
# "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"
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
40 changes: 21 additions & 19 deletions test/systems/plonk/placeholder/circuits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,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 @@ -246,8 +245,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 @@ -361,7 +361,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 @@ -373,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<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 @@ -466,7 +466,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 @@ -483,8 +483,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 @@ -578,25 +579,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 @@ -656,7 +655,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 @@ -671,7 +670,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 @@ -773,7 +773,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 @@ -788,7 +788,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 @@ -913,7 +914,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 @@ -928,7 +929,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 1112191

Please sign in to comment.