diff --git a/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp b/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp index 5ab7fcab34b..bd8f7cda186 100644 --- a/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp @@ -8,7 +8,7 @@ inline std::vector exec_pipe(std::string const& command) { FILE* pipe = popen(command.c_str(), "r"); if (!pipe) { - throw std::runtime_error("popen() failed!"); + throw std::runtime_error("popen() failed! Can't run: " + command); } std::vector result; diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp index ad23caec6a4..e0eb99beb05 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp @@ -41,7 +41,7 @@ std::vector get_bn254_g1_data(const std::filesystem::path& p if (g1_file_size >= num_points * 64 && g1_file_size % 64 == 0) { vinfo("using cached bn254 crs of size ", std::to_string(g1_file_size / 64), " at ", g1_path); - auto data = read_file(g1_path, g1_file_size); + auto data = read_file(g1_path, num_points * 64); auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { points[i] = from_buffer(data, i * 64); diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index f9d45093549..8412faee038 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -910,17 +910,23 @@ UltraProver_ compute_valid_prover(const std::string& bytecodePath, } else if constexpr (IsAnyOf) { honk_recursion = 2; } - const acir_format::ProgramMetadata metadata{ .recursive = recursive, .honk_recursion = honk_recursion }; - acir_format::AcirProgram program{ get_constraint_system(bytecodePath, metadata.honk_recursion) }; - if (!witnessPath.empty()) { - program.witness = get_witness(witnessPath); - } // TODO(https://github.com/AztecProtocol/barretenberg/issues/1180): Don't init grumpkin crs when unnecessary. init_grumpkin_crs(1 << CONST_ECCVM_LOG_N); - auto builder = acir_format::create_circuit(program, metadata); - auto prover = Prover{ builder }; + // Lambda function to ensure the builder gets freed before generating the vk. Vk generation requires initialing the + // pippenger runtime state which leads to it being the peak, when its functionality is purely for debugging purposes + // here. + auto prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = recursive, .honk_recursion = honk_recursion }; + acir_format::AcirProgram program{ get_constraint_system(bytecodePath, metadata.honk_recursion) }; + if (!witnessPath.empty()) { + program.witness = get_witness(witnessPath); + } + auto builder = acir_format::create_circuit(program, metadata); + return Prover{ builder }; + }(); + size_t required_crs_size = prover.proving_key->proving_key.circuit_size; if constexpr (Flavor::HasZK) { // Ensure there are enough points to commit to the libra polynomials required for zero-knowledge sumcheck diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index a3e037af23f..980c57eec92 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -316,16 +316,18 @@ WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ - acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), - acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) - }; + // Lambda function to ensure things get freed before proving. + UltraProver prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion), + acir_format::witness_buf_to_witness_data( + from_buffer>(witness_vec)) }; + auto builder = acir_format::create_circuit(program, metadata); + + return UltraProver(builder); + }(); - auto builder = acir_format::create_circuit(program, metadata); - - UltraProver prover{ builder }; auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -335,14 +337,17 @@ WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { - auto constraint_system = - acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), /*honk_recursion=*/1); - auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); - - auto builder = acir_format::create_circuit( - constraint_system, *recursive, 0, witness, /*honk_recursion=*/1); - - UltraKeccakProver prover{ builder }; + // Lambda function to ensure things get freed before proving. + UltraKeccakProver prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion), + acir_format::witness_buf_to_witness_data( + from_buffer>(witness_vec)) }; + auto builder = acir_format::create_circuit(program, metadata); + + return UltraKeccakProver(builder); + }(); auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -381,15 +386,16 @@ WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* r { using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraFlavor::VerificationKey; - - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( - from_buffer>(acir_vec), metadata.honk_recursion) }; - auto builder = acir_format::create_circuit(program, metadata); - - DeciderProvingKey proving_key(builder); + // lambda to free the builder + DeciderProvingKey proving_key = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion) }; + auto builder = acir_format::create_circuit(program, metadata); + return DeciderProvingKey(builder); + }(); VerificationKey vk(proving_key.proving_key); + vinfo("Constructed UltraHonk verification key"); *out = to_heap_buffer(to_buffer(vk)); } @@ -398,14 +404,16 @@ WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool c using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraKeccakFlavor::VerificationKey; - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( - from_buffer>(acir_vec), metadata.honk_recursion) }; - auto builder = acir_format::create_circuit(program, metadata); - - DeciderProvingKey proving_key(builder); + // lambda to free the builder + DeciderProvingKey proving_key = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion) }; + auto builder = acir_format::create_circuit(program, metadata); + return DeciderProvingKey(builder); + }(); VerificationKey vk(proving_key.proving_key); + vinfo("Constructed UltraKeccakHonk verification key"); *out = to_heap_buffer(to_buffer(vk)); } diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index 978c3b203e8..8eef6b58e48 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -278,6 +278,8 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof ECCVMProver prover(builder); + prover.transcript->enable_manifest(); + prover.ipa_transcript->enable_manifest(); ECCVMProof proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -285,6 +287,7 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) auto prover_manifest = prover.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { ASSERT_EQ(prover_manifest[round], manifest_expected[round]) << "Prover manifest discrepency in round " << round; } @@ -293,6 +296,7 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) auto prover_ipa_manifest = prover.ipa_transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(ipa_manifest_expected.size() > 0); for (size_t round = 0; round < ipa_manifest_expected.size(); ++round) { ASSERT_EQ(prover_ipa_manifest[round], ipa_manifest_expected[round]) << "IPA prover manifest discrepency in round " << round; @@ -311,6 +315,8 @@ TEST_F(ECCVMTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof ECCVMProver prover(builder); + prover.transcript->enable_manifest(); + prover.ipa_transcript->enable_manifest(); ECCVMProof proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -325,10 +331,20 @@ TEST_F(ECCVMTranscriptTests, VerifierManifestConsistency) // The last challenge generated by the ECCVM Prover is the translation univariate batching challenge and, on the // verifier side, is only generated in the translator verifier hence the ECCVM prover's manifest will have one extra // challenge + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size() - 1; ++round) { ASSERT_EQ(prover_manifest[round], verifier_manifest[round]) << "Prover/Verifier manifest discrepency in round " << round; } + + // Check consistency of IPA transcripts + auto prover_ipa_manifest = prover.ipa_transcript->get_manifest(); + auto verifier_ipa_manifest = verifier.ipa_transcript->get_manifest(); + ASSERT(prover_ipa_manifest.size() > 0); + for (size_t round = 0; round < prover_ipa_manifest.size(); ++round) { + ASSERT_EQ(prover_ipa_manifest[round], verifier_ipa_manifest[round]) + << "Prover/Verifier IPA manifest discrepency in round " << round; + } } /** diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 8a7d43f880b..82606aa3729 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -20,6 +20,9 @@ bool ECCVMVerifier::verify_proof(const ECCVMProof& proof) RelationParameters relation_parameters; transcript = std::make_shared(proof.pre_ipa_proof); ipa_transcript = std::make_shared(proof.ipa_proof); + transcript->enable_manifest(); + ipa_transcript->enable_manifest(); + VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 3d7cbec843d..b4eadf05b82 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -19,6 +19,7 @@ void ProtogalaxyVerifier_::run_oink_verifier_on_each_in const std::vector& proof) { transcript = std::make_shared(proof); + transcript->enable_manifest(); size_t index = 0; auto key = keys_to_fold[0]; auto domain_separator = std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp index 101dc7067a7..078049b831e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp @@ -34,6 +34,8 @@ ECCVMRecursiveVerifier_::verify_proof(const ECCVMProof& proof) StdlibProof stdlib_ipa_proof = bb::convert_native_proof_to_stdlib(builder, proof.ipa_proof); transcript = std::make_shared(stdlib_proof); ipa_transcript = std::make_shared(stdlib_ipa_proof); + transcript->enable_manifest(); + ipa_transcript->enable_manifest(); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp index 88dadca1976..76ec71551ad 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp @@ -102,6 +102,8 @@ template class ECCVMRecursiveTests : public ::testing EXPECT_TRUE(native_result); auto recursive_manifest = verifier.transcript->get_manifest(); auto native_manifest = native_verifier.transcript->get_manifest(); + + ASSERT(recursive_manifest.size() > 0); for (size_t i = 0; i < recursive_manifest.size(); ++i) { EXPECT_EQ(recursive_manifest[i], native_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp index 607f7b17f17..1e1a93aeae9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp @@ -19,6 +19,7 @@ void ProtogalaxyRecursiveVerifier_::run_oink_verifier_o const std::vector& proof) { transcript = std::make_shared(proof); + transcript->enable_manifest(); size_t index = 0; auto key = keys_to_fold[0]; auto domain_separator = std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp index 18e8643ab3b..40f31064e90 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp @@ -238,6 +238,7 @@ template class ProtogalaxyRecursiveTests : public tes auto recursive_folding_manifest = verifier.transcript->get_manifest(); auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); + ASSERT(recursive_folding_manifest.size() > 0); for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; @@ -316,6 +317,7 @@ template class ProtogalaxyRecursiveTests : public tes auto recursive_folding_manifest = verifier.transcript->get_manifest(); auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); + ASSERT(recursive_folding_manifest.size() > 0); for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; diff --git a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp index 9948d588777..4023fcedc12 100644 --- a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp +++ b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp @@ -55,9 +55,11 @@ void TraceToPolynomials::add_memory_records_to_proving_key(TraceData& tr ASSERT(proving_key.memory_read_records.empty() && proving_key.memory_write_records.empty()); // Update indices of RAM/ROM reads/writes based on where block containing these gates sits in the trace + proving_key.memory_read_records.reserve(builder.memory_read_records.size()); for (auto& index : builder.memory_read_records) { proving_key.memory_read_records.emplace_back(index + trace_data.ram_rom_offset); } + proving_key.memory_write_records.reserve(builder.memory_write_records.size()); for (auto& index : builder.memory_write_records) { proving_key.memory_write_records.emplace_back(index + trace_data.ram_rom_offset); } diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 06d09946bcc..032bc847294 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -150,6 +150,8 @@ template class BaseTranscript { Fr previous_challenge{}; // default-initialized to zeros std::vector current_round_data; + bool use_manifest = false; // indicates whether the manifest is turned on, currently only on for manifest tests. + // "Manifest" object that records a summary of the transcript interactions TranscriptManifest manifest; @@ -211,8 +213,10 @@ template class BaseTranscript { */ void consume_prover_element_frs(const std::string& label, std::span element_frs) { - // Add an entry to the current round of the manifest - manifest.add_entry(round_number, label, element_frs.size()); + if (use_manifest) { + // Add an entry to the current round of the manifest + manifest.add_entry(round_number, label, element_frs.size()); + } current_round_data.insert(current_round_data.end(), element_frs.begin(), element_frs.end()); @@ -276,6 +280,12 @@ template class BaseTranscript { std::copy(proof.begin(), proof.end(), std::back_inserter(proof_data)); } + /** + * @brief Enables the manifest + * + */ + void enable_manifest() { use_manifest = true; } + /** * @brief After all the prover messages have been sent, finalize the round by hashing all the data and then * create the number of requested challenges. @@ -290,8 +300,10 @@ template class BaseTranscript { { constexpr size_t num_challenges = sizeof...(Strings); - // Add challenge labels for current round to the manifest - manifest.add_challenge(round_number, labels...); + if (use_manifest) { + // Add challenge labels for current round to the manifest + manifest.add_challenge(round_number, labels...); + } // Compute the new challenge buffer from which we derive the challenges. @@ -438,7 +450,13 @@ template class BaseTranscript { [[nodiscard]] TranscriptManifest get_manifest() const { return manifest; }; - void print() { manifest.print(); } + void print() + { + if (!use_manifest) { + info("Warning: manifest is not enabled!"); + } + manifest.print(); + } }; template diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp index 43a0393bbfd..ecc5dc5038b 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp @@ -93,7 +93,7 @@ template void DeciderProvingKey_::allocate_select template void DeciderProvingKey_::allocate_table_lookup_polynomials(const Circuit& circuit) { - PROFILE_THIS_NAME("allocate_table_lookup_polynomials_and_inverses"); + PROFILE_THIS_NAME("allocate_table_lookup_and_lookup_read_polynomials"); size_t table_offset = circuit.blocks.lookup.trace_offset; // TODO(https://github.com/AztecProtocol/barretenberg/issues/1193): can potentially improve memory footprint @@ -143,6 +143,7 @@ template void DeciderProvingKey_::allocate_databus_polynomials(const Circuit& circuit) requires HasDataBus { + PROFILE_THIS_NAME("allocate_databus_and_lookup_inverse_polynomials"); proving_key.polynomials.calldata = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); proving_key.polynomials.calldata_read_counts = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); proving_key.polynomials.calldata_read_tags = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp index 17c558b1c85..b3fe19b10b6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp @@ -193,12 +193,14 @@ TYPED_TEST(MegaTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto proving_key = std::make_shared(builder); Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite auto manifest_expected = TestFixture::construct_mega_honk_manifest(); auto prover_manifest = prover.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { if (prover_manifest[round] != manifest_expected[round]) { info("Prover manifest discrepency in round ", round); @@ -229,6 +231,7 @@ TYPED_TEST(MegaTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto proving_key = std::make_shared(builder); Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -242,6 +245,7 @@ TYPED_TEST(MegaTranscriptTests, VerifierManifestConsistency) auto verifier_manifest = verifier.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size(); ++round) { if (prover_manifest[round] != verifier_manifest[round]) { info("Prover/Verifier manifest discrepency in round ", round); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 36b534e0dcb..8b619a76b23 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -59,10 +59,10 @@ template void OinkProver::prove() // Generate relation separators alphas for sumcheck/combiner computation proving_key->alphas = generate_alphas_round(); -#ifndef __wasm__ + // #ifndef __wasm__ // Free the commitment key proving_key->proving_key.commitment_key = nullptr; -#endif + // #endif } /** diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 2f61e40aa92..26aefc31c46 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -200,6 +200,7 @@ TYPED_TEST(UltraTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto proving_key = std::make_shared(builder); typename TestFixture::Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -208,6 +209,7 @@ TYPED_TEST(UltraTranscriptTests, ProverManifestConsistency) // Note: a manifest can be printed using manifest.print() manifest_expected.print(); prover_manifest.print(); + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { ASSERT_EQ(prover_manifest[round], manifest_expected[round]) << "Prover manifest discrepency in round " << round; } @@ -228,6 +230,7 @@ TYPED_TEST(UltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto proving_key = std::make_shared(builder); typename TestFixture::Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -258,6 +261,7 @@ TYPED_TEST(UltraTranscriptTests, VerifierManifestConsistency) auto verifier_manifest = verifier.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size(); ++round) { ASSERT_EQ(prover_manifest[round], verifier_manifest[round]) << "Prover/Verifier manifest discrepency in round " << round; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 692ac54397f..2c10eef26e3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -15,6 +15,7 @@ template bool UltraVerifier_::verify_proof(const HonkP using FF = typename Flavor::FF; transcript = std::make_shared(proof); + transcript->enable_manifest(); // Enable manifest for the verifier. OinkVerifier oink_verifier{ verification_key, transcript }; oink_verifier.verify(); @@ -58,7 +59,8 @@ template bool UltraVerifier_::verify_proof(const HonkP }; // verify the ipa_proof with this claim - auto ipa_transcript = std::make_shared(ipa_proof); + ipa_transcript = std::make_shared(ipa_proof); + ipa_transcript->enable_manifest(); // Enable manifest for the verifier. bool ipa_result = IPA::reduce_verify(ipa_verification_key, ipa_claim, ipa_transcript); if (!ipa_result) { return false; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index effd6a3de94..884bd6ecb90 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -27,6 +27,7 @@ template class UltraVerifier_ { bool verify_proof(const HonkProof& proof, const HonkProof& ipa_proof = {}); std::shared_ptr transcript{ nullptr }; + std::shared_ptr ipa_transcript{ nullptr }; std::shared_ptr verification_key; std::shared_ptr> ipa_verification_key; }; diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 3a492e21495..da73d019bb0 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -84,6 +84,7 @@ async function initUltraPlonk( ) { const api = await Barretenberg.new({ threads }); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraPlonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, honkRecursion, api); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin @@ -112,6 +113,7 @@ async function initUltraPlonk( async function initUltraHonk(bytecodePath: string, recursive: boolean, crsPath: string) { const api = await Barretenberg.new({ threads }); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, /*honkRecursion=*/ true, api); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin