Skip to content

Commit

Permalink
Set public input sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
akokoshn committed Mar 17, 2024
1 parent df994b4 commit 3635f45
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ jobs:
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@5bb7c4b0790f56b3a339e33ba442816fac17ab88
with:
artifact-name: ${{ needs.build-and-test-linux.outputs.transpiler-artifact-name }}
evm-placeholder-verification-ref: 202fbd0402eda22ae91348800dea7366110b1501
evm-placeholder-verification-ref: 2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
test-names: ${{ needs.build-and-test-linux.outputs.evm-targets }}

Expand Down Expand Up @@ -404,7 +404,7 @@ jobs:
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@5bb7c4b0790f56b3a339e33ba442816fac17ab88
with:
artifact-name: ${{ needs.merge-proofs-to-transpiler-output.outputs.merged-artifact-name }}
evm-placeholder-verification-ref: 202fbd0402eda22ae91348800dea7366110b1501
evm-placeholder-verification-ref: 2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
test-names: ${{ needs.build-and-test-linux.outputs.evm-targets }}

Expand Down
21 changes: 17 additions & 4 deletions bin/assigner/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ using namespace nil::blueprint;
template<typename Endianness, typename ArithmetizationType, typename ConstraintSystemType>
void print_circuit(const circuit_proxy<ArithmetizationType> &circuit_proxy,
const assignment_proxy<ArithmetizationType> &table_proxy,
bool rename_required, std::ostream &out = std::cout) {
bool multi_prover, std::ostream &out = std::cout) {
using TTypeBase = nil::marshalling::field_type<Endianness>;
using value_marshalling_type =
nil::crypto3::marshalling::types::plonk_constraint_system<TTypeBase, ConstraintSystemType>;
Expand All @@ -90,7 +90,7 @@ void print_circuit(const circuit_proxy<ArithmetizationType> &circuit_proxy,
used_copy_constraints.push_back(copy_constraints[it]);
}

if (rename_required) {
if (multi_prover) {
const auto& used_rows = table_proxy.get_used_rows();
std::uint32_t local_row = 0;
for (const auto &row : used_rows) {
Expand Down Expand Up @@ -128,13 +128,26 @@ void print_circuit(const circuit_proxy<ArithmetizationType> &circuit_proxy,
used_lookup_tables.push_back(lookup_tables[it]);
}


// fill public input sizes
nil::crypto3::marshalling::types::public_input_sizes_type<TTypeBase> public_input_sizes;
using public_input_size_type = typename nil::crypto3::marshalling::types::public_input_sizes_type<TTypeBase>::element_type;
std::uint32_t public_input_size = table_proxy.public_inputs_amount();
for (std::uint32_t i = 0; i < public_input_size; i++) {
public_input_sizes.value().push_back(public_input_size_type(table_proxy.public_input_column_size(i)));
}
if (multi_prover) {
public_input_sizes.value().push_back(public_input_size_type(table_proxy.shared_column_size(0)));
}

auto filled_val =
value_marshalling_type(std::make_tuple(
nil::crypto3::marshalling::types::fill_plonk_gates<Endianness, typename ConstraintSystemType::gates_container_type::value_type>(used_gates),
nil::crypto3::marshalling::types::fill_plonk_copy_constraints<Endianness, typename ConstraintSystemType::variable_type>(used_copy_constraints),
nil::crypto3::marshalling::types::fill_plonk_lookup_gates<Endianness, typename ConstraintSystemType::lookup_gates_container_type::value_type>(used_lookup_gates),
nil::crypto3::marshalling::types::fill_plonk_lookup_tables<Endianness, typename ConstraintSystemType::lookup_tables_type::value_type>(used_lookup_tables)
));
nil::crypto3::marshalling::types::fill_plonk_lookup_tables<Endianness, typename ConstraintSystemType::lookup_tables_type::value_type>(used_lookup_tables),
public_input_sizes
));

std::vector<std::uint8_t> cv;
cv.resize(filled_val.length(), 0x00);
Expand Down
42 changes: 14 additions & 28 deletions bin/recursive_gen/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ int main(int argc, char *argv[]) {
It'll be better to create an empty folder for output")
("skip-verification", "Used with gen-test-proof, if set - skips verifiyng the generated proof")
("multi-prover", "Pass this flag if input circuit is a part of larger circuit, divided for faster paralel proving")
("public-input-rows,p", boost::program_options::value<int>(), "Used public input column rows")
("shared-rows,s", boost::program_options::value<int>(), "Used shared rows")
("elliptic-curve-type,e", boost::program_options::value<std::string>(), "Native elliptic curve type (pallas, vesta, ed25519, bls12381)");

// clang-format on
Expand Down Expand Up @@ -303,38 +301,12 @@ int curve_dependent_main(
return 1;
}

std::uint32_t public_input_rows = 50;
if (vm.count("public-input-rows")) {
public_input_rows = vm["public-input-rows"].as<int>(); }

std::uint32_t shared_rows = 50;
if (vm.count("shared-rows")) {
if( !vm.count("shared-rows") )
std::cout << "shared-rows parameter will be ignored because it is single-prover example" << std::endl;
shared_rows = vm["shared-rows"].as<int>();
}

using parameters_policy = ParametersPolicy<BlueprintFieldType>;
constexpr std::size_t WitnessColumns = parameters_policy::WitnessColumns;
constexpr std::size_t PublicInputColumns = is_multi_prover? parameters_policy::PublicInputColumns + 1: parameters_policy::PublicInputColumns;
constexpr std::size_t ConstantColumns = parameters_policy::ComponentConstantColumns + parameters_policy::LookupConstantColumns;
constexpr std::size_t SelectorColumns = parameters_policy::ComponentSelectorColumns + parameters_policy::LookupSelectorColumns;

std::cout << "WitnessColumns = " << WitnessColumns << std::endl;
std::cout << "PublicInputColumns = " << PublicInputColumns << std::endl;
std::cout << "ConstantColumns = " << ConstantColumns << ": LookupConstantColumns = " << parameters_policy::LookupConstantColumns << std::endl;
std::cout << "SelectorColumns = " << SelectorColumns << ": LookupSelectorColumns = " << parameters_policy::LookupSelectorColumns << std::endl;

std::vector<std::size_t> public_input_sizes(PublicInputColumns);
for(std::size_t i = 0; i < PublicInputColumns; i++){
public_input_sizes[i] = public_input_rows;
}
if( is_multi_prover )
public_input_sizes[PublicInputColumns - 1] = shared_rows;

zk::snark::plonk_table_description<BlueprintFieldType> desc(
WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns);

// Circuit-specific parameter
using ConstraintSystemType =
nil::crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>;
Expand Down Expand Up @@ -364,6 +336,7 @@ int curve_dependent_main(
}

ConstraintSystemType constraint_system;
std::vector<std::size_t> public_input_sizes(PublicInputColumns);
{
std::ifstream ifile;
ifile.open(circuit_file_name, std::ios_base::binary | std::ios_base::in);
Expand All @@ -389,9 +362,16 @@ int curve_dependent_main(
constraint_system = nil::crypto3::marshalling::types::make_plonk_constraint_system<Endianness, ConstraintSystemType>(
marshalled_data
);

for(std::size_t i = 0; i < constraint_system.public_input_sizes_num(); i++){
public_input_sizes[i] = constraint_system.public_input_size(i);
std::cout << "Public input size " << i << " = " << public_input_sizes[i] << std::endl;
}
}

AssignmentTableType assignment_table;
zk::snark::plonk_table_description<BlueprintFieldType> desc(
WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns);
{
std::ifstream iassignment;
iassignment.open(assignment_table_file_name, std::ios_base::binary | std::ios_base::in);
Expand Down Expand Up @@ -419,6 +399,12 @@ int curve_dependent_main(
);
desc.rows_amount = assignment_table.rows_amount();
}

std::cout << "WitnessColumns = " << desc.witness_columns << std::endl;
std::cout << "PublicInputColumns = " << desc.public_input_columns << std::endl;
std::cout << "ConstantColumns = " << desc.constant_columns << ": LookupConstantColumns = " << parameters_policy::LookupConstantColumns << std::endl;
std::cout << "SelectorColumns = " << desc.selector_columns << ": LookupSelectorColumns = " << parameters_policy::LookupSelectorColumns << std::endl;

std::vector<std::set<int>> columns_rotations;

const std::size_t Lambda = parameters_policy::lambda;
Expand Down
2 changes: 1 addition & 1 deletion libs/assigner
Submodule assigner updated 45 files
+1 −1 include/nil/blueprint/assigner.hpp
+2 −2 include/nil/blueprint/comparison/comparison.hpp
+3 −4 include/nil/blueprint/component_mockups/bls12_381_pairing.hpp
+2 −2 include/nil/blueprint/component_mockups/comparison.hpp
+5 −5 include/nil/blueprint/component_mockups/fp12_multiplication.hpp
+3 −6 include/nil/blueprint/component_mockups/h2c.hpp
+3 −5 include/nil/blueprint/component_mockups/is_in_g1.hpp
+3 −5 include/nil/blueprint/component_mockups/is_in_g2.hpp
+4 −4 include/nil/blueprint/fields/addition.hpp
+3 −3 include/nil/blueprint/fields/division.hpp
+4 −4 include/nil/blueprint/fields/multiplication.hpp
+4 −4 include/nil/blueprint/fields/subtraction.hpp
+12 −11 include/nil/blueprint/handle_component.hpp
+1 −1 include/nil/blueprint/integers/addition.hpp
+1 −1 include/nil/blueprint/integers/bit_de_composition.hpp
+1 −1 include/nil/blueprint/integers/bit_shift.hpp
+1 −1 include/nil/blueprint/integers/multiplication.hpp
+1 −1 include/nil/blueprint/integers/subtraction.hpp
+1 −1 include/nil/blueprint/recursive_prover/gate_arg_verifier.hpp
+ test/data/ed25519_non_native_field_add_0.crct
+ test/data/ed25519_non_native_field_add_1.crct
+ test/data/ed25519_non_native_field_add_2.crct
+ test/data/ed25519_non_native_field_mul_0.crct
+ test/data/ed25519_non_native_field_mul_1.crct
+ test/data/ed25519_non_native_field_mul_2.crct
+ test/data/ed25519_non_native_field_sub_0.crct
+ test/data/ed25519_non_native_field_sub_1.crct
+ test/data/ed25519_non_native_field_sub_2.crct
+ test/data/pallas_native_curve_add_0.crct
+ test/data/pallas_native_curve_add_1.crct
+ test/data/pallas_native_curve_add_2.crct
+ test/data/pallas_native_curve_mul_0.crct
+ test/data/pallas_native_curve_mul_1.crct
+ test/data/pallas_native_field_add_0.crct
+ test/data/pallas_native_field_add_1.crct
+ test/data/pallas_native_field_add_2.crct
+ test/data/pallas_native_field_add_3.crct
+ test/data/pallas_native_field_mul_0.crct
+ test/data/pallas_native_field_mul_1.crct
+ test/data/pallas_native_field_mul_2.crct
+ test/data/pallas_native_field_mul_3.crct
+ test/data/pallas_native_field_sub_0.crct
+ test/data/pallas_native_field_sub_1.crct
+ test/data/pallas_native_field_sub_2.crct
+ test/data/pallas_native_field_sub_3.crct
2 changes: 1 addition & 1 deletion libs/blueprint
Submodule blueprint updated 64 files
+1 −0 .github/workflows/run_tests.yml
+144 −0 include/nil/blueprint/basic_non_native_policy.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/bool_scalar_multiplication.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/complete_addition.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/doubling.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/scalar_non_native_range.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/variable_base_multiplication.hpp
+1 −1 ...e/nil/blueprint/components/algebra/curves/edwards/plonk/non_native/variable_base_multiplication_per_bit.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/pasta/plonk/endo_scalar.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/pasta/plonk/unified_addition.hpp
+1 −1 include/nil/blueprint/components/algebra/curves/pasta/plonk/variable_base_scalar_mul.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/addition.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/bit_shift_constant.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/division.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/division_or_zero.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/exponentiation.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/linear_interpolation.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/logic_and_flag.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/logic_or_flag.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/multiplication.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/multiplication_by_constant.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/addition.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/bit_composition.hpp
+5 −2 include/nil/blueprint/components/algebra/fields/plonk/non_native/bit_decomposition.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/comparison_checked.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/comparison_flag.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/comparison_unchecked.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/detail/boolean_lookup_op_component.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/detail/boolean_op_component.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/division_remainder.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/equality_flag.hpp
+69 −0 include/nil/blueprint/components/algebra/fields/plonk/non_native/logic_ops.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/multiplication.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/range.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/reduction.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/non_native/subtraction.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/quadratic_interpolation.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/range_check.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/sqrt.hpp
+1 −1 include/nil/blueprint/components/algebra/fields/plonk/subtraction.hpp
+3 −8 include/nil/blueprint/components/hashes/poseidon/plonk/poseidon.hpp
+1 −2 include/nil/blueprint/components/hashes/poseidon/plonk/poseidon_constants.hpp
+1 −1 include/nil/blueprint/components/hashes/sha2/plonk/decomposition.hpp
+1 −1 include/nil/blueprint/components/hashes/sha2/plonk/sha256.hpp
+2 −2 include/nil/blueprint/components/hashes/sha2/plonk/sha256_process.hpp
+2 −2 include/nil/blueprint/components/hashes/sha2/plonk/sha512.hpp
+2 −2 include/nil/blueprint/components/hashes/sha2/plonk/sha512_process.hpp
+170 −0 include/nil/blueprint/components/mock/mocked_component_base.hpp
+683 −0 include/nil/blueprint/components/mock/mocked_components.hpp
+2 −2 include/nil/blueprint/components/systems/snark/plonk/kimchi/detail/limbs.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/detail/f1_loop.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/detail/f3_loop.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/detail/gate_component.hpp
+5 −2 include/nil/blueprint/components/systems/snark/plonk/placeholder/fri_array_swap.hpp
+2 −2 include/nil/blueprint/components/systems/snark/plonk/placeholder/fri_cosets.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/fri_lin_inter.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/gate_argument_verifier.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/lookup_argument_verifier.hpp
+1 −1 include/nil/blueprint/components/systems/snark/plonk/placeholder/permutation_argument_verifier.hpp
+7 −4 include/nil/blueprint/utils/connectedness_check.hpp
+1 −0 test/CMakeLists.txt
+61 −4 test/algebra/fields/plonk/non_native/logic_ops.cpp
+749 −0 test/mock/mocked_components.cpp
+35 −30 test/utils/connectedness_check.cpp

0 comments on commit 3635f45

Please sign in to comment.