Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean PI [2] #363

Merged
merged 3 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions bin/assigner/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ int curve_dependent_main(std::string bytecode_file_name,
long stack_size,
bool check_validity,
bool verbose,
const std::string &policy) {
const std::string &policy,
std::uint32_t max_num_provers) {
using BlueprintFieldType = typename CurveType::base_field_type;
constexpr std::size_t WitnessColumns = 15;
constexpr std::size_t PublicInputColumns = 1;
constexpr std::size_t ConstantColumns = 5;
constexpr std::size_t SelectorColumns = 35;
constexpr std::uint32_t MaxNumProvers = 2;

using ArithmetizationParams =
zk::snark::plonk_arithmetization_params<WitnessColumns, PublicInputColumns, ConstantColumns, SelectorColumns>;
Expand Down Expand Up @@ -391,7 +391,7 @@ int curve_dependent_main(std::string bytecode_file_name,
}

nil::blueprint::parser<BlueprintFieldType, ArithmetizationParams, PrintCircuitOutput> parser_instance(stack_size,
verbose, MaxNumProvers, policy);
verbose, max_num_provers, policy);

std::unique_ptr<llvm::Module> module = parser_instance.parseIRFile(bytecode_file_name.c_str());
if (module == nullptr) {
Expand Down Expand Up @@ -490,7 +490,8 @@ int main(int argc, char *argv[]) {
("check", "Check satisfiability of the generated circuit")
("verbose", "Print detailed log")
("print_circuit_output", "print output of the circuit")
("policy", boost::program_options::value<std::string>(), "Policy for creating circuits. Possible values: default");
("policy", boost::program_options::value<std::string>(), "Policy for creating circuits. Possible values: default")
("max-num-provers", boost::program_options::value<int>(), "Maximum number of provers. Possible values >= 1");
// clang-format on

boost::program_options::variables_map vm;
Expand Down Expand Up @@ -590,6 +591,16 @@ int main(int argc, char *argv[]) {
}
}

std::uint32_t max_num_provers = 1;
if (vm.count("max-num-provers")) {
max_num_provers = vm["max-num-provers"].as<int>();
if (max_num_provers < 1) {
std::cerr << "Invalid command line argument - max-num-provers. " << max_num_provers << " is wrong value." << std::endl;
std::cout << options_desc << std::endl;
return 1;
}
}

switch (curve_options[elliptic_curve]) {
case 0: {
if (vm.count("print_circuit_output")) {
Expand All @@ -601,7 +612,8 @@ int main(int argc, char *argv[]) {
stack_size,
vm.count("check"),
vm.count("verbose"),
policy);
policy,
max_num_provers);
}
else {
return curve_dependent_main<typename algebra::curves::pallas, false>(
Expand All @@ -612,7 +624,8 @@ int main(int argc, char *argv[]) {
stack_size,
vm.count("check"),
vm.count("verbose"),
policy);
policy,
max_num_provers);
}
break;
}
Expand Down
6 changes: 3 additions & 3 deletions examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ add_example_with_proving(polynomial_cpp_example SOURCES polynomial.cpp INPUT pol
add_example_with_proving(pallas_curve_addition_cpp_example
SOURCES pallas_curve_examples/pallas_curve_add.cpp
INPUT pallas_curve_examples/pallas_curve_add.inp)
add_example_with_proving(pallas_curve_multiplication_cpp_example
SOURCES pallas_curve_examples/pallas_curve_mul.cpp
INPUT pallas_curve_examples/pallas_curve_mul.inp)
# add_example_with_proving(pallas_curve_multiplication_cpp_example
# SOURCES pallas_curve_examples/pallas_curve_mul.cpp
# INPUT pallas_curve_examples/pallas_curve_mul.inp)
add_example_with_proving(ed25519_curve_add_cpp SOURCES ed25519_curve_add.cpp INPUT ed25519_curve_add.inp)
add_example_with_proving(ed25519_curve_mul_cpp SOURCES ed25519_curve_mul.cpp INPUT ed25519_curve_mul.inp)
add_example_with_proving(ed25519_field_add_cpp SOURCES ed25519_field_add.cpp INPUT ed25519_field_add.inp)
Expand Down
2 changes: 1 addition & 1 deletion libs/assigner
8 changes: 7 additions & 1 deletion tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ for i in ${!test_examples[*]}; do
for file in tests/inputs/$parent_dir/*.inp; do

echo -n "input $file: ";
./build/bin/assigner/assigner -b build/tests/cpp/${test_example////_}.ll -i "$file" -t assignment.tbl -c circuit.crct -e pallas --check --print_circuit_output > real.log

if [[ $test_example == *"multi_provers"* ]]; then
./build/bin/assigner/assigner -b build/tests/cpp/${test_example////_}.ll -i "$file" -t assignment.tbl -c circuit.crct -e pallas --check --print_circuit_output --max-num-provers 2 > real.log
else
./build/bin/assigner/assigner -b build/tests/cpp/${test_example////_}.ll -i "$file" -t assignment.tbl -c circuit.crct -e pallas --check --print_circuit_output > real.log
fi

if [ $? -ne 0 ]; then
exit_code=1
echo -e "\033[31m Assigner failed! \033[0m";
Expand Down