Skip to content

Commit

Permalink
Submodules updated, max-quotient-chunks parameter added to command-li…
Browse files Browse the repository at this point in the history
…ne arguments#83
  • Loading branch information
ETatuzova authored and x-mass committed Apr 30, 2024
1 parent 383b43e commit 1c30941
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ namespace nil {
bool verification_only = false;
CurvesVariant elliptic_curve_type = type_identity<nil::crypto3::algebra::curves::pallas>{};
HashesVariant hash_type = type_identity<nil::crypto3::hashes::keccak_1600<256>>{};
;

std::size_t lambda = 9;
std::size_t grind = 69;
std::size_t expand_factor = 2;
std::size_t max_quotient_chunks = 0;
};

std::optional<ProverOptions> parse_args(int argc, char* argv[]);
Expand Down
16 changes: 11 additions & 5 deletions bin/proof-generator/include/nil/proof-generator/prover.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
#include <nil/crypto3/multiprecision/cpp_int.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/constraint_system.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp>
/* clang-format off */
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/placeholder_policy.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/preprocessor.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/proof.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/prover.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/verifier.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
/* clang-format on */

#include <nil/blueprint/transpiler/recursive_verifier_generator.hpp>
#include <nil/marshalling/endianness.hpp>
Expand Down Expand Up @@ -128,6 +130,7 @@ namespace nil {
boost::filesystem::path json_file,
std::size_t lambda,
std::size_t expand_factor,
std::size_t max_q_chunks,
std::size_t grind
)
: circuit_file_(circuit_file_name)
Expand All @@ -137,8 +140,8 @@ namespace nil {
, json_file_(json_file)
, lambda_(lambda)
, expand_factor_(expand_factor)
, max_quotient_chunks_(max_q_chunks)
, grind_(grind) {
std::cout << "Global constructor" << std::endl;
}

bool generate_to_file(bool skip_verification) {
Expand Down Expand Up @@ -310,13 +313,14 @@ namespace nil {
nil::crypto3::marshalling::types::make_assignment_table<Endianness, AssignmentTable>(
*marshalled_table
);
table_description_ = table_description;

public_inputs_ = assignment_table.public_inputs();
table_description_.emplace(table_description);

// Lambdas and grinding bits should be passed threw preprocessor directives
std::size_t table_rows_log = std::ceil(std::log2(table_description_->rows_amount));

fri_params_.emplace(FriParams(1, table_rows_log, lambda_, expand_factor_));

lpc_scheme_.emplace(*fri_params_);

BOOST_LOG_TRIVIAL(info) << "Preprocessing public data";
Expand All @@ -326,7 +330,8 @@ namespace nil {
*constraint_system_,
assignment_table.move_public_table(),
*table_description_,
*lpc_scheme_
*lpc_scheme_,
max_quotient_chunks_
)
);

Expand All @@ -344,6 +349,7 @@ namespace nil {
const boost::filesystem::path proof_file_;
const boost::filesystem::path json_file_;
const std::size_t expand_factor_;
const std::size_t max_quotient_chunks_;
const std::size_t lambda_;
const std::size_t grind_;

Expand Down
1 change: 1 addition & 0 deletions bin/proof-generator/src/arg_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ namespace nil {
("lambda-param", make_defaulted_option(prover_options.lambda), "Lambda param (9)")
("grind-param", make_defaulted_option(prover_options.grind), "Grind param (69)")
("expand-factor,x", make_defaulted_option(prover_options.expand_factor), "Expand factor")
("max-quotient-chunks,q", make_defaulted_option(prover_options.max_quotient_chunks), "Maximum quotient polynomial parts amount")
("skip-verification", po::bool_switch(&prover_options.skip_verification), "Skip generated proof verifying step")
("verification-only", po::bool_switch(&prover_options.verification_only), "Read proof for verification instead of writing to it");
// clang-format on
Expand Down
8 changes: 1 addition & 7 deletions bin/proof-generator/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ int run_prover(const nil::proof_generator::ProverOptions& prover_options) {
prover_options.json_file_path,
prover_options.lambda,
prover_options.expand_factor,
prover_options.max_quotient_chunks,
prover_options.grind
);
bool prover_result;
Expand All @@ -64,15 +65,13 @@ int hash_wrapper(const ProverOptions& prover_options) {
int ret;
auto run_prover_wrapper_void = [&prover_options, &ret]<typename HashTypeIdentity>() {
using HashType = typename HashTypeIdentity::type;
std::cout << "run prover" << std::endl;
ret = run_prover<CurveType, HashType>(prover_options);
};
pass_variant_type_to_template_func<HashesVariant>(prover_options.hash_type, run_prover_wrapper_void);
return ret;
}

int curve_wrapper(const ProverOptions& prover_options) {
std::cout << "Curve wrapper" << std::endl;
int ret;
auto curves_wrapper_void = [&prover_options, &ret]<typename CurveTypeIdentity>() {
using CurveType = typename CurveTypeIdentity::type;
Expand All @@ -83,19 +82,14 @@ int curve_wrapper(const ProverOptions& prover_options) {
}

int initial_wrapper(const ProverOptions& prover_options) {
std::cout << "Initial wrapper" << std::endl;
return curve_wrapper(prover_options);
}

int main(int argc, char* argv[]) {
std::cout << "Main" << std::endl;
std::optional<nil::proof_generator::ProverOptions> prover_options = nil::proof_generator::parse_args(argc, argv);
std::cout << "Parsed" << std::endl;
if (!prover_options) {
// Action has already taken a place (help, version, etc.)
return 0;
}
std::cout << "Prover done" << std::endl;

return initial_wrapper(*prover_options);
}

0 comments on commit 1c30941

Please sign in to comment.