From 11bc182ccc33bc60d90a0e59b3fac94cebce40c9 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 4 Jun 2024 14:28:21 +0000 Subject: [PATCH 1/4] added new flow --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index c488b3d9f9d..50b57c9bdac 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -809,6 +809,74 @@ void prove_output_all(const std::string& bytecodePath, const std::string& witnes vinfo("vk as fields written to: ", vkFieldsOutputPath); } +/** + * @brief Creates a Honk proof for an ACIR circuit, outputs the proof and verification key in binary and 'field' format + * + * Communication: + * - Filesystem: The proof is written to the path specified by outputPath + * + * @param bytecodePath Path to the file containing the serialized circuit + * @param witnessPath Path to the file containing the serialized witness + * @param outputPath Directory into which we write the proof and verification key data + */ +template +void prove_honk_output_all(const std::string& bytecodePath, + const std::string& witnessPath, + const std::string& outputPath) +{ + using Builder = Flavor::CircuitBuilder; + using Prover = UltraProver_; + using VerificationKey = Flavor::VerificationKey; + + bool honk_recursion = false; + if constexpr (IsAnyOf) { + honk_recursion = true; + } + + auto constraint_system = get_constraint_system(bytecodePath, honk_recursion); + auto witness = get_witness(witnessPath); + + auto builder = acir_format::create_circuit(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 }; + auto proof = prover.construct_proof(); + + // We have been given a directory, we will write the proof and verification key + // into the directory in both 'binary' and 'fields' formats + std::string vkOutputPath = outputPath + "/honk_vk"; + std::string proofPath = outputPath + "/honk_proof"; + std::string vkFieldsOutputPath = outputPath + "/honk_vk_fields.json"; + std::string proofFieldsPath = outputPath + "/honk_proof_fields.json"; + + VerificationKey vk( + prover.instance->proving_key); // uses a partial form of the proving key which only has precomputed entities + + // Write the 'binary' proof + write_file(proofPath, to_buffer(proof)); + vinfo("binary proof written to: ", proofPath); + + // Write the proof as fields + std::string proofJson = proof_to_json(proof); + write_file(proofFieldsPath, { proofJson.begin(), proofJson.end() }); + vinfo("proof as fields written to: ", proofFieldsPath); + + // Write the vk as binary + auto serialized_vk = to_buffer(vk); + write_file(vkOutputPath, serialized_vk); + vinfo("vk written to: ", vkOutputPath); + + // Write the vk as fields + std::vector vk_data = vk.to_field_elements(); + auto vk_json = honk_vk_to_json(vk_data); + write_file(vkFieldsOutputPath, { vk_json.begin(), vk_json.end() }); + vinfo("vk as fields written to: ", vkFieldsOutputPath); +} + bool flag_present(std::vector& args, const std::string& flag) { return std::find(args.begin(), args.end(), flag) != args.end(); @@ -870,6 +938,12 @@ int main(int argc, char* argv[]) } else if (command == "prove_output_all") { std::string output_path = get_option(args, "-o", "./proofs"); prove_output_all(bytecode_path, witness_path, output_path); + } else if (command == "prove_ultra_honk_output_all") { + std::string output_path = get_option(args, "-o", "./proofs"); + prove_honk_output_all(bytecode_path, witness_path, output_path); + } else if (command == "prove_mega_honk_output_all") { + std::string output_path = get_option(args, "-o", "./proofs"); + prove_honk_output_all(bytecode_path, witness_path, output_path); } else if (command == "gates") { gateCount(bytecode_path, honk_recursion); } else if (command == "verify") { From b038df5464f7308d9cd59900007e19e2edea2f00 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 6 Jun 2024 17:16:10 +0000 Subject: [PATCH 2/4] added fake write_vk_honk and prove_honk_output_all commands --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 117 +++++++++++++++++- .../stdlib_circuit_builders/mock_circuits.hpp | 44 +++++-- 2 files changed, 143 insertions(+), 18 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 50b57c9bdac..8eca9b59f18 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -663,7 +663,7 @@ template bool verify_honk(const std::string& proof_path, } /** - * @brief Writes a verification key for an ACIR circuit to a file + * @brief Writes a Honk verification key for an ACIR circuit to a file * * Communication: * - stdout: The verification key is written to stdout as a byte array @@ -703,6 +703,44 @@ template void write_vk_honk(const std::string& bytecodePa } } +/** + * @brief Writes a Honk verification key for a fixed mock ACIR circuit to a file + * + * Communication: + * - stdout: The verification key is written to stdout as a byte array + * - Filesystem: The verification key is written to the path specified by outputPath + * + * @param bytecodePath Path to the file containing the serialized circuit + * @param outputPath Path to write the verification key to + */ +template void write_vk_honk_fake(const std::string& outputPath) +{ + using Builder = Flavor::CircuitBuilder; + using ProverInstance = ProverInstance_; + using VerificationKey = Flavor::VerificationKey; + + // Create some mock circuit that's some size + Builder builder; + MockCircuits::construct_arithmetic_circuit(builder, 10, /*random=*/false, /*has_pub_input=*/false); + 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); + + ProverInstance prover_inst(builder); + VerificationKey vk( + prover_inst.proving_key); // uses a partial form of the proving key which only has precomputed entities + + info("fake honk vk circuit size: ", vk.circuit_size); + auto serialized_vk = to_buffer(vk); + if (outputPath == "-") { + writeRawBytesToStdout(serialized_vk); + vinfo("fake honk vk written to stdout"); + } else { + write_file(outputPath, serialized_vk); + vinfo("fake honk vk written to: ", outputPath); + } +} + /** * @brief Outputs proof as vector of field elements in readable format. * @@ -848,10 +886,10 @@ void prove_honk_output_all(const std::string& bytecodePath, // We have been given a directory, we will write the proof and verification key // into the directory in both 'binary' and 'fields' formats - std::string vkOutputPath = outputPath + "/honk_vk"; - std::string proofPath = outputPath + "/honk_proof"; - std::string vkFieldsOutputPath = outputPath + "/honk_vk_fields.json"; - std::string proofFieldsPath = outputPath + "/honk_proof_fields.json"; + std::string vkOutputPath = outputPath + "/vk"; + std::string proofPath = outputPath + "/proof"; + std::string vkFieldsOutputPath = outputPath + "/vk_fields.json"; + std::string proofFieldsPath = outputPath + "/proof_fields.json"; VerificationKey vk( prover.instance->proving_key); // uses a partial form of the proving key which only has precomputed entities @@ -877,6 +915,67 @@ void prove_honk_output_all(const std::string& bytecodePath, vinfo("vk as fields written to: ", vkFieldsOutputPath); } +/** + * @brief Creates a Honk proof for an ACIR circuit, outputs the proof and verification key in binary and 'field' format + * + * Communication: + * - Filesystem: The proof is written to the path specified by outputPath + * + * @param bytecodePath Path to the file containing the serialized circuit + * @param witnessPath Path to the file containing the serialized witness + * @param outputPath Directory into which we write the proof and verification key data + */ +template void prove_honk_output_all_fake(const std::string& outputPath) +{ + using Builder = Flavor::CircuitBuilder; + using Prover = UltraProver_; + using VerificationKey = Flavor::VerificationKey; + + Builder builder; + // Create mock circuit + MockCircuits::construct_arithmetic_circuit(builder, 10, /*random=*/false, /*has_pub_input=*/false); + + 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 }; + auto proof = prover.construct_proof(); + + // We have been given a directory, we will write the proof and verification key + // into the directory in both 'binary' and 'fields' formats + std::string vkOutputPath = outputPath + "/vk"; + std::string proofPath = outputPath + "/proof"; + std::string vkFieldsOutputPath = outputPath + "/vk_fields.json"; + std::string proofFieldsPath = outputPath + "/proof_fields.json"; + + VerificationKey vk( + prover.instance->proving_key); // uses a partial form of the proving key which only has precomputed entities + info("fake honk vk circuit size: ", vk.circuit_size); + info("fake honk vk num public inputs: ", vk.num_public_inputs); + + // Write the 'binary' proof + write_file(proofPath, to_buffer(proof)); + vinfo("fake honk binary proof written to: ", proofPath); + + // Write the proof as fields + std::string proofJson = proof_to_json(proof); + write_file(proofFieldsPath, { proofJson.begin(), proofJson.end() }); + vinfo("fake honk proof as fields written to: ", proofFieldsPath); + + // Write the vk as binary + auto serialized_vk = to_buffer(vk); + write_file(vkOutputPath, serialized_vk); + vinfo("fake honk vk written to: ", vkOutputPath); + + // Write the vk as fields + std::vector vk_data = vk.to_field_elements(); + auto vk_json = honk_vk_to_json(vk_data); + write_file(vkFieldsOutputPath, { vk_json.begin(), vk_json.end() }); + vinfo("fake honk vk as fields written to: ", vkFieldsOutputPath); +} + bool flag_present(std::vector& args, const std::string& flag) { return std::find(args.begin(), args.end(), flag) != args.end(); @@ -899,7 +998,7 @@ int main(int argc, char* argv[]) } std::string command = args[0]; - + info("bb COMMAND is: ", command); std::string bytecode_path = get_option(args, "-b", "./target/program.json"); std::string witness_path = get_option(args, "-w", "./target/witness.gz"); std::string proof_path = get_option(args, "-p", "./proofs/proof"); @@ -941,6 +1040,9 @@ int main(int argc, char* argv[]) } else if (command == "prove_ultra_honk_output_all") { std::string output_path = get_option(args, "-o", "./proofs"); prove_honk_output_all(bytecode_path, witness_path, output_path); + } else if (command == "prove_ultra_honk_output_all_fake") { + std::string output_path = get_option(args, "-o", "./proofs"); + prove_honk_output_all_fake(output_path); } else if (command == "prove_mega_honk_output_all") { std::string output_path = get_option(args, "-o", "./proofs"); prove_honk_output_all(bytecode_path, witness_path, output_path); @@ -979,6 +1081,9 @@ int main(int argc, char* argv[]) } else if (command == "write_vk_ultra_honk") { std::string output_path = get_option(args, "-o", "./target/vk"); write_vk_honk(bytecode_path, output_path); + } else if (command == "write_vk_ultra_honk_fake") { + std::string output_path = get_option(args, "-o", "./target/vk"); + write_vk_honk_fake(output_path); } else if (command == "prove_mega_honk") { std::string output_path = get_option(args, "-o", "./proofs/proof"); prove_honk(bytecode_path, witness_path, output_path); diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp index 183d951f070..857a0118e03 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp @@ -19,13 +19,22 @@ class MockCircuits { * @param num_gates */ template - static void add_arithmetic_gates_with_public_inputs(Builder& builder, const size_t num_gates = 4) + static void add_arithmetic_gates_with_public_inputs(Builder& builder, + const size_t num_gates = 4, + bool random = true) { // For good measure, include a gate with some public inputs for (size_t i = 0; i < num_gates; ++i) { - FF a = FF::random_element(&engine); - FF b = FF::random_element(&engine); - FF c = FF::random_element(&engine); + FF a, b, c; + if (random) { + a = FF::random_element(&engine); + b = FF::random_element(&engine); + c = FF::random_element(&engine); + } else { + a = FF(1); + b = FF(2); + c = FF(3); + } FF d = a + b + c; uint32_t a_idx = builder.add_public_variable(a); uint32_t b_idx = builder.add_variable(b); @@ -42,13 +51,21 @@ class MockCircuits { * @param builder * @param num_gates */ - template static void add_arithmetic_gates(Builder& builder, const size_t num_gates = 4) + template + static void add_arithmetic_gates(Builder& builder, const size_t num_gates = 4, bool random = true) { // For good measure, include a gate with some public inputs for (size_t i = 0; i < num_gates; ++i) { - FF a = FF::random_element(&engine); - FF b = FF::random_element(&engine); - FF c = FF::random_element(&engine); + FF a, b, c; + if (random) { + a = FF::random_element(&engine); + b = FF::random_element(&engine); + c = FF::random_element(&engine); + } else { + a = FF(1); + b = FF(2); + c = FF(3); + } FF d = a + b + c; uint32_t a_idx = builder.add_variable(a); uint32_t b_idx = builder.add_variable(b); @@ -66,15 +83,18 @@ class MockCircuits { * @param num_gates */ template - static void construct_arithmetic_circuit(Builder& builder, const size_t target_log2_dyadic_size = 4) + static void construct_arithmetic_circuit(Builder& builder, + const size_t target_log2_dyadic_size = 4, + bool random = true, + bool has_pub_input = true) { const size_t target_dyadic_size = 1 << target_log2_dyadic_size; const size_t num_preamble_gates = builder.num_gates; ASSERT(target_dyadic_size >= num_preamble_gates); // For good measure, include a gate with some public inputs - if (target_dyadic_size > num_preamble_gates) { - add_arithmetic_gates_with_public_inputs(builder, 1); + if (has_pub_input && target_dyadic_size > num_preamble_gates) { + add_arithmetic_gates_with_public_inputs(builder, 1, random); } // A proper treatment of this would dynamically calculate how many gates to add given static information about @@ -90,7 +110,7 @@ class MockCircuits { size_t num_gates_to_add = target_dyadic_size - OFFSET_HACK - 1 - num_preamble_gates; // Add arbitrary arithmetic gates to obtain a total of num_gates-many gates - add_arithmetic_gates(builder, num_gates_to_add); + add_arithmetic_gates(builder, num_gates_to_add, random); } /** From cd7bd07fddadf7303f0a40dd6d3c77634bd22be3 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 20 Jun 2024 05:24:26 +0000 Subject: [PATCH 3/4] removed fake and reverted mock circuits changes --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 107 +----------------- .../stdlib_circuit_builders/mock_circuits.hpp | 45 ++------ 2 files changed, 13 insertions(+), 139 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 8eca9b59f18..a3577423238 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -703,44 +703,6 @@ template void write_vk_honk(const std::string& bytecodePa } } -/** - * @brief Writes a Honk verification key for a fixed mock ACIR circuit to a file - * - * Communication: - * - stdout: The verification key is written to stdout as a byte array - * - Filesystem: The verification key is written to the path specified by outputPath - * - * @param bytecodePath Path to the file containing the serialized circuit - * @param outputPath Path to write the verification key to - */ -template void write_vk_honk_fake(const std::string& outputPath) -{ - using Builder = Flavor::CircuitBuilder; - using ProverInstance = ProverInstance_; - using VerificationKey = Flavor::VerificationKey; - - // Create some mock circuit that's some size - Builder builder; - MockCircuits::construct_arithmetic_circuit(builder, 10, /*random=*/false, /*has_pub_input=*/false); - 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); - - ProverInstance prover_inst(builder); - VerificationKey vk( - prover_inst.proving_key); // uses a partial form of the proving key which only has precomputed entities - - info("fake honk vk circuit size: ", vk.circuit_size); - auto serialized_vk = to_buffer(vk); - if (outputPath == "-") { - writeRawBytesToStdout(serialized_vk); - vinfo("fake honk vk written to stdout"); - } else { - write_file(outputPath, serialized_vk); - vinfo("fake honk vk written to: ", outputPath); - } -} - /** * @brief Outputs proof as vector of field elements in readable format. * @@ -915,67 +877,6 @@ void prove_honk_output_all(const std::string& bytecodePath, vinfo("vk as fields written to: ", vkFieldsOutputPath); } -/** - * @brief Creates a Honk proof for an ACIR circuit, outputs the proof and verification key in binary and 'field' format - * - * Communication: - * - Filesystem: The proof is written to the path specified by outputPath - * - * @param bytecodePath Path to the file containing the serialized circuit - * @param witnessPath Path to the file containing the serialized witness - * @param outputPath Directory into which we write the proof and verification key data - */ -template void prove_honk_output_all_fake(const std::string& outputPath) -{ - using Builder = Flavor::CircuitBuilder; - using Prover = UltraProver_; - using VerificationKey = Flavor::VerificationKey; - - Builder builder; - // Create mock circuit - MockCircuits::construct_arithmetic_circuit(builder, 10, /*random=*/false, /*has_pub_input=*/false); - - 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 }; - auto proof = prover.construct_proof(); - - // We have been given a directory, we will write the proof and verification key - // into the directory in both 'binary' and 'fields' formats - std::string vkOutputPath = outputPath + "/vk"; - std::string proofPath = outputPath + "/proof"; - std::string vkFieldsOutputPath = outputPath + "/vk_fields.json"; - std::string proofFieldsPath = outputPath + "/proof_fields.json"; - - VerificationKey vk( - prover.instance->proving_key); // uses a partial form of the proving key which only has precomputed entities - info("fake honk vk circuit size: ", vk.circuit_size); - info("fake honk vk num public inputs: ", vk.num_public_inputs); - - // Write the 'binary' proof - write_file(proofPath, to_buffer(proof)); - vinfo("fake honk binary proof written to: ", proofPath); - - // Write the proof as fields - std::string proofJson = proof_to_json(proof); - write_file(proofFieldsPath, { proofJson.begin(), proofJson.end() }); - vinfo("fake honk proof as fields written to: ", proofFieldsPath); - - // Write the vk as binary - auto serialized_vk = to_buffer(vk); - write_file(vkOutputPath, serialized_vk); - vinfo("fake honk vk written to: ", vkOutputPath); - - // Write the vk as fields - std::vector vk_data = vk.to_field_elements(); - auto vk_json = honk_vk_to_json(vk_data); - write_file(vkFieldsOutputPath, { vk_json.begin(), vk_json.end() }); - vinfo("fake honk vk as fields written to: ", vkFieldsOutputPath); -} - bool flag_present(std::vector& args, const std::string& flag) { return std::find(args.begin(), args.end(), flag) != args.end(); @@ -998,7 +899,7 @@ int main(int argc, char* argv[]) } std::string command = args[0]; - info("bb COMMAND is: ", command); + std::string bytecode_path = get_option(args, "-b", "./target/program.json"); std::string witness_path = get_option(args, "-w", "./target/witness.gz"); std::string proof_path = get_option(args, "-p", "./proofs/proof"); @@ -1040,9 +941,6 @@ int main(int argc, char* argv[]) } else if (command == "prove_ultra_honk_output_all") { std::string output_path = get_option(args, "-o", "./proofs"); prove_honk_output_all(bytecode_path, witness_path, output_path); - } else if (command == "prove_ultra_honk_output_all_fake") { - std::string output_path = get_option(args, "-o", "./proofs"); - prove_honk_output_all_fake(output_path); } else if (command == "prove_mega_honk_output_all") { std::string output_path = get_option(args, "-o", "./proofs"); prove_honk_output_all(bytecode_path, witness_path, output_path); @@ -1081,9 +979,6 @@ int main(int argc, char* argv[]) } else if (command == "write_vk_ultra_honk") { std::string output_path = get_option(args, "-o", "./target/vk"); write_vk_honk(bytecode_path, output_path); - } else if (command == "write_vk_ultra_honk_fake") { - std::string output_path = get_option(args, "-o", "./target/vk"); - write_vk_honk_fake(output_path); } else if (command == "prove_mega_honk") { std::string output_path = get_option(args, "-o", "./proofs/proof"); prove_honk(bytecode_path, witness_path, output_path); diff --git a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp index 857a0118e03..5d5b3c03953 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib_circuit_builders/mock_circuits.hpp @@ -19,22 +19,13 @@ class MockCircuits { * @param num_gates */ template - static void add_arithmetic_gates_with_public_inputs(Builder& builder, - const size_t num_gates = 4, - bool random = true) + static void add_arithmetic_gates_with_public_inputs(Builder& builder, const size_t num_gates = 4) { // For good measure, include a gate with some public inputs for (size_t i = 0; i < num_gates; ++i) { - FF a, b, c; - if (random) { - a = FF::random_element(&engine); - b = FF::random_element(&engine); - c = FF::random_element(&engine); - } else { - a = FF(1); - b = FF(2); - c = FF(3); - } + FF a = FF::random_element(&engine); + FF b = FF::random_element(&engine); + FF c = FF::random_element(&engine); FF d = a + b + c; uint32_t a_idx = builder.add_public_variable(a); uint32_t b_idx = builder.add_variable(b); @@ -51,21 +42,12 @@ class MockCircuits { * @param builder * @param num_gates */ - template - static void add_arithmetic_gates(Builder& builder, const size_t num_gates = 4, bool random = true) + template static void add_arithmetic_gates(Builder& builder, const size_t num_gates = 4) { - // For good measure, include a gate with some public inputs for (size_t i = 0; i < num_gates; ++i) { - FF a, b, c; - if (random) { - a = FF::random_element(&engine); - b = FF::random_element(&engine); - c = FF::random_element(&engine); - } else { - a = FF(1); - b = FF(2); - c = FF(3); - } + FF a = FF::random_element(&engine); + FF b = FF::random_element(&engine); + FF c = FF::random_element(&engine); FF d = a + b + c; uint32_t a_idx = builder.add_variable(a); uint32_t b_idx = builder.add_variable(b); @@ -83,18 +65,15 @@ class MockCircuits { * @param num_gates */ template - static void construct_arithmetic_circuit(Builder& builder, - const size_t target_log2_dyadic_size = 4, - bool random = true, - bool has_pub_input = true) + static void construct_arithmetic_circuit(Builder& builder, const size_t target_log2_dyadic_size = 4) { const size_t target_dyadic_size = 1 << target_log2_dyadic_size; const size_t num_preamble_gates = builder.num_gates; ASSERT(target_dyadic_size >= num_preamble_gates); // For good measure, include a gate with some public inputs - if (has_pub_input && target_dyadic_size > num_preamble_gates) { - add_arithmetic_gates_with_public_inputs(builder, 1, random); + if (target_dyadic_size > num_preamble_gates) { + add_arithmetic_gates_with_public_inputs(builder, 1); } // A proper treatment of this would dynamically calculate how many gates to add given static information about @@ -110,7 +89,7 @@ class MockCircuits { size_t num_gates_to_add = target_dyadic_size - OFFSET_HACK - 1 - num_preamble_gates; // Add arbitrary arithmetic gates to obtain a total of num_gates-many gates - add_arithmetic_gates(builder, num_gates_to_add, random); + add_arithmetic_gates(builder, num_gates_to_add); } /** From c1e7e07cb8ec21357016a076af19df94ecb1c272 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Thu, 20 Jun 2024 16:00:53 +0000 Subject: [PATCH 4/4] update to_json --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 6764ffeefd7..114e2f0caf2 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -1017,7 +1017,7 @@ void prove_honk_output_all(const std::string& bytecodePath, vinfo("binary proof written to: ", proofPath); // Write the proof as fields - std::string proofJson = proof_to_json(proof); + std::string proofJson = to_json(proof); write_file(proofFieldsPath, { proofJson.begin(), proofJson.end() }); vinfo("proof as fields written to: ", proofFieldsPath);