-
Notifications
You must be signed in to change notification settings - Fork 595
fix: make gate counting functions less confusing and avoid estimations #9046
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
Changes from 11 commits
5829dd6
75052af
639a4b8
62334ee
04f953b
e3f5beb
8d0d7fd
d0fd343
ef8e8b5
6a923f5
6258541
374dd95
4e2053f
b4a59b2
7c2064b
37392f1
298810c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,16 +159,15 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP | |
| auto witness = get_witness(witnessPath); | ||
|
|
||
| acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; | ||
| acir_composer.create_circuit(constraint_system, witness); | ||
|
|
||
| init_bn254_crs(acir_composer.get_dyadic_circuit_size()); | ||
| acir_composer.create_finalized_circuit(constraint_system, witness); | ||
| init_bn254_crs(acir_composer.get_finalized_dyadic_circuit_size()); | ||
|
|
||
| Timer pk_timer; | ||
| acir_composer.init_proving_key(); | ||
| write_benchmark("pk_construction_time", pk_timer.milliseconds(), "acir_test", current_dir); | ||
|
|
||
| write_benchmark("gate_count", acir_composer.get_total_circuit_size(), "acir_test", current_dir); | ||
| write_benchmark("subgroup_size", acir_composer.get_dyadic_circuit_size(), "acir_test", current_dir); | ||
| write_benchmark("gate_count", acir_composer.get_finalized_total_circuit_size(), "acir_test", current_dir); | ||
| write_benchmark("subgroup_size", acir_composer.get_finalized_dyadic_circuit_size(), "acir_test", current_dir); | ||
|
|
||
| Timer proof_timer; | ||
| auto proof = acir_composer.create_proof(); | ||
|
|
@@ -199,12 +198,9 @@ bool proveAndVerifyHonkAcirFormat(acir_format::AcirFormat constraint_system, aci | |
| // Construct a bberg circuit from the acir representation | ||
| auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, witness, honk_recursion); | ||
|
|
||
| auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); | ||
| size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); | ||
| init_bn254_crs(srs_size); | ||
|
|
||
| // Construct Honk proof | ||
| Prover prover{ builder }; | ||
| init_bn254_crs(prover.proving_key->proving_key.circuit_size); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. core change: avoiding a needless builder computation just to get an incorrect srs size... |
||
| auto proof = prover.construct_proof(); | ||
|
|
||
| // Verify Honk proof | ||
|
|
@@ -670,8 +666,8 @@ void prove(const std::string& bytecodePath, const std::string& witnessPath, cons | |
| auto witness = get_witness(witnessPath); | ||
|
|
||
| acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; | ||
| acir_composer.create_circuit(constraint_system, witness); | ||
| init_bn254_crs(acir_composer.get_dyadic_circuit_size()); | ||
| acir_composer.create_finalized_circuit(constraint_system, witness); | ||
| init_bn254_crs(acir_composer.get_finalized_dyadic_circuit_size()); | ||
| acir_composer.init_proving_key(); | ||
| auto proof = acir_composer.create_proof(); | ||
|
|
||
|
|
@@ -701,7 +697,8 @@ template <typename Builder = UltraCircuitBuilder> void gateCount(const std::stri | |
| for (auto constraint_system : constraint_systems) { | ||
| auto builder = acir_format::create_circuit<Builder>( | ||
| constraint_system, 0, {}, honk_recursion, std::make_shared<bb::ECCOpQueue>(), true); | ||
| builder.finalize_circuit(); | ||
| builder.finalize_circuit(/*ensure_nonzero=*/true); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. core change: fix thats needed to properly add in the ensure nonzero gates |
||
| info("num gates in gateCount: ", builder.num_gates); | ||
|
lucasxia01 marked this conversation as resolved.
Outdated
|
||
| size_t circuit_size = builder.num_gates; | ||
|
|
||
| // Build individual circuit report | ||
|
|
@@ -778,8 +775,9 @@ void write_vk(const std::string& bytecodePath, const std::string& outputPath) | |
| { | ||
| auto constraint_system = get_constraint_system(bytecodePath, false); | ||
| acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; | ||
| acir_composer.create_circuit(constraint_system); | ||
| init_bn254_crs(acir_composer.get_dyadic_circuit_size()); | ||
| acir_composer.create_finalized_circuit(constraint_system); | ||
| acir_composer.finalize_circuit(); | ||
| init_bn254_crs(acir_composer.get_finalized_dyadic_circuit_size()); | ||
| acir_composer.init_proving_key(); | ||
| auto vk = acir_composer.init_verification_key(); | ||
| auto serialized_vk = to_buffer(*vk); | ||
|
|
@@ -796,8 +794,9 @@ void write_pk(const std::string& bytecodePath, const std::string& outputPath) | |
| { | ||
| auto constraint_system = get_constraint_system(bytecodePath, /*honk_recursion=*/false); | ||
| acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; | ||
| acir_composer.create_circuit(constraint_system); | ||
| init_bn254_crs(acir_composer.get_dyadic_circuit_size()); | ||
| acir_composer.create_finalized_circuit(constraint_system); | ||
| acir_composer.finalize_circuit(); | ||
| init_bn254_crs(acir_composer.get_finalized_dyadic_circuit_size()); | ||
| auto pk = acir_composer.init_proving_key(); | ||
| auto serialized_pk = to_buffer(*pk); | ||
|
|
||
|
|
@@ -1089,12 +1088,9 @@ UltraProver_<Flavor> compute_valid_prover(const std::string& bytecodePath, const | |
| } | ||
|
|
||
| auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, witness, honk_recursion); | ||
|
|
||
| auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); | ||
| size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); | ||
| init_bn254_crs(srs_size); | ||
|
|
||
| return Prover{ builder }; | ||
| auto prover = Prover{ builder }; | ||
| init_bn254_crs(prover.proving_key->proving_key.circuit_size); | ||
| return std::move(prover); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1219,12 +1215,9 @@ void write_recursion_inputs_honk(const std::string& bytecodePath, | |
| auto witness = get_witness(witnessPath); | ||
| auto builder = acir_format::create_circuit<Builder>(constraints, 0, witness, honk_recursion); | ||
|
|
||
| auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); | ||
| size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); | ||
| init_bn254_crs(srs_size); | ||
|
|
||
| // Construct Honk proof and verification key | ||
| Prover prover{ builder }; | ||
| init_bn254_crs(prover.proving_key->proving_key.circuit_size); | ||
| std::vector<FF> proof = prover.construct_proof(); | ||
| VerificationKey verification_key(prover.proving_key->proving_key); | ||
|
|
||
|
|
@@ -1306,8 +1299,9 @@ void prove_output_all(const std::string& bytecodePath, const std::string& witnes | |
| auto witness = get_witness(witnessPath); | ||
|
|
||
| acir_proofs::AcirComposer acir_composer{ 0, verbose_logging }; | ||
| acir_composer.create_circuit(constraint_system, witness); | ||
| init_bn254_crs(acir_composer.get_dyadic_circuit_size()); | ||
| acir_composer.create_finalized_circuit(constraint_system, witness); | ||
| acir_composer.finalize_circuit(); | ||
| init_bn254_crs(acir_composer.get_finalized_dyadic_circuit_size()); | ||
| acir_composer.init_proving_key(); | ||
| auto proof = acir_composer.create_proof(); | ||
|
|
||
|
|
@@ -1371,12 +1365,9 @@ void prove_honk_output_all(const std::string& bytecodePath, | |
|
|
||
| auto builder = acir_format::create_circuit<Builder>(constraint_system, 0, witness, honk_recursion); | ||
|
|
||
| auto num_extra_gates = builder.get_num_gates_added_to_ensure_nonzero_polynomials(); | ||
| size_t srs_size = builder.get_circuit_subgroup_size(builder.get_total_circuit_size() + num_extra_gates); | ||
| init_bn254_crs(srs_size); | ||
|
|
||
| // Construct Honk proof | ||
| Prover prover{ builder }; | ||
| init_bn254_crs(prover.proving_key->proving_key.circuit_size); | ||
| auto proof = prover.construct_proof(); | ||
|
|
||
| // We have been given a directory, we will write the proof and verification key | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.