diff --git a/barretenberg/cpp/format.sh b/barretenberg/cpp/format.sh index e1836e48165f..5802f5624ae8 100755 --- a/barretenberg/cpp/format.sh +++ b/barretenberg/cpp/format.sh @@ -1,30 +1,28 @@ #!/usr/bin/env bash -set -e +function format_files { + if [ -n "$1" ]; then + echo "$1" | parallel -j+0 'clang-format-20 -i {} && sed -i.bak "s/\r$//" {} && rm {}.bak' + fi +} if [ "$1" == "staged" ]; then echo Formatting barretenberg staged files... - for FILE in $(git diff-index --diff-filter=d --relative --cached --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$'); do - clang-format-20 -i $FILE - sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak - git add $FILE - done + files=$(git diff-index --diff-filter=d --relative --cached --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$') + format_files "$files" + if [ -n "$files" ]; then + git add "$files" + fi elif [ "$1" == "changed" ]; then echo Formatting barretenberg changed files... - for FILE in $(git diff-index --diff-filter=d --relative --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$'); do - clang-format-20 -i $FILE - sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak - done + files=$(git diff-index --diff-filter=d --relative --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$') + format_files "$files" elif [ "$1" == "check" ]; then - find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v src/msgpack-c | grep -v bb/deps | \ - parallel -N10 clang-format-20 --dry-run --Werror + files=$(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v bb/deps) + echo "$files" | parallel -N10 clang-format-20 --dry-run --Werror elif [ -n "$1" ]; then - for FILE in $(git diff-index --relative --name-only $1 | grep -e '\.\(cpp\|hpp\|tcc\)$'); do - clang-format-20 -i $FILE - sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak - done + files=$(git diff-index --relative --name-only $1 | grep -e '\.\(cpp\|hpp\|tcc\)$') + format_files "$files" else - for FILE in $(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v src/msgpack-c); do - clang-format-20 -i $FILE - sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak - done + files=$(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc) + format_files "$files" fi diff --git a/barretenberg/cpp/scripts/bench_hardware_concurrency.sh b/barretenberg/cpp/scripts/bench_hardware_concurrency.sh index 873b12aa1f69..941a89888acc 100755 --- a/barretenberg/cpp/scripts/bench_hardware_concurrency.sh +++ b/barretenberg/cpp/scripts/bench_hardware_concurrency.sh @@ -195,7 +195,7 @@ for test_case in test_cases: for cpu, metrics in all_data.items(): for metric_name, time_ms in metrics.items(): # Categorize metrics based on name - if "Chonk" in metric_name or "SumcheckChonk" in metric_name: + if "Chonk" in metric_name or "Chonk" in metric_name: components["Main"][metric_name][cpu] = time_ms elif "ProtogalaxyProver" in metric_name: components["ProtogalaxyProver"][metric_name][cpu] = time_ms diff --git a/barretenberg/cpp/src/barretenberg/api/api_chonk.cpp b/barretenberg/cpp/src/barretenberg/api/api_chonk.cpp index 97a2a8ed40da..773da9c0ab5c 100644 --- a/barretenberg/cpp/src/barretenberg/api/api_chonk.cpp +++ b/barretenberg/cpp/src/barretenberg/api/api_chonk.cpp @@ -2,15 +2,15 @@ #include "barretenberg/api/file_io.hpp" #include "barretenberg/api/log.hpp" #include "barretenberg/bbapi/bbapi.hpp" +#include "barretenberg/chonk/chonk.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/chonk/private_execution_steps.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" #include "barretenberg/common/get_bytecode.hpp" #include "barretenberg/common/map.hpp" #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/common/try_catch_shim.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "barretenberg/serialize/msgpack.hpp" #include "barretenberg/serialize/msgpack_check_eq.hpp" #include @@ -44,7 +44,7 @@ void write_standalone_vk(std::vector bytecode, const std::filesystem::p void write_chonk_vk(std::vector bytecode, const std::filesystem::path& output_dir) { // compute the hiding kernel's vk - info("SumcheckChonk: computing IVC vk for hiding kernel circuit"); + info("Chonk: computing IVC vk for hiding kernel circuit"); auto response = bbapi::ChonkComputeIvcVk{ .circuit{ .bytecode = std::move(bytecode) } }.execute(); const bool output_to_stdout = output_dir == "-"; if (output_to_stdout) { @@ -65,14 +65,14 @@ void ChonkAPI::prove(const Flags& flags, std::vector raw_steps = PrivateExecutionStepRaw::load_and_decompress(input_path); bbapi::ChonkStart{ .num_circuits = raw_steps.size() }.execute(request); - info("SumcheckChonk: starting with ", raw_steps.size(), " circuits"); + info("Chonk: starting with ", raw_steps.size(), " circuits"); for (const auto& step : raw_steps) { bbapi::ChonkLoad{ .circuit = { .name = step.function_name, .bytecode = step.bytecode, .verification_key = step.vk } }.execute(request); // NOLINTNEXTLINE(bugprone-unchecked-optional-access): we know the optional has been set here. - info("SumcheckChonk: accumulating " + step.function_name); + info("Chonk: accumulating " + step.function_name); bbapi::ChonkAccumulate{ .witness = step.witness }.execute(request); } @@ -85,10 +85,10 @@ void ChonkAPI::prove(const Flags& flags, const auto write_proof = [&]() { const auto buf = to_buffer(proof.to_field_elements()); if (output_to_stdout) { - vinfo("writing SumcheckChonk proof to stdout"); + vinfo("writing Chonk proof to stdout"); write_bytes_to_stdout(buf); } else { - vinfo("writing SumcheckChonk proof in directory ", output_dir); + vinfo("writing Chonk proof in directory ", output_dir); write_file(output_dir / "proof", buf); } }; @@ -96,7 +96,7 @@ void ChonkAPI::prove(const Flags& flags, write_proof(); if (flags.write_vk) { - vinfo("writing SumcheckChonk vk in directory ", output_dir); + vinfo("writing Chonk vk in directory ", output_dir); // write CHONK vk using the bytecode of the hiding circuit (the last step of the execution) write_chonk_vk(raw_steps[raw_steps.size() - 1].bytecode, output_dir); } @@ -109,7 +109,7 @@ bool ChonkAPI::verify([[maybe_unused]] const Flags& flags, { BB_BENCH_NAME("ChonkAPI::verify"); auto proof_fields = many_from_buffer(read_file(proof_path)); - auto proof = SumcheckChonk::Proof::from_field_elements(proof_fields); + auto proof = Chonk::Proof::from_field_elements(proof_fields); auto vk_buffer = read_file(vk_path); @@ -123,11 +123,11 @@ bool ChonkAPI::prove_and_verify(const std::filesystem::path& input_path) PrivateExecutionSteps steps; steps.parse(PrivateExecutionStepRaw::load_and_decompress(input_path)); - std::shared_ptr ivc = steps.accumulate(); + std::shared_ptr ivc = steps.accumulate(); // Construct the hiding kernel as the final step of the IVC auto proof = ivc->prove(); - const bool verified = SumcheckChonk::verify(proof, ivc->get_vk()); + const bool verified = Chonk::verify(proof, ivc->get_vk()); return verified; } diff --git a/barretenberg/cpp/src/barretenberg/api/api_chonk.test.cpp b/barretenberg/cpp/src/barretenberg/api/api_chonk.test.cpp index 01da06ac6bd3..fa951c636fbd 100644 --- a/barretenberg/cpp/src/barretenberg/api/api_chonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/api/api_chonk.test.cpp @@ -3,9 +3,9 @@ #include "barretenberg/bbapi/bbapi.hpp" #include "barretenberg/bbapi/bbapi_execute.hpp" #include "barretenberg/chonk/acir_bincode_mocks.hpp" +#include "barretenberg/chonk/chonk.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/chonk/private_execution_steps.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_format_mocks.hpp" @@ -105,7 +105,7 @@ std::vector compress(const std::vector& input); } // namespace bb // Helper to get an IVC verification key for testing -SumcheckChonk::MegaVerificationKey get_ivc_vk(const std::filesystem::path& test_dir) +Chonk::MegaVerificationKey get_ivc_vk(const std::filesystem::path& test_dir) { auto [app_bytecode, app_witness_data] = acir_bincode_mocks::create_simple_circuit_bytecode(); bbapi::BBApiRequest request; @@ -128,7 +128,7 @@ SumcheckChonk::MegaVerificationKey get_ivc_vk(const std::filesystem::path& test_ api.write_vk(write_vk_flags, bytecode_path, test_dir); auto buffer = read_file(test_dir / "vk"); - return from_buffer(buffer); + return from_buffer(buffer); }; // Test the ChonkAPI::prove flow, making sure --write_vk @@ -153,10 +153,9 @@ TEST_F(ChonkAPITests, DISABLED_ProveAndVerifyFileBasedFlow) }; // Helper lambda to verify VK equivalence - auto verify_vk_equivalence = [&](const std::filesystem::path& vk1_path, - const SumcheckChonk::MegaVerificationKey& vk2) { + auto verify_vk_equivalence = [&](const std::filesystem::path& vk1_path, const Chonk::MegaVerificationKey& vk2) { auto vk1_data = read_file(vk1_path); - auto vk1 = from_buffer(vk1_data); + auto vk1 = from_buffer(vk1_data); ASSERT_EQ(vk1, vk2); }; @@ -164,7 +163,7 @@ TEST_F(ChonkAPITests, DISABLED_ProveAndVerifyFileBasedFlow) auto verify_proof = [&]() { std::filesystem::path proof_path = output_dir / "proof"; std::filesystem::path vk_path = output_dir / "vk"; - std::filesystem::path public_inputs_path; // Not used for SumcheckChonk + std::filesystem::path public_inputs_path; // Not used for Chonk ChonkAPI::Flags flags; ChonkAPI verify_api; diff --git a/barretenberg/cpp/src/barretenberg/bb/cli.cpp b/barretenberg/cpp/src/barretenberg/bb/cli.cpp index 55f9e094ab50..b8a9e06f48e1 100644 --- a/barretenberg/cpp/src/barretenberg/bb/cli.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/cli.cpp @@ -249,7 +249,7 @@ int parse_and_run_cli_command(int argc, char* argv[]) "verification). `standalone_hiding` is similar to `standalone` but is used for the last step " "where the structured trace is not utilized. `ivc` produces a verification key for verifying " "the stack of run though a dedicated ivc verifier class (currently the only option is the " - "SumcheckChonk class)") + "Chonk class)") ->check(CLI::IsMember({ "standalone", "standalone_hiding", "ivc" }).name("is_member")); }; @@ -655,9 +655,8 @@ int parse_and_run_cli_command(int argc, char* argv[]) ChonkAPI api; if (prove->parsed()) { if (!std::filesystem::exists(ivc_inputs_path)) { - throw_or_abort( - "The prove command for SumcheckChonk expect a valid file passed with --ivc_inputs_path " - " (default ./ivc-inputs.msgpack)"); + throw_or_abort("The prove command for Chonk expect a valid file passed with --ivc_inputs_path " + " (default ./ivc-inputs.msgpack)"); } api.prove(flags, ivc_inputs_path, output_path); #if !defined(__wasm__) || defined(ENABLE_WASM_BENCH) @@ -679,9 +678,8 @@ int parse_and_run_cli_command(int argc, char* argv[]) } if (check->parsed()) { if (!std::filesystem::exists(ivc_inputs_path)) { - throw_or_abort( - "The check command for SumcheckChonk expect a valid file passed with --ivc_inputs_path " - " (default ./ivc-inputs.msgpack)"); + throw_or_abort("The check command for Chonk expect a valid file passed with --ivc_inputs_path " + " (default ./ivc-inputs.msgpack)"); } return api.check_precomputed_vks(flags, ivc_inputs_path) ? 0 : 1; } diff --git a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp index 52b2aeae6911..cac651f580e5 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp +++ b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.cpp @@ -1,11 +1,11 @@ #include "barretenberg/bbapi/bbapi_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/common/log.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "barretenberg/dsl/acir_format/serde/witness_stack.hpp" #include "barretenberg/serialize/msgpack_check_eq.hpp" #include "barretenberg/stdlib_circuit_builders/mega_circuit_builder.hpp" @@ -16,7 +16,7 @@ ChonkStart::Response ChonkStart::execute(BBApiRequest& request) && { BB_BENCH_NAME(MSGPACK_SCHEMA_NAME); - request.ivc_in_progress = std::make_shared(num_circuits); + request.ivc_in_progress = std::make_shared(num_circuits); request.ivc_stack_depth = 0; return Response{}; @@ -26,7 +26,7 @@ ChonkLoad::Response ChonkLoad::execute(BBApiRequest& request) && { BB_BENCH_NAME(MSGPACK_SCHEMA_NAME); if (!request.ivc_in_progress) { - throw_or_abort("SumcheckChonk not started. Call ChonkStart first."); + throw_or_abort("Chonk not started. Call ChonkStart first."); } request.loaded_circuit_name = circuit.name; @@ -42,7 +42,7 @@ ChonkAccumulate::Response ChonkAccumulate::execute(BBApiRequest& request) && { BB_BENCH_NAME(MSGPACK_SCHEMA_NAME); if (!request.ivc_in_progress) { - throw_or_abort("SumcheckChonk not started. Call ChonkStart first."); + throw_or_abort("Chonk not started. Call ChonkStart first."); } if (!request.loaded_circuit_constraints.has_value()) { @@ -55,19 +55,17 @@ ChonkAccumulate::Response ChonkAccumulate::execute(BBApiRequest& request) && const acir_format::ProgramMetadata metadata{ .ivc = request.ivc_in_progress }; auto circuit = acir_format::create_circuit(program, metadata); - std::shared_ptr precomputed_vk; + std::shared_ptr precomputed_vk; if (request.vk_policy == VkPolicy::RECOMPUTE) { precomputed_vk = nullptr; } else if (request.vk_policy == VkPolicy::DEFAULT || request.vk_policy == VkPolicy::CHECK) { if (!request.loaded_circuit_vk.empty()) { - precomputed_vk = - from_buffer>(request.loaded_circuit_vk); + precomputed_vk = from_buffer>(request.loaded_circuit_vk); if (request.vk_policy == VkPolicy::CHECK) { - auto prover_instance = std::make_shared(circuit); - auto computed_vk = - std::make_shared(prover_instance->get_precomputed()); + auto prover_instance = std::make_shared(circuit); + auto computed_vk = std::make_shared(prover_instance->get_precomputed()); // Dereference to compare VK contents if (*precomputed_vk != *computed_vk) { @@ -94,7 +92,7 @@ ChonkProve::Response ChonkProve::execute(BBApiRequest& request) && { BB_BENCH_NAME(MSGPACK_SCHEMA_NAME); if (!request.ivc_in_progress) { - throw_or_abort("SumcheckChonk not started. Call ChonkStart first."); + throw_or_abort("Chonk not started. Call ChonkStart first."); } if (request.ivc_stack_depth == 0) { @@ -107,22 +105,22 @@ ChonkProve::Response ChonkProve::execute(BBApiRequest& request) && Response response; bool verification_passed = false; - info("ChonkProve - using SumcheckChonk"); - auto sumcheck_ivc = std::dynamic_pointer_cast(request.ivc_in_progress); + info("ChonkProve - using Chonk"); + auto sumcheck_ivc = std::dynamic_pointer_cast(request.ivc_in_progress); auto proof = sumcheck_ivc->prove(); auto vk = sumcheck_ivc->get_vk(); // We verify this proof. Another bb call to verify has some overhead of loading VK/proof/SRS, // and it is mysterious if this transaction fails later in the lifecycle. info("ChonkProve - verifying the generated proof as a sanity check"); - verification_passed = SumcheckChonk::verify(proof, vk); + verification_passed = Chonk::verify(proof, vk); if (!verification_passed) { throw_or_abort("Failed to verify the generated proof!"); } - response.proof = SumcheckChonk::Proof{ .mega_proof = std::move(proof.mega_proof), - .goblin_proof = std::move(proof.goblin_proof) }; + response.proof = + Chonk::Proof{ .mega_proof = std::move(proof.mega_proof), .goblin_proof = std::move(proof.goblin_proof) }; request.ivc_in_progress.reset(); request.ivc_stack_depth = 0; @@ -134,21 +132,20 @@ ChonkVerify::Response ChonkVerify::execute(const BBApiRequest& /*request*/) && { BB_BENCH_NAME(MSGPACK_SCHEMA_NAME); // Deserialize the verification key directly from buffer - SumcheckChonk::VerificationKey verification_key = from_buffer(vk); + Chonk::VerificationKey verification_key = from_buffer(vk); - // Verify the proof using SumcheckChonk's static verify method - const bool verified = SumcheckChonk::verify(proof, verification_key); + // Verify the proof using Chonk's static verify method + const bool verified = Chonk::verify(proof, verification_key); return { .valid = verified }; } -static std::shared_ptr get_acir_program_prover_instance( - acir_format::AcirProgram& program) +static std::shared_ptr get_acir_program_prover_instance(acir_format::AcirProgram& program) { - SumcheckChonk::ClientCircuit builder = acir_format::create_circuit(program); + Chonk::ClientCircuit builder = acir_format::create_circuit(program); // Construct the verification key via the prover-constructed proving key with the proper trace settings - return std::make_shared(builder); + return std::make_shared(builder); } ChonkComputeStandaloneVk::Response ChonkComputeStandaloneVk::execute([[maybe_unused]] const BBApiRequest& request) && @@ -159,8 +156,8 @@ ChonkComputeStandaloneVk::Response ChonkComputeStandaloneVk::execute([[maybe_unu auto constraint_system = acir_format::circuit_buf_to_acir_format(std::move(circuit.bytecode)); acir_format::AcirProgram program{ constraint_system, /*witness=*/{} }; - std::shared_ptr prover_instance = get_acir_program_prover_instance(program); - auto verification_key = std::make_shared(prover_instance->get_precomputed()); + std::shared_ptr prover_instance = get_acir_program_prover_instance(program); + auto verification_key = std::make_shared(prover_instance->get_precomputed()); return { .bytes = to_buffer(*verification_key), .fields = verification_key->to_field_elements() }; } @@ -174,11 +171,10 @@ ChonkComputeIvcVk::Response ChonkComputeIvcVk::execute(BB_UNUSED const BBApiRequ .circuit{ .name = "standalone_circuit", .bytecode = std::move(circuit.bytecode) } }.execute(); - auto mega_vk = from_buffer(standalone_vk_response.bytes); - SumcheckChonk::VerificationKey chonk_vk{ .mega = std::make_shared(mega_vk), - .eccvm = std::make_shared(), - .translator = - std::make_shared() }; + auto mega_vk = from_buffer(standalone_vk_response.bytes); + Chonk::VerificationKey chonk_vk{ .mega = std::make_shared(mega_vk), + .eccvm = std::make_shared(), + .translator = std::make_shared() }; Response response; response.bytes = to_buffer(chonk_vk); @@ -193,8 +189,8 @@ ChonkCheckPrecomputedVk::Response ChonkCheckPrecomputedVk::execute([[maybe_unuse acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format(std::move(circuit.bytecode)), /*witness=*/{} }; - std::shared_ptr prover_instance = get_acir_program_prover_instance(program); - auto computed_vk = std::make_shared(prover_instance->get_precomputed()); + std::shared_ptr prover_instance = get_acir_program_prover_instance(program); + auto computed_vk = std::make_shared(prover_instance->get_precomputed()); if (circuit.verification_key.empty()) { info("FAIL: Expected precomputed vk for function ", circuit.name); @@ -202,7 +198,7 @@ ChonkCheckPrecomputedVk::Response ChonkCheckPrecomputedVk::execute([[maybe_unuse } // Deserialize directly from buffer - auto precomputed_vk = from_buffer>(circuit.verification_key); + auto precomputed_vk = from_buffer>(circuit.verification_key); Response response; response.valid = true; @@ -222,12 +218,11 @@ ChonkStats::Response ChonkStats::execute([[maybe_unused]] BBApiRequest& request) acir_format::AcirProgram program{ constraint_system }; // Get IVC constraints if any - const auto& ivc_constraints = constraint_system.pg_recursion_constraints; + const auto& ivc_constraints = constraint_system.hn_recursion_constraints; // Create metadata with appropriate IVC context acir_format::ProgramMetadata metadata{ - .ivc = - ivc_constraints.empty() ? nullptr : acir_format::create_mock_sumcheck_ivc_from_constraints(ivc_constraints), + .ivc = ivc_constraints.empty() ? nullptr : acir_format::create_mock_chonk_from_constraints(ivc_constraints), .collect_gates_per_opcode = include_gates_per_opcode }; diff --git a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.hpp b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.hpp index 3a469f6f4e23..c88b28930b7f 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.hpp +++ b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.hpp @@ -1,13 +1,13 @@ #pragma once /** * @file bbapi_chonk.hpp - * @brief SumcheckChonk-specific command definitions for the Barretenberg RPC API. + * @brief Chonk-specific command definitions for the Barretenberg RPC API. * - * This file contains command structures for SumcheckChonk (Client-side Incrementally Verifiable Computation) + * This file contains command structures for Chonk (Client-side Incrementally Verifiable Computation) * operations including circuit loading, accumulation, proving, and verification key computation. */ #include "barretenberg/bbapi/bbapi_shared.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/named_union.hpp" #include "barretenberg/honk/proof_system/types/proof.hpp" #include "barretenberg/serialize/msgpack.hpp" @@ -17,7 +17,7 @@ namespace bb::bbapi { /** * @struct ChonkStart - * @brief Initialize a new SumcheckChonk instance for incremental proof accumulation + * @brief Initialize a new Chonk instance for incremental proof accumulation * * @note Only one IVC request can be made at a time for each batch_request. */ @@ -43,7 +43,7 @@ struct ChonkStart { /** * @struct ChonkLoad - * @brief Load a circuit into the SumcheckChonk instance for accumulation + * @brief Load a circuit into the Chonk instance for accumulation */ struct ChonkLoad { static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkLoad"; @@ -106,7 +106,7 @@ struct ChonkProve { static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkProveResponse"; /** @brief Complete IVC proof for all accumulated circuits */ - SumcheckChonk::Proof proof; + Chonk::Proof proof; MSGPACK_FIELDS(proof); bool operator==(const Response&) const = default; }; @@ -117,7 +117,7 @@ struct ChonkProve { /** * @struct ChonkVerify - * @brief Verify a SumcheckChonk proof with its verification key + * @brief Verify a Chonk proof with its verification key */ struct ChonkVerify { static constexpr const char MSGPACK_SCHEMA_NAME[] = "ChonkVerify"; @@ -135,8 +135,8 @@ struct ChonkVerify { bool operator==(const Response&) const = default; }; - /** @brief The SumcheckChonk proof to verify */ - SumcheckChonk::Proof proof; + /** @brief The Chonk proof to verify */ + Chonk::Proof proof; /** @brief The verification key */ std::vector vk; Response execute(const BBApiRequest& request = {}) &&; diff --git a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.test.cpp b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.test.cpp index 6cb035420901..3e016222e808 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_chonk.test.cpp @@ -1,6 +1,6 @@ #include "barretenberg/bbapi/bbapi_chonk.hpp" #include "barretenberg/chonk/acir_bincode_mocks.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" @@ -39,7 +39,7 @@ TEST_F(BBApiChonkTest, ChonkVkSerialization) auto vk_response = ChonkComputeIvcVk{ .circuit = { .name = "test_circuit", .bytecode = bytecode } }.execute(); // Create a VK from the field elements - SumcheckChonk::VerificationKey vk = from_buffer(vk_response.bytes); + Chonk::VerificationKey vk = from_buffer(vk_response.bytes); EXPECT_EQ(to_buffer(vk.to_field_elements()), vk_response.bytes) << "Serialized field elements should match original field elements"; } diff --git a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_shared.hpp b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_shared.hpp index 2b7c8157ab80..442c575d50f3 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_shared.hpp +++ b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_shared.hpp @@ -7,7 +7,7 @@ * including circuit input types and proof system settings. */ -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/honk/execution_trace/mega_execution_trace.hpp" #include @@ -28,7 +28,7 @@ enum class VkPolicy { /** * @struct CircuitInputNoVK - * @brief A circuit to be used in either ultrahonk or chonk (SumcheckChonk+honk) verification key derivation. + * @brief A circuit to be used in either ultrahonk or chonk verification key derivation. */ struct CircuitInputNoVK { /** @@ -53,7 +53,7 @@ struct CircuitInputNoVK { /** * @struct CircuitInput - * @brief A circuit to be used in either ultrahonk or SumcheckChonk-honk proving. + * @brief A circuit to be used in either ultrahonk or Chonk proving. */ struct CircuitInput { /** diff --git a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_ultra_honk.hpp b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_ultra_honk.hpp index e54364c3436e..68f25e7be8d4 100644 --- a/barretenberg/cpp/src/barretenberg/bbapi/bbapi_ultra_honk.hpp +++ b/barretenberg/cpp/src/barretenberg/bbapi/bbapi_ultra_honk.hpp @@ -41,7 +41,7 @@ struct CircuitComputeVk { * @struct CircuitProve * @brief Represents a request to generate a proof. * Currently, UltraHonk is the only proving system supported by BB (after plonk was deprecated and removed). - * This is used for one-shot proving, not our "IVC" scheme, SumcheckChonk-honk. For that, use the SumcheckChonk* + * This is used for one-shot proving, not our "IVC" scheme, Chonk. For that, use the Chonk* * commands. */ struct CircuitProve { diff --git a/barretenberg/cpp/src/barretenberg/benchmark/chonk_bench/chonk.bench.cpp b/barretenberg/cpp/src/barretenberg/benchmark/chonk_bench/chonk.bench.cpp index af2a483b856d..3fcbbd2deefa 100644 --- a/barretenberg/cpp/src/barretenberg/benchmark/chonk_bench/chonk.bench.cpp +++ b/barretenberg/cpp/src/barretenberg/benchmark/chonk_bench/chonk.bench.cpp @@ -37,7 +37,7 @@ BENCHMARK_DEFINE_F(ChonkBench, VerificationOnly)(benchmark::State& state) auto [proof, vk] = accumulate_and_prove_with_precomputed_vks(NUM_APP_CIRCUITS, precomputed_vks); for (auto _ : state) { - benchmark::DoNotOptimize(SumcheckChonk::verify(proof, vk)); + benchmark::DoNotOptimize(Chonk::verify(proof, vk)); } } diff --git a/barretenberg/cpp/src/barretenberg/chonk/acir_bincode_mocks.hpp b/barretenberg/cpp/src/barretenberg/chonk/acir_bincode_mocks.hpp index 3ea3ac20c9a4..e61a84ee0d88 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/acir_bincode_mocks.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/acir_bincode_mocks.hpp @@ -144,13 +144,13 @@ inline std::vector create_simple_kernel(size_t vk_size, bool is_init_ke Acir::FunctionInput predicate{ .value = predicate_const }; // Modeled after noir-projects/mock-protocol-circuits/crates/mock-private-kernel-init/src/main.nr - // We mock the init or tail kernels using OINK or PG respectively. + // We mock the init or tail kernels using OINK or HN respectively. Acir::BlackBoxFuncCall::RecursiveAggregation recursion{ .verification_key = vk_inputs, .proof = {}, .public_inputs = {}, .key_hash = key_hash, .proof_type = is_init_kernel ? acir_format::PROOF_TYPE::OINK - : acir_format::PROOF_TYPE::PG, + : acir_format::PROOF_TYPE::HN, .predicate = predicate }; Acir::BlackBoxFuncCall black_box_call; diff --git a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.cpp b/barretenberg/cpp/src/barretenberg/chonk/chonk.cpp similarity index 87% rename from barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.cpp rename to barretenberg/cpp/src/barretenberg/chonk/chonk.cpp index a95eff8e8387..35c900232182 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.cpp +++ b/barretenberg/cpp/src/barretenberg/chonk/chonk.cpp @@ -4,7 +4,7 @@ // external_2: { status: not started, auditors: [], date: YYYY-MM-DD } // ===================== -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/bb_bench.hpp" #include "barretenberg/common/streams.hpp" #include "barretenberg/honk/prover_instance_inspector.hpp" @@ -17,7 +17,7 @@ namespace bb { // Constructor -SumcheckChonk::SumcheckChonk(size_t num_circuits) +Chonk::Chonk(size_t num_circuits) : num_circuits(num_circuits) , goblin(bn254_commitment_key) { @@ -39,8 +39,8 @@ SumcheckChonk::SumcheckChonk(size_t num_circuits) * * @param circuit */ -void SumcheckChonk::instantiate_stdlib_verification_queue( - ClientCircuit& circuit, const std::vector>& input_keys) +void Chonk::instantiate_stdlib_verification_queue(ClientCircuit& circuit, + const std::vector>& input_keys) { bool vkeys_provided = !input_keys.empty(); if (vkeys_provided) { @@ -74,14 +74,14 @@ void SumcheckChonk::instantiate_stdlib_verification_queue( /** * @brief Populate the provided circuit with constraints for (1) recursive verification of the provided accumulation * proof and (2) the associated databus commitment consistency checks. - * @details The recursive verifier will be either Oink or Protogalaxy depending on the specified proof type. In either + * @details The recursive verifier will be either Oink or Hypernova depending on the specified proof type. In either * case, the verifier accumulator is updated in place via the verification algorithm. Databus commitment consistency * checks are performed on the witness commitments and public inputs extracted from the proof by the verifier. Merge - * verification is performed with commitments to the subtable t_j extracted from the PG verifier. The computed + * verification is performed with commitments to the subtable t_j extracted from the HN verifier. The computed * commitment T is propagated to the next step of recursive verification. * * @param circuit - * @param verifier_inputs {proof, vkey, type (Oink/PG)} A set of inputs for recursive verification + * @param verifier_inputs {proof, vkey, type (Oink/HN)} A set of inputs for recursive verification * @param merge_commitments Container for the commitments for the Merge recursive verification to be performed * @param accumulation_recursive_transcript Transcript shared across recursive verification of the folding of * K_{i-1} (kernel), A_{i,1} (app), .., A_{i, n} (app) @@ -89,10 +89,10 @@ void SumcheckChonk::instantiate_stdlib_verification_queue( * @return Triple of output verifier accumulator, PairingPoints for final verification and commitments to the merged * tables as read from the proof by the Merge verifier */ -std::tuple, - std::vector, - SumcheckChonk::TableCommitments> -SumcheckChonk::perform_recursive_verification_and_databus_consistency_checks( +std::tuple, + std::vector, + Chonk::TableCommitments> +Chonk::perform_recursive_verification_and_databus_consistency_checks( ClientCircuit& circuit, const StdlibVerifierInputs& verifier_inputs, const std::optional& input_verifier_accumulator, @@ -131,21 +131,21 @@ SumcheckChonk::perform_recursive_verification_and_databus_consistency_checks( merge_commitments.T_prev_commitments = stdlib::recursion::honk::empty_ecc_op_tables(circuit); break; } - case QUEUE_TYPE::PG: - case QUEUE_TYPE::PG_TAIL: { + case QUEUE_TYPE::HN: + case QUEUE_TYPE::HN_TAIL: { vinfo("Recursively verifying inner accumulation."); - auto [_first_sumcheck_verified, _second_sumcheck_verified, new_verifier_accumulator] = + auto [_first_verified, _second_verified, new_verifier_accumulator] = folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof); output_verifier_accumulator = std::move(new_verifier_accumulator); break; } - case QUEUE_TYPE::PG_FINAL: { + case QUEUE_TYPE::HN_FINAL: { vinfo("Recursively verifying accumulation of the tail kernel."); BB_ASSERT_EQ(stdlib_verification_queue.size(), size_t(1)); hide_op_queue_accumulation_result(circuit); - auto [_first_sumcheck_verified, _second_sumcheck_verified, final_verifier_accumulator] = + auto [_first_verified, _second_verified, final_verifier_accumulator] = folding_verifier.verify_folding_proof(verifier_instance, verifier_inputs.proof); RecursiveDeciderVerifier decider_verifier(accumulation_recursive_transcript); @@ -156,7 +156,7 @@ SumcheckChonk::perform_recursive_verification_and_databus_consistency_checks( break; } default: { - throw_or_abort("Invalid queue type! Only OINK, PG, PG_TAIL and PG_FINAL are supported"); + throw_or_abort("Invalid queue type! Only OINK, HN, HN_TAIL and HN_FINAL are supported"); } } @@ -178,14 +178,14 @@ SumcheckChonk::perform_recursive_verification_and_databus_consistency_checks( // verification of of the folding of K_{i-1} (kernel), A_{i} (app). This verification happens in K_{i} merge_commitments.T_prev_commitments = std::move(kernel_input.ecc_op_tables); - BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::PG || verifier_inputs.type == QUEUE_TYPE::PG_TAIL || - verifier_inputs.type == QUEUE_TYPE::PG_FINAL, + BB_ASSERT_EQ(verifier_inputs.type == QUEUE_TYPE::HN || verifier_inputs.type == QUEUE_TYPE::HN_TAIL || + verifier_inputs.type == QUEUE_TYPE::HN_FINAL, true, "Kernel circuits should be folded."); // Get the previous accum hash - info("Accumulator hash from IO: ", kernel_input.output_pg_accum_hash); + info("Accumulator hash from IO: ", kernel_input.output_hn_accum_hash); BB_ASSERT(prev_accum_hash.has_value()); - kernel_input.output_pg_accum_hash.assert_equal(*prev_accum_hash); + kernel_input.output_hn_accum_hash.assert_equal(*prev_accum_hash); // Set the kernel return data commitment to be propagated via the public inputs bus_depot.set_kernel_return_data_commitment(witness_commitments.return_data); @@ -213,13 +213,13 @@ SumcheckChonk::perform_recursive_verification_and_databus_consistency_checks( /** * @brief Append logic to complete a kernel circuit - * @details A kernel circuit may contain some combination of PG recursive verification, merge recursive + * @details A kernel circuit may contain some combination of HN recursive verification, merge recursive * verification, and databus commitment consistency checks. This method appends this logic to a provided kernel * circuit. * * @param circuit */ -void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) +void Chonk::complete_kernel_circuit_logic(ClientCircuit& circuit) { // Transcript to be shared across recursive verification of the folding of K_{i-1} (kernel), A_{i} (app) auto accumulation_recursive_transcript = std::make_shared(); @@ -236,10 +236,10 @@ void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) stdlib_verification_queue.size() == 1 && (stdlib_verification_queue.front().type == QUEUE_TYPE::OINK); bool is_tail_kernel = - stdlib_verification_queue.size() == 1 && (stdlib_verification_queue.front().type == QUEUE_TYPE::PG_TAIL); + stdlib_verification_queue.size() == 1 && (stdlib_verification_queue.front().type == QUEUE_TYPE::HN_TAIL); bool is_hiding_kernel = - stdlib_verification_queue.size() == 1 && (stdlib_verification_queue.front().type == QUEUE_TYPE::PG_FINAL); + stdlib_verification_queue.size() == 1 && (stdlib_verification_queue.front().type == QUEUE_TYPE::HN_FINAL); // The ECC-op subtable for a kernel begins with an eq-and-reset to ensure that the preceeding circuit's subtable // cannot affect the ECC-op accumulator for the kernel. For the tail kernel, we additionally add a preceeding no-op @@ -256,7 +256,7 @@ void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) } circuit.queue_ecc_eq(); - // Perform Oink/PG and Merge recursive verification + databus consistency checks for each entry in the queue + // Perform Oink/HN and Merge recursive verification + databus consistency checks for each entry in the queue std::vector points_accumulator; std::optional current_stdlib_verifier_accumulator; if (!is_init_kernel) { @@ -288,7 +288,7 @@ void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) if (is_hiding_kernel) { BB_ASSERT_EQ(current_stdlib_verifier_accumulator.has_value(), false); // Add randomness at the end of the hiding kernel (whose ecc ops fall right at the end of the op queue table) to - // ensure the CIVC proof doesn't leak information about the actual content of the op queue + // ensure the Chonk proof doesn't leak information about the actual content of the op queue hide_op_queue_content_in_hiding(circuit); HidingKernelIO hiding_output{ pairing_points_aggregator, @@ -306,9 +306,9 @@ void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) kernel_output.app_return_data = bus_depot.get_app_return_data_commitment(circuit); kernel_output.ecc_op_tables = T_prev_commitments; RecursiveTranscript hash_transcript; - kernel_output.output_pg_accum_hash = + kernel_output.output_hn_accum_hash = current_stdlib_verifier_accumulator->hash_through_transcript("", hash_transcript); - info("Kernel output accumulator hash: ", kernel_output.output_pg_accum_hash); + info("Kernel output accumulator hash: ", kernel_output.output_hn_accum_hash); kernel_output.set_public(); } } @@ -316,7 +316,7 @@ void SumcheckChonk::complete_kernel_circuit_logic(ClientCircuit& circuit) /** * @brief Get queue type for the proof of a circuit about to be accumulated based on num circuits accumulated so far. */ -SumcheckChonk::QUEUE_TYPE SumcheckChonk::get_queue_type() const +Chonk::QUEUE_TYPE Chonk::get_queue_type() const { // first app if (num_circuits_accumulated == 0) { @@ -324,15 +324,15 @@ SumcheckChonk::QUEUE_TYPE SumcheckChonk::get_queue_type() const } // app (excluding first) or kernel (inner or reset) if ((num_circuits_accumulated > 0 && num_circuits_accumulated < num_circuits - 3)) { - return QUEUE_TYPE::PG; + return QUEUE_TYPE::HN; } // last kernel prior to tail kernel if ((num_circuits_accumulated == num_circuits - 3)) { - return QUEUE_TYPE::PG_TAIL; + return QUEUE_TYPE::HN_TAIL; } // tail kernel if ((num_circuits_accumulated == num_circuits - 2)) { - return QUEUE_TYPE::PG_FINAL; + return QUEUE_TYPE::HN_FINAL; } // hiding kernel if ((num_circuits_accumulated == num_circuits - 1)) { @@ -344,19 +344,19 @@ SumcheckChonk::QUEUE_TYPE SumcheckChonk::get_queue_type() const /** * @brief Execute prover work for accumulation * @details Construct an prover instance for the provided circuit. If this is the first step in the IVC, simply - * initialize the folding accumulator. Otherwise, execute the PG prover to fold the prover instance into the accumulator + * initialize the folding accumulator. Otherwise, execute the HN prover to fold the prover instance into the accumulator * and produce a folding proof. Also execute the merge protocol to produce a merge proof. * * @param circuit * this case, just produce a Honk proof for that circuit and do no folding. * @param precomputed_vk */ -void SumcheckChonk::accumulate(ClientCircuit& circuit, const std::shared_ptr& precomputed_vk) +void Chonk::accumulate(ClientCircuit& circuit, const std::shared_ptr& precomputed_vk) { BB_ASSERT_LT( - num_circuits_accumulated, num_circuits, "SumcheckChonk: Attempting to accumulate more circuits than expected."); + num_circuits_accumulated, num_circuits, "Chonk: Attempting to accumulate more circuits than expected."); - BB_ASSERT(precomputed_vk != nullptr, "SumcheckChonk::accumulate - VK expected for the provided circuit"); + BB_ASSERT(precomputed_vk != nullptr, "Chonk::accumulate - VK expected for the provided circuit"); // Construct the prover instance for circuit std::shared_ptr prover_instance = std::make_shared(circuit); @@ -399,12 +399,12 @@ void SumcheckChonk::accumulate(ClientCircuit& circuit, const std::shared_ptr& verification_key) +HonkProof Chonk::construct_honk_proof_for_hiding_kernel(ClientCircuit& circuit, + const std::shared_ptr& verification_key) { auto hiding_prover_inst = std::make_shared(circuit, bn254_commitment_key); @@ -543,7 +543,7 @@ HonkProof SumcheckChonk::construct_honk_proof_for_hiding_kernel( * * @return Proof */ -SumcheckChonk::Proof SumcheckChonk::prove() +Chonk::Proof Chonk::prove() { // deallocate the accumulator prover_accumulator = ProverAccumulator(); @@ -560,7 +560,7 @@ SumcheckChonk::Proof SumcheckChonk::prove() return { mega_proof, goblin.prove(MergeSettings::APPEND) }; }; -bool SumcheckChonk::verify(const Proof& proof, const VerificationKey& vk) +bool Chonk::verify(const Proof& proof, const VerificationKey& vk) { using TableCommitments = Goblin::TableCommitments; // Create a transcript to be shared by MegaZK-, Merge-, ECCVM-, and Translator- Verifiers. @@ -586,12 +586,12 @@ bool SumcheckChonk::verify(const Proof& proof, const VerificationKey& vk) } // Proof methods -size_t SumcheckChonk::Proof::size() const +size_t Chonk::Proof::size() const { return mega_proof.size() + goblin_proof.size(); } -std::vector SumcheckChonk::Proof::to_field_elements() const +std::vector Chonk::Proof::to_field_elements() const { HonkProof proof; @@ -604,12 +604,12 @@ std::vector SumcheckChonk::Proof::to_field_elements() const return proof; }; -SumcheckChonk::Proof SumcheckChonk::Proof::from_field_elements(const std::vector& fields) +Chonk::Proof Chonk::Proof::from_field_elements(const std::vector& fields) { HonkProof mega_proof; GoblinProof goblin_proof; - size_t custom_public_inputs_size = fields.size() - SumcheckChonk::Proof::PROOF_LENGTH(); + size_t custom_public_inputs_size = fields.size() - Chonk::Proof::PROOF_LENGTH(); // Mega proof auto start_idx = fields.begin(); @@ -641,14 +641,14 @@ SumcheckChonk::Proof SumcheckChonk::Proof::from_field_elements(const std::vector return { mega_proof, goblin_proof }; }; -msgpack::sbuffer SumcheckChonk::Proof::to_msgpack_buffer() const +msgpack::sbuffer Chonk::Proof::to_msgpack_buffer() const { msgpack::sbuffer buffer; msgpack::pack(buffer, *this); return buffer; } -uint8_t* SumcheckChonk::Proof::to_msgpack_heap_buffer() const +uint8_t* Chonk::Proof::to_msgpack_heap_buffer() const { msgpack::sbuffer buffer = to_msgpack_buffer(); @@ -656,7 +656,7 @@ uint8_t* SumcheckChonk::Proof::to_msgpack_heap_buffer() const return to_heap_buffer(buf); } -SumcheckChonk::Proof SumcheckChonk::Proof::from_msgpack_buffer(uint8_t const*& buffer) +Chonk::Proof Chonk::Proof::from_msgpack_buffer(uint8_t const*& buffer) { auto uint8_buffer = from_buffer>(buffer); @@ -666,7 +666,7 @@ SumcheckChonk::Proof SumcheckChonk::Proof::from_msgpack_buffer(uint8_t const*& b return from_msgpack_buffer(sbuf); } -SumcheckChonk::Proof SumcheckChonk::Proof::from_msgpack_buffer(const msgpack::sbuffer& buffer) +Chonk::Proof Chonk::Proof::from_msgpack_buffer(const msgpack::sbuffer& buffer) { msgpack::object_handle oh = msgpack::unpack(buffer.data(), buffer.size()); msgpack::object obj = oh.get(); @@ -675,7 +675,7 @@ SumcheckChonk::Proof SumcheckChonk::Proof::from_msgpack_buffer(const msgpack::sb return proof; } -void SumcheckChonk::Proof::to_file_msgpack(const std::string& filename) const +void Chonk::Proof::to_file_msgpack(const std::string& filename) const { msgpack::sbuffer buffer = to_msgpack_buffer(); std::ofstream ofs(filename, std::ios::binary); @@ -686,7 +686,7 @@ void SumcheckChonk::Proof::to_file_msgpack(const std::string& filename) const ofs.close(); } -SumcheckChonk::Proof SumcheckChonk::Proof::from_file_msgpack(const std::string& filename) +Chonk::Proof Chonk::Proof::from_file_msgpack(const std::string& filename) { std::ifstream ifs(filename, std::ios::binary); if (!ifs.is_open()) { @@ -707,7 +707,7 @@ SumcheckChonk::Proof SumcheckChonk::Proof::from_file_msgpack(const std::string& } // VerificationKey construction -SumcheckChonk::VerificationKey SumcheckChonk::get_vk() const +Chonk::VerificationKey Chonk::get_vk() const { BB_ASSERT_EQ(verification_queue.size(), 1UL); BB_ASSERT_EQ(verification_queue.front().type == QUEUE_TYPE::MEGA, true); @@ -718,8 +718,8 @@ SumcheckChonk::VerificationKey SumcheckChonk::get_vk() const } #ifndef NDEBUG -void SumcheckChonk::update_native_verifier_accumulator(const VerifierInputs& queue_entry, - const std::shared_ptr& verifier_transcript) +void Chonk::update_native_verifier_accumulator(const VerifierInputs& queue_entry, + const std::shared_ptr& verifier_transcript) { auto verifier_inst = std::make_shared(queue_entry.honk_vk); @@ -728,7 +728,7 @@ void SumcheckChonk::update_native_verifier_accumulator(const VerifierInputs& que auto [_, new_accumulator] = native_verifier.instance_to_accumulator(verifier_inst, queue_entry.proof); native_verifier_accum = std::move(new_accumulator); } else { - auto [_first_sumcheck_verified, _second_sumcheck_verified, new_accumulator] = + auto [_first_verified, _second_verified, new_accumulator] = native_verifier.verify_folding_proof(verifier_inst, queue_entry.proof); native_verifier_accum = std::move(new_accumulator); } diff --git a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.hpp b/barretenberg/cpp/src/barretenberg/chonk/chonk.hpp similarity index 92% rename from barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.hpp rename to barretenberg/cpp/src/barretenberg/chonk/chonk.hpp index 0d92a0f6934b..777743f9f1bf 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/chonk.hpp @@ -24,7 +24,7 @@ namespace bb { /** - * @brief The IVC scheme used by the aztec chonk for private function execution + * @brief The IVC scheme used by the aztec client for private function execution * @details Combines HyperNova with Goblin to accumulate one circuit at a time with efficient EC group * operations. It is assumed that the circuits being accumulated correspond alternatingly to an app and a kernel, as is * the case in Aztec. Two recursive folding verifiers are appended to each kernel (except the first one) to verify the @@ -32,7 +32,7 @@ namespace bb { * of circuits being accumulated is even. * */ -class SumcheckChonk : public IVCBase { +class Chonk : public IVCBase { // CHONK: "Client Honk" - An UltraHonk variant with incremental folding and delayed non-native arithmetic. public: @@ -90,7 +90,7 @@ class SumcheckChonk : public IVCBase { GoblinProof goblin_proof; /** - * @brief The size of a LegacyChonk proof without backend-added public inputs + * @brief The size of a Chonk proof without backend-added public inputs * * @param virtual_log_n * @return constexpr size_t @@ -105,7 +105,7 @@ class SumcheckChonk : public IVCBase { } /** - * @brief The size of a LegacyChonk proof with backend-added public inputs: HidingKernelIO + * @brief The size of a Chonk proof with backend-added public inputs: HidingKernelIO * * @param virtual_log_n * @return constexpr size_t @@ -125,7 +125,7 @@ class SumcheckChonk : public IVCBase { */ std::vector to_field_elements() const; - static Proof from_field_elements(const std::vector& fields); + static Proof from_field_elements(const std::vector& fields); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1299): The following msgpack methods are generic // and should leverage some kind of shared msgpack utility. @@ -221,15 +221,15 @@ class SumcheckChonk : public IVCBase { // Specifies proof type or equivalently the type of recursive verification to be performed on a given proof enum class QUEUE_TYPE : uint8_t { OINK, - PG, - PG_FINAL, // the final PG verification, used in hiding kernel - PG_TAIL, // used in tail to indicate special handling of merge for ZK + HN, + HN_FINAL, // the final HN verification, used in hiding kernel + HN_TAIL, // used in tail to indicate special handling of merge for ZK MEGA }; // An entry in the native verification queue struct VerifierInputs { - std::vector proof; // oink or PG + std::vector proof; // oink or HN std::shared_ptr honk_vk; QUEUE_TYPE type; bool is_kernel = false; @@ -238,7 +238,7 @@ class SumcheckChonk : public IVCBase { // An entry in the stdlib verification queue struct StdlibVerifierInputs { - StdlibProof proof; // oink or PG + StdlibProof proof; // oink or HN std::shared_ptr honk_vk_and_hash; QUEUE_TYPE type; bool is_kernel = false; @@ -256,14 +256,14 @@ class SumcheckChonk : public IVCBase { public: size_t num_circuits_accumulated = 0; // number of circuits accumulated so far - ProverAccumulator prover_accumulator; // current PG prover accumulator instance + ProverAccumulator prover_accumulator; // current HN prover accumulator instance HonkProof decider_proof; // decider proof to be verified in the hiding circuit VerifierAccumulator recursive_verifier_native_accum; // native verifier accumulator used in recursive folding VerifierAccumulator native_verifier_accum; // native verifier accumulator used in prover folding - // Set of tuples {proof, verification_key, type (Oink/PG)} to be recursively verified + // Set of tuples {proof, verification_key, type (Oink/HN)} to be recursively verified VerificationQueue verification_queue; // Set of tuples {stdlib_proof, stdlib_verification_key, type} corresponding to the native verification queue StdlibVerificationQueue stdlib_verification_queue; @@ -281,7 +281,7 @@ class SumcheckChonk : public IVCBase { Goblin& get_goblin() override { return goblin; } const Goblin& get_goblin() const override { return goblin; } - SumcheckChonk(size_t num_circuits); + Chonk(size_t num_circuits); void instantiate_stdlib_verification_queue(ClientCircuit& circuit, const std::vector>& input_keys = {}); @@ -295,11 +295,11 @@ class SumcheckChonk : public IVCBase { const TableCommitments& T_prev_commitments, const std::shared_ptr& accumulation_recursive_transcript); - // Complete the logic of a kernel circuit (e.g. PG/merge recursive verification, databus consistency checks) + // Complete the logic of a kernel circuit (e.g. HN/merge recursive verification, databus consistency checks) void complete_kernel_circuit_logic(ClientCircuit& circuit); /** - * @brief Perform prover work for accumulation (e.g. PG folding, merge proving) + * @brief Perform prover work for accumulation (e.g. HN folding, merge proving) * * @param circuit The incoming statement * @param precomputed_vk The verification key of the incoming statement OR a mocked key whose metadata needs to be @@ -336,12 +336,12 @@ class SumcheckChonk : public IVCBase { QUEUE_TYPE get_queue_type() const; }; -// Serialization methods for LegacyChonk::VerificationKey -inline void read(uint8_t const*& it, SumcheckChonk::VerificationKey& vk) +// Serialization methods for Chonk::VerificationKey +inline void read(uint8_t const*& it, Chonk::VerificationKey& vk) { using serialize::read; - size_t num_frs = SumcheckChonk::VerificationKey::calc_num_data_types(); + size_t num_frs = Chonk::VerificationKey::calc_num_data_types(); // Read exactly num_frs field elements from the buffer std::vector field_elements(num_frs); @@ -353,7 +353,7 @@ inline void read(uint8_t const*& it, SumcheckChonk::VerificationKey& vk) vk.from_field_elements(field_elements); } -inline void write(std::vector& buf, SumcheckChonk::VerificationKey const& vk) +inline void write(std::vector& buf, Chonk::VerificationKey const& vk) { using serialize::write; diff --git a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.test.cpp b/barretenberg/cpp/src/barretenberg/chonk/chonk.test.cpp similarity index 75% rename from barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.test.cpp rename to barretenberg/cpp/src/barretenberg/chonk/chonk.test.cpp index bfa18f4750ac..9f9e109daf04 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_chonk.test.cpp +++ b/barretenberg/cpp/src/barretenberg/chonk/chonk.test.cpp @@ -1,6 +1,6 @@ -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" -#include "barretenberg/chonk/sumcheck_test_bench_shared.hpp" +#include "barretenberg/chonk/chonk.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" +#include "barretenberg/chonk/test_bench_shared.hpp" #include "barretenberg/common/assert.hpp" #include "barretenberg/common/mem.hpp" #include "barretenberg/common/test.hpp" @@ -18,18 +18,18 @@ static constexpr size_t SMALL_LOG_2_NUM_GATES = 5; // TODO(https://github.com/AztecProtocol/barretenberg/issues/1511): The Chonk class should enforce the minimum number of // circuits in a test flow. -class SumcheckChonkTests : public ::testing::Test { +class ChonkTests : public ::testing::Test { protected: static void SetUpTestSuite() { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); } - using Flavor = SumcheckChonk::Flavor; + using Flavor = Chonk::Flavor; using FF = typename Flavor::FF; using Commitment = Flavor::Commitment; using VerificationKey = Flavor::VerificationKey; - using Builder = SumcheckChonk::ClientCircuit; - using ProverInstance = SumcheckChonk::ProverInstance; - using VerifierInstance = SumcheckChonk::VerifierInstance; - using DeciderProver = SumcheckChonk::DeciderProver; + using Builder = Chonk::ClientCircuit; + using ProverInstance = Chonk::ProverInstance; + using VerifierInstance = Chonk::VerifierInstance; + using DeciderProver = Chonk::DeciderProver; using CircuitProducer = PrivateFunctionExecutionMockCircuitProducer; public: @@ -51,12 +51,13 @@ class SumcheckChonkTests : public ::testing::Test { } } - static std::pair accumulate_and_prove_ivc( - size_t num_app_circuits, TestSettings settings = {}, bool check_circuit_sizes = false) + static std::pair accumulate_and_prove_ivc(size_t num_app_circuits, + TestSettings settings = {}, + bool check_circuit_sizes = false) { CircuitProducer circuit_producer(num_app_circuits); const size_t num_circuits = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ num_circuits }; + Chonk ivc{ num_circuits }; for (size_t j = 0; j < num_circuits; ++j) { circuit_producer.construct_and_accumulate_next_circuit(ivc, settings, check_circuit_sizes); @@ -72,21 +73,21 @@ class SumcheckChonkTests : public ::testing::Test { * - No settings: first app is 2^19, all other apps are 2^17, all the kernels are 2^18 * - Settings: apps are 2^(log2_num_gates + 2), all kernels are smaller than 2^19 */ -TEST_F(SumcheckChonkTests, TestCircuitSizes) +TEST_F(ChonkTests, TestCircuitSizes) { const size_t NUM_APP_CIRCUITS = 2; // Check circuit sizes when no settings are passed { auto [proof, vk] = accumulate_and_prove_ivc(NUM_APP_CIRCUITS, {}, true); - EXPECT_TRUE(SumcheckChonk::verify(proof, vk)); + EXPECT_TRUE(Chonk::verify(proof, vk)); } // Check circuit sizes when no settings are passed { auto [proof, vk] = accumulate_and_prove_ivc(NUM_APP_CIRCUITS, { .log2_num_gates = SMALL_LOG_2_NUM_GATES }, true); - EXPECT_TRUE(SumcheckChonk::verify(proof, vk)); + EXPECT_TRUE(Chonk::verify(proof, vk)); } }; @@ -96,12 +97,12 @@ TEST_F(SumcheckChonkTests, TestCircuitSizes) * @note The circuits are of varying size: first circuit is 2^19, kernels are 2^18, apps are 2^17. * */ -TEST_F(SumcheckChonkTests, Basic) +TEST_F(ChonkTests, Basic) { const size_t NUM_APP_CIRCUITS = 2; auto [proof, vk] = accumulate_and_prove_ivc(NUM_APP_CIRCUITS); - EXPECT_TRUE(SumcheckChonk::verify(proof, vk)); + EXPECT_TRUE(Chonk::verify(proof, vk)); }; /** @@ -111,9 +112,9 @@ TEST_F(SumcheckChonkTests, Basic) * fail. * */ -TEST_F(SumcheckChonkTests, BadProofFailure) +TEST_F(ChonkTests, BadProofFailure) { - BB_DISABLE_ASSERTS(); // Disable assert in PG prover + BB_DISABLE_ASSERTS(); // Disable assert in HN prover const size_t NUM_APP_CIRCUITS = 2; // Confirm that the IVC verifies if nothing is tampered with @@ -121,7 +122,7 @@ TEST_F(SumcheckChonkTests, BadProofFailure) CircuitProducer circuit_producer(NUM_APP_CIRCUITS); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; TestSettings settings{ .log2_num_gates = SMALL_LOG_2_NUM_GATES }; // Construct and accumulate a set of mocked private function execution circuits @@ -129,14 +130,14 @@ TEST_F(SumcheckChonkTests, BadProofFailure) circuit_producer.construct_and_accumulate_next_circuit(ivc, settings); } auto proof = ivc.prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc.get_vk())); + EXPECT_TRUE(Chonk::verify(proof, ivc.get_vk())); } // The IVC throws an exception if the FIRST fold proof is tampered with { CircuitProducer circuit_producer(NUM_APP_CIRCUITS); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; size_t num_public_inputs = 0; @@ -157,14 +158,14 @@ TEST_F(SumcheckChonkTests, BadProofFailure) } } auto proof = ivc.prove(); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc.get_vk())); + EXPECT_FALSE(Chonk::verify(proof, ivc.get_vk())); } // The IVC fails if the SECOND fold proof is tampered with { CircuitProducer circuit_producer(NUM_APP_CIRCUITS); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; // Construct and accumulate a set of mocked private function execution circuits for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { @@ -179,14 +180,14 @@ TEST_F(SumcheckChonkTests, BadProofFailure) } } auto proof = ivc.prove(); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc.get_vk())); + EXPECT_FALSE(Chonk::verify(proof, ivc.get_vk())); } // The IVC fails if the calldata of the Hiding Kernel is different from the return data of the Tail Kernels { CircuitProducer circuit_producer(NUM_APP_CIRCUITS); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; // Construct and accumulate a set of mocked private function execution circuits for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { @@ -198,7 +199,7 @@ TEST_F(SumcheckChonkTests, BadProofFailure) // The public input after the PairingPoints is the commitment to the return data of the Tail kernel. tamper_with_proof(proof.mega_proof, PAIRING_POINTS_SIZE); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc.get_vk())); + EXPECT_FALSE(Chonk::verify(proof, ivc.get_vk())); } EXPECT_TRUE(true); @@ -209,53 +210,53 @@ TEST_F(SumcheckChonkTests, BadProofFailure) * leads to a verification failure. * */ -TEST_F(SumcheckChonkTests, WrongProofComponentFailure) +TEST_F(ChonkTests, WrongProofComponentFailure) { // Produce two valid proofs auto [chonk_proof_1, chonk_vk_1] = accumulate_and_prove_ivc(/*num_app_circuits=*/1); { - EXPECT_TRUE(SumcheckChonk::verify(chonk_proof_1, chonk_vk_1)); + EXPECT_TRUE(Chonk::verify(chonk_proof_1, chonk_vk_1)); } auto [chonk_proof_2, chonk_vk_2] = accumulate_and_prove_ivc(/*num_app_circuits=*/1); { - EXPECT_TRUE(SumcheckChonk::verify(chonk_proof_2, chonk_vk_2)); + EXPECT_TRUE(Chonk::verify(chonk_proof_2, chonk_vk_2)); } { // Replace Merge proof - SumcheckChonk::Proof tampered_proof = chonk_proof_1; + Chonk::Proof tampered_proof = chonk_proof_1; tampered_proof.goblin_proof.merge_proof = chonk_proof_2.goblin_proof.merge_proof; - EXPECT_THROW_OR_ABORT(SumcheckChonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); + EXPECT_THROW_OR_ABORT(Chonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); } { // Replace hiding circuit proof - SumcheckChonk::Proof tampered_proof = chonk_proof_1; + Chonk::Proof tampered_proof = chonk_proof_1; tampered_proof.mega_proof = chonk_proof_2.mega_proof; - EXPECT_THROW_OR_ABORT(SumcheckChonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); + EXPECT_THROW_OR_ABORT(Chonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); } { // Replace ECCVM proof - SumcheckChonk::Proof tampered_proof = chonk_proof_1; + Chonk::Proof tampered_proof = chonk_proof_1; tampered_proof.goblin_proof.eccvm_proof = chonk_proof_2.goblin_proof.eccvm_proof; - EXPECT_THROW_OR_ABORT(SumcheckChonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); + EXPECT_THROW_OR_ABORT(Chonk::verify(tampered_proof, chonk_vk_1), ".*IPA verification fails.*"); } { // Replace Translator proof - SumcheckChonk::Proof tampered_proof = chonk_proof_1; + Chonk::Proof tampered_proof = chonk_proof_1; tampered_proof.goblin_proof.translator_proof = chonk_proof_2.goblin_proof.translator_proof; - EXPECT_FALSE(SumcheckChonk::verify(tampered_proof, chonk_vk_1)); + EXPECT_FALSE(Chonk::verify(tampered_proof, chonk_vk_1)); } }; @@ -263,20 +264,20 @@ TEST_F(SumcheckChonkTests, WrongProofComponentFailure) * @brief Ensure that the Chonk VK is independent of the number of circuits accumulated * */ -TEST_F(SumcheckChonkTests, VKIndependenceFromNumberOfCircuits) +TEST_F(ChonkTests, VKIndependenceFromNumberOfCircuits) { const TestSettings settings{ .log2_num_gates = SMALL_LOG_2_NUM_GATES }; auto [unused_1, chonk_vk_1] = accumulate_and_prove_ivc(/*num_app_circuits=*/1, settings); auto [unused_2, chonk_vk_2] = accumulate_and_prove_ivc(/*num_app_circuits=*/3, settings); - // Check the equality of the Mega components of the SumcheckChonk VKeys. + // Check the equality of the Mega components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.mega.get(), *chonk_vk_2.mega.get()); - // Check the equality of the ECCVM components of the SumcheckChonk VKeys. + // Check the equality of the ECCVM components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.eccvm.get(), *chonk_vk_2.eccvm.get()); - // Check the equality of the Translator components of the SumcheckChonk VKeys. + // Check the equality of the Translator components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.translator.get(), *chonk_vk_2.translator.get()); }; @@ -284,7 +285,7 @@ TEST_F(SumcheckChonkTests, VKIndependenceFromNumberOfCircuits) * @brief Ensure that the Chonk VK is independent of the sizes of the circuits being accumulated * */ -TEST_F(SumcheckChonkTests, VKIndependenceFromCircuitSize) +TEST_F(ChonkTests, VKIndependenceFromCircuitSize) { // Run IVC for two sets of circuits const size_t NUM_APP_CIRCUITS = 1; @@ -297,13 +298,13 @@ TEST_F(SumcheckChonkTests, VKIndependenceFromCircuitSize) auto [unused_1, chonk_vk_1] = accumulate_and_prove_ivc(NUM_APP_CIRCUITS, settings_1); auto [unused_2, chonk_vk_2] = accumulate_and_prove_ivc(NUM_APP_CIRCUITS, settings_2); - // Check the equality of the Mega components of the SumcheckChonk VKeys. + // Check the equality of the Mega components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.mega.get(), *chonk_vk_2.mega.get()); - // Check the equality of the ECCVM components of the SumcheckChonk VKeys. + // Check the equality of the ECCVM components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.eccvm.get(), *chonk_vk_2.eccvm.get()); - // Check the equality of the Translator components of the SumcheckChonk VKeys. + // Check the equality of the Translator components of the Chonk VKeys. EXPECT_EQ(*chonk_vk_1.translator.get(), *chonk_vk_2.translator.get()); }; @@ -311,14 +312,14 @@ TEST_F(SumcheckChonkTests, VKIndependenceFromCircuitSize) * @brief Test to establish the "max" number of apps that can be accumulated due to limitations on the ECCVM size * */ -HEAVY_TEST(SumcheckChonkKernelCapacity, MaxCapacityPassing) +HEAVY_TEST(ChonkKernelCapacity, MaxCapacityPassing) { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); const size_t NUM_APP_CIRCUITS = 27; - auto [proof, vk] = SumcheckChonkTests::accumulate_and_prove_ivc(NUM_APP_CIRCUITS); + auto [proof, vk] = ChonkTests::accumulate_and_prove_ivc(NUM_APP_CIRCUITS); - bool verified = SumcheckChonk::verify(proof, vk); + bool verified = Chonk::verify(proof, vk); EXPECT_TRUE(verified); }; @@ -326,7 +327,7 @@ HEAVY_TEST(SumcheckChonkKernelCapacity, MaxCapacityPassing) * @brief Test methods for serializing and deserializing a proof to/from a file/buffer in msgpack format * */ -TEST_F(SumcheckChonkTests, MsgpackProofFromFileOrBuffer) +TEST_F(ChonkTests, MsgpackProofFromFileOrBuffer) { // Generate an arbitrary valid CICV proof TestSettings settings{ .log2_num_gates = SMALL_LOG_2_NUM_GATES }; @@ -335,31 +336,31 @@ TEST_F(SumcheckChonkTests, MsgpackProofFromFileOrBuffer) { // Serialize/deserialize the proof to/from a file, check that it verifies const std::string filename = "proof.msgpack"; proof.to_file_msgpack(filename); - auto proof_deserialized = SumcheckChonk::Proof::from_file_msgpack(filename); + auto proof_deserialized = Chonk::Proof::from_file_msgpack(filename); - EXPECT_TRUE(SumcheckChonk::verify(proof_deserialized, vk)); + EXPECT_TRUE(Chonk::verify(proof_deserialized, vk)); } { // Serialize/deserialize proof to/from a heap buffer, check that it verifies uint8_t* buffer = proof.to_msgpack_heap_buffer(); auto uint8_buffer = from_buffer>(buffer); uint8_t const* uint8_ptr = uint8_buffer.data(); - auto proof_deserialized = SumcheckChonk::Proof::from_msgpack_buffer(uint8_ptr); + auto proof_deserialized = Chonk::Proof::from_msgpack_buffer(uint8_ptr); - EXPECT_TRUE(SumcheckChonk::verify(proof_deserialized, vk)); + EXPECT_TRUE(Chonk::verify(proof_deserialized, vk)); } { // Check that attempting to deserialize a proof from a buffer with random bytes fails gracefully msgpack::sbuffer buffer = proof.to_msgpack_buffer(); - auto proof_deserialized = SumcheckChonk::Proof::from_msgpack_buffer(buffer); - EXPECT_TRUE(SumcheckChonk::verify(proof_deserialized, vk)); + auto proof_deserialized = Chonk::Proof::from_msgpack_buffer(buffer); + EXPECT_TRUE(Chonk::verify(proof_deserialized, vk)); std::vector random_bytes(buffer.size()); std::generate(random_bytes.begin(), random_bytes.end(), []() { return static_cast(rand() % 256); }); std::copy(random_bytes.begin(), random_bytes.end(), buffer.data()); // Expect deserialization to fail with error msgpack::v1::type_error with description "std::bad_cast" - EXPECT_THROW(SumcheckChonk::Proof::from_msgpack_buffer(buffer), msgpack::v1::type_error); + EXPECT_THROW(Chonk::Proof::from_msgpack_buffer(buffer), msgpack::v1::type_error); } }; @@ -372,13 +373,13 @@ TEST_F(SumcheckChonkTests, MsgpackProofFromFileOrBuffer) * causes failure of the IVC to verify. * */ -TEST_F(SumcheckChonkTests, DatabusFailure) +TEST_F(ChonkTests, DatabusFailure) { - BB_DISABLE_ASSERTS(); // Disable assert in PG prover + BB_DISABLE_ASSERTS(); // Disable assert in HN prover PrivateFunctionExecutionMockCircuitProducer circuit_producer{ /*num_app_circuits=*/1 }; const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; // Construct and accumulate a series of mocked private function execution circuits for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { @@ -393,5 +394,5 @@ TEST_F(SumcheckChonkTests, DatabusFailure) } auto proof = ivc.prove(); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc.get_vk())); + EXPECT_FALSE(Chonk::verify(proof, ivc.get_vk())); }; diff --git a/barretenberg/cpp/src/barretenberg/chonk/chonk_base.hpp b/barretenberg/cpp/src/barretenberg/chonk/chonk_base.hpp index 736d269783a6..a219914c3bd0 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/chonk_base.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/chonk_base.hpp @@ -15,7 +15,7 @@ namespace bb { /** * @brief Base class interface for IVC schemes * - * Provides common interface for different IVC implementations SumcheckChonk allowing them to be + * Provides common interface for different IVC implementations Chonk allowing them to be * used polymorphically in the API. */ class IVCBase { diff --git a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_mock_circuit_producer.hpp b/barretenberg/cpp/src/barretenberg/chonk/mock_circuit_producer.hpp similarity index 93% rename from barretenberg/cpp/src/barretenberg/chonk/sumcheck_mock_circuit_producer.hpp rename to barretenberg/cpp/src/barretenberg/chonk/mock_circuit_producer.hpp index 397260950801..3f7ec4371b97 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_mock_circuit_producer.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/mock_circuit_producer.hpp @@ -6,7 +6,7 @@ #pragma once -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/bb_bench.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" @@ -24,7 +24,7 @@ namespace { */ class MockDatabusProducer { private: - using ClientCircuit = SumcheckChonk::ClientCircuit; + using ClientCircuit = Chonk::ClientCircuit; using Flavor = MegaFlavor; using FF = Flavor::FF; using BusDataArray = std::vector; @@ -110,7 +110,7 @@ struct TestSettings { * testing consecutive kernels. These can be configured via TestSettings. */ class PrivateFunctionExecutionMockCircuitProducer { - using ClientCircuit = SumcheckChonk::ClientCircuit; + using ClientCircuit = Chonk::ClientCircuit; using Flavor = MegaFlavor; using VerificationKey = Flavor::VerificationKey; @@ -149,8 +149,7 @@ class PrivateFunctionExecutionMockCircuitProducer { // Deepcopy the opqueue to avoid modifying the original one when finalising the circuit builder.op_queue = std::make_shared(*builder.op_queue); - std::shared_ptr prover_instance = - std::make_shared(builder); + std::shared_ptr prover_instance = std::make_shared(builder); std::shared_ptr vk = std::make_shared(prover_instance->get_precomputed()); return vk; } @@ -161,7 +160,7 @@ class PrivateFunctionExecutionMockCircuitProducer { * large. * */ - ClientCircuit create_next_circuit(SumcheckChonk& ivc, + ClientCircuit create_next_circuit(Chonk& ivc, size_t log2_num_gates = 0, size_t num_public_inputs = 0, bool check_circuit_sizes = false) @@ -195,7 +194,7 @@ class PrivateFunctionExecutionMockCircuitProducer { } if (check_circuit_sizes) { - auto prover_instance = std::make_shared(circuit); + auto prover_instance = std::make_shared(circuit); size_t log2_dyadic_size = numeric::get_msb(prover_instance->get_metadata().dyadic_size); if (log2_num_gates != 0) { if (is_kernel) { @@ -232,7 +231,7 @@ class PrivateFunctionExecutionMockCircuitProducer { * @brief Create the next circuit (app/kernel) in a mocked private function execution stack */ std::pair> create_next_circuit_and_vk( - SumcheckChonk& ivc, TestSettings settings = {}, bool check_circuit_size = false) + Chonk& ivc, TestSettings settings = {}, bool check_circuit_size = false) { // If this is a mock hiding kernel, remove the settings and use a default (non-structured) trace if (ivc.num_circuits_accumulated == ivc.get_num_circuits() - 1) { @@ -243,9 +242,7 @@ class PrivateFunctionExecutionMockCircuitProducer { return { circuit, get_verification_key(circuit) }; } - void construct_and_accumulate_next_circuit(SumcheckChonk& ivc, - TestSettings settings = {}, - bool check_circuit_sizes = false) + void construct_and_accumulate_next_circuit(Chonk& ivc, TestSettings settings = {}, bool check_circuit_sizes = false) { auto [circuit, vk] = create_next_circuit_and_vk(ivc, settings, check_circuit_sizes); ivc.accumulate(circuit, vk); diff --git a/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.cpp b/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.cpp index c3b6f575219b..d7a1d9a33749 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.cpp +++ b/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.cpp @@ -1,5 +1,5 @@ #include "private_execution_steps.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" #include @@ -133,15 +133,15 @@ void PrivateExecutionSteps::parse(std::vector&& steps) // For backwards compatibility, but it affects performance and correctness. precomputed_vks[i] = nullptr; } else { - precomputed_vks[i] = from_buffer>(step.vk); + precomputed_vks[i] = from_buffer>(step.vk); } function_names[i] = step.function_name; } } -std::shared_ptr PrivateExecutionSteps::accumulate() +std::shared_ptr PrivateExecutionSteps::accumulate() { - auto ivc = std::make_shared(/*num_circuits=*/folding_stack.size()); + auto ivc = std::make_shared(/*num_circuits=*/folding_stack.size()); const acir_format::ProgramMetadata metadata{ ivc }; @@ -156,7 +156,7 @@ std::shared_ptr PrivateExecutionSteps::accumulate() // Construct a bberg circuit from the acir representation then accumulate it into the IVC auto circuit = acir_format::create_circuit(program, metadata); - info("SumcheckChonk: accumulating " + function_name); + info("Chonk: accumulating " + function_name); // Do one step of ivc accumulator or, if there is only one circuit in the stack, prove that circuit. In this // case, no work is added to the Goblin opqueue, but VM proofs for trivials inputs are produced. ivc->accumulate(circuit, precomputed_vk); diff --git a/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.hpp b/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.hpp index d52b20638085..010b0f9ba3ed 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/private_execution_steps.hpp @@ -45,9 +45,9 @@ struct PrivateExecutionStepRaw { struct PrivateExecutionSteps { std::vector folding_stack; std::vector function_names; - std::vector> precomputed_vks; + std::vector> precomputed_vks; - std::shared_ptr accumulate(); + std::shared_ptr accumulate(); void parse(std::vector&& steps); }; } // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_test_bench_shared.hpp b/barretenberg/cpp/src/barretenberg/chonk/sumcheck_test_bench_shared.hpp deleted file mode 100644 index 18164f045d39..000000000000 --- a/barretenberg/cpp/src/barretenberg/chonk/sumcheck_test_bench_shared.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// === AUDIT STATUS === -// internal: { status: not started, auditors: [], date: YYYY-MM-DD } -// external_1: { status: not started, auditors: [], date: YYYY-MM-DD } -// external_2: { status: not started, auditors: [], date: YYYY-MM-DD } -// ===================== - -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" -#include "barretenberg/common/bb_bench.hpp" -#include "barretenberg/goblin/mock_circuits.hpp" -#include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" -#include "barretenberg/ultra_honk/ultra_verifier.hpp" - -namespace bb { - -/** - * @brief Perform a specified number of circuit accumulation rounds - * - * @param NUM_CIRCUITS Number of circuits to accumulate (apps + kernels) - */ -std::pair accumulate_and_prove_ivc_with_precomputed_vks( - size_t num_app_circuits, auto& precomputed_vks, const bool large_first_app = true) -{ - PrivateFunctionExecutionMockCircuitProducer circuit_producer(num_app_circuits, large_first_app); - const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; - - BB_ASSERT_EQ(precomputed_vks.size(), NUM_CIRCUITS, "There should be a precomputed VK for each circuit"); - - for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { - MegaCircuitBuilder circuit; - { - BB_BENCH_NAME("construct_circuits"); - circuit = circuit_producer.create_next_circuit(ivc); - } - - ivc.accumulate(circuit, precomputed_vks[circuit_idx]); - } - return { ivc.prove(), ivc.get_vk() }; -} - -std::vector> sumcheck_precompute_vks( - const size_t num_app_circuits, const bool large_first_app = true) -{ - using CircuitProducer = PrivateFunctionExecutionMockCircuitProducer; - CircuitProducer circuit_producer(num_app_circuits, large_first_app); - const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; - - std::vector> vkeys; - for (size_t j = 0; j < NUM_CIRCUITS; ++j) { - - auto circuit = circuit_producer.create_next_circuit(ivc); - auto vk = CircuitProducer::get_verification_key(circuit); - vkeys.push_back(vk); - ivc.accumulate(circuit, vk); - } - - return vkeys; -} - -} // namespace bb diff --git a/barretenberg/cpp/src/barretenberg/chonk/test_bench_shared.hpp b/barretenberg/cpp/src/barretenberg/chonk/test_bench_shared.hpp index 938473c052e4..c42aff0dfcbe 100644 --- a/barretenberg/cpp/src/barretenberg/chonk/test_bench_shared.hpp +++ b/barretenberg/cpp/src/barretenberg/chonk/test_bench_shared.hpp @@ -4,8 +4,8 @@ // external_2: { status: not started, auditors: [], date: YYYY-MM-DD } // ===================== -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" +#include "barretenberg/chonk/chonk.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/common/bb_bench.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/stdlib_circuit_builders/ultra_circuit_builder.hpp" @@ -18,12 +18,12 @@ namespace bb { * * @param NUM_CIRCUITS Number of circuits to accumulate (apps + kernels) */ -std::pair accumulate_and_prove_with_precomputed_vks( +std::pair accumulate_and_prove_with_precomputed_vks( size_t num_app_circuits, auto& precomputed_vks, const bool large_first_app = true) { PrivateFunctionExecutionMockCircuitProducer circuit_producer(num_app_circuits, large_first_app); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; BB_ASSERT_EQ(precomputed_vks.size(), NUM_CIRCUITS, "There should be a precomputed VK for each circuit"); @@ -45,7 +45,7 @@ std::vector> precompute_vk using CircuitProducer = PrivateFunctionExecutionMockCircuitProducer; CircuitProducer circuit_producer(num_app_circuits, large_first_app); const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; std::vector> vkeys; for (size_t j = 0; j < NUM_CIRCUITS; ++j) { diff --git a/barretenberg/cpp/src/barretenberg/constants.hpp b/barretenberg/cpp/src/barretenberg/constants.hpp index c73f38bfd526..1f652929bbcd 100644 --- a/barretenberg/cpp/src/barretenberg/constants.hpp +++ b/barretenberg/cpp/src/barretenberg/constants.hpp @@ -19,8 +19,8 @@ static constexpr uint32_t CONST_OP_QUEUE_LOG_SIZE = CONST_TRANSLATOR_MINI_CIRCUI // TODO(https://github.com/AztecProtocol/barretenberg/issues/1046): Remove the need for const sized proofs static constexpr uint32_t CONST_PROOF_SIZE_LOG_N = 28; -// The log of the max circuit size of circuits being folded. This size is assumed by the PG prover and verifier in order -// to ensure a constant PG proof size and a PG recursive verifier circuit that is independent of the size of the +// The log of the max circuit size of circuits being folded. This size is assumed by the HN prover and verifier in order +// to ensure a constant HN proof size and a HN recursive verifier circuit that is independent of the size of the // circuits being folded. static constexpr uint32_t CONST_PG_LOG_N = 21; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp index 81d03c02e8f7..d94455700009 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.cpp @@ -14,7 +14,7 @@ #include "barretenberg/dsl/acir_format/chonk_recursion_constraints.hpp" #include "barretenberg/dsl/acir_format/ecdsa_constraints.hpp" #include "barretenberg/dsl/acir_format/honk_recursion_constraint.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "barretenberg/dsl/acir_format/proof_surgeon.hpp" #include "barretenberg/flavor/flavor.hpp" #include "barretenberg/honk/prover_instance_inspector.hpp" @@ -270,12 +270,12 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta // RecursionConstraints bool has_honk_recursion_constraints = !constraint_system.honk_recursion_constraints.empty(); bool has_avm_recursion_constraints = !constraint_system.avm_recursion_constraints.empty(); - bool has_pg_recursion_constraints = !constraint_system.pg_recursion_constraints.empty(); + bool has_hn_recursion_constraints = !constraint_system.hn_recursion_constraints.empty(); bool has_chonk_recursion_constraints = !constraint_system.chonk_recursion_constraints.empty(); if constexpr (IsMegaBuilder) { // We shouldn't have both honk recursion constraints and pg recursion constraints. - BB_ASSERT_EQ(!has_honk_recursion_constraints || !has_pg_recursion_constraints, + BB_ASSERT_EQ(!has_honk_recursion_constraints || !has_hn_recursion_constraints, true, "Invalid circuit: both honk and ivc recursion constraints present."); @@ -292,7 +292,7 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta stdlib::recursion::honk::DefaultIO inputs; inputs.pairing_inputs = output.points_accumulator; inputs.set_public(); - } else if (has_pg_recursion_constraints) { + } else if (has_hn_recursion_constraints) { process_pg_recursion_constraints( builder, constraint_system, metadata.ivc, has_valid_witness_assignments, gate_counter); } else { @@ -310,7 +310,7 @@ void build_constraints(Builder& builder, AcirProgram& program, const ProgramMeta // - AVM recursion constraints // However, as mock protocol circuits use Chonk + AVM (mock Public Base Rollup), instead of throwing an assert // we return a vinfo for the case of Chonk + AVM - BB_ASSERT_EQ(has_pg_recursion_constraints, + BB_ASSERT_EQ(has_hn_recursion_constraints, false, "Invalid circuit: pg recursion constraints are present with UltraBuilder."); BB_ASSERT_EQ(!(has_chonk_recursion_constraints && has_honk_recursion_constraints), @@ -527,14 +527,14 @@ void process_pg_recursion_constraints(MegaCircuitBuilder& builder, bool has_valid_witness_assignments, GateCounter& gate_counter) { - using StdlibVerificationKey = SumcheckChonk::RecursiveVerificationKey; - using StdlibVKAndHash = SumcheckChonk::RecursiveVKAndHash; - using StdlibFF = SumcheckChonk::RecursiveFlavor::FF; + using StdlibVerificationKey = Chonk::RecursiveVerificationKey; + using StdlibVKAndHash = Chonk::RecursiveVKAndHash; + using StdlibFF = Chonk::RecursiveFlavor::FF; - // Lambda template to handle both SumcheckChonk and SumcheckChonk with the same code + // Lambda template to handle both Chonk and Chonk with the same code auto process_with_ivc = [&](const std::shared_ptr& ivc) { // We expect the length of the internal verification queue to match the number of ivc recursion constraints - BB_ASSERT_EQ(constraints.pg_recursion_constraints.size(), + BB_ASSERT_EQ(constraints.hn_recursion_constraints.size(), ivc->verification_queue.size(), "WARNING: Mismatch in number of recursive verifications during kernel creation!"); @@ -543,7 +543,7 @@ void process_pg_recursion_constraints(MegaCircuitBuilder& builder, if (!has_valid_witness_assignments) { // Create stdlib representations of each {proof, vkey} pair to be recursively verified for (auto [constraint, queue_entry] : - zip_view(constraints.pg_recursion_constraints, ivc->verification_queue)) { + zip_view(constraints.hn_recursion_constraints, ivc->verification_queue)) { populate_dummy_vk_in_constraint(builder, queue_entry.honk_vk, constraint.key); builder.set_variable(constraint.key_hash, queue_entry.honk_vk->hash()); } @@ -552,8 +552,8 @@ void process_pg_recursion_constraints(MegaCircuitBuilder& builder, // Construct a stdlib verification key for each constraint based on the verification key witness indices // therein std::vector> stdlib_vk_and_hashs; - stdlib_vk_and_hashs.reserve(constraints.pg_recursion_constraints.size()); - for (const auto& constraint : constraints.pg_recursion_constraints) { + stdlib_vk_and_hashs.reserve(constraints.hn_recursion_constraints.size()); + for (const auto& constraint : constraints.hn_recursion_constraints) { stdlib_vk_and_hashs.push_back(std::make_shared( std::make_shared( StdlibVerificationKey::from_witness_indices(builder, constraint.key)), @@ -567,7 +567,7 @@ void process_pg_recursion_constraints(MegaCircuitBuilder& builder, // acir are properly connected to the constraints generated herein via the ivc scheme (e.g. recursive // verifications). for (auto [constraint, queue_entry] : - zip_view(constraints.pg_recursion_constraints, ivc->stdlib_verification_queue)) { + zip_view(constraints.hn_recursion_constraints, ivc->stdlib_verification_queue)) { // Get the witness indices for the public inputs contained within the proof in the verification queue std::vector public_input_indices = @@ -587,17 +587,17 @@ void process_pg_recursion_constraints(MegaCircuitBuilder& builder, // Note: we can't easily track the gate contribution from each individual pg_recursion_constraint since they // are handled simultaneously in the above function call; instead we track the total contribution gate_counter.track_diff(constraints.gates_per_opcode, - constraints.original_opcode_indices.pg_recursion_constraints.at(0)); + constraints.original_opcode_indices.hn_recursion_constraints.at(0)); }; // If an ivc instance is not provided, we mock one with the state required to construct the recursion // constraints present in the program. This is for when we write_vk. if (ivc_base == nullptr) { - auto mock_ivc = create_mock_sumcheck_ivc_from_constraints(constraints.pg_recursion_constraints); + auto mock_ivc = create_mock_chonk_from_constraints(constraints.hn_recursion_constraints); process_with_ivc(mock_ivc); } else { - auto sumcheck_ivc = std::static_pointer_cast(ivc_base); + auto sumcheck_ivc = std::static_pointer_cast(ivc_base); process_with_ivc(sumcheck_ivc); } } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp index 7bf926a77363..e7d7dc48119c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format.hpp @@ -8,7 +8,7 @@ #include "aes128_constraint.hpp" #include "avm2_recursion_constraint.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/common/slab_allocator.hpp" #include "barretenberg/serialize/msgpack.hpp" #include "blake2s_constraint.hpp" @@ -51,7 +51,7 @@ struct AcirFormatOriginalOpcodeIndices { std::vector ec_add_constraints; std::vector honk_recursion_constraints; std::vector avm_recursion_constraints; - std::vector pg_recursion_constraints; + std::vector hn_recursion_constraints; std::vector chonk_recursion_constraints; std::vector assert_equalities; std::vector poly_triple_constraints; @@ -91,7 +91,7 @@ struct AcirFormat { std::vector ec_add_constraints; std::vector honk_recursion_constraints; std::vector avm_recursion_constraints; - std::vector pg_recursion_constraints; + std::vector hn_recursion_constraints; std::vector chonk_recursion_constraints; std::vector> assert_equalities; @@ -139,7 +139,7 @@ struct AcirFormat { ec_add_constraints, honk_recursion_constraints, avm_recursion_constraints, - pg_recursion_constraints, + hn_recursion_constraints, chonk_recursion_constraints, poly_triple_constraints, quad_constraints, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp index 8e915fbaed0b..0027702960e9 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_format_mocks.cpp @@ -23,7 +23,7 @@ acir_format::AcirFormatOriginalOpcodeIndices create_empty_original_opcode_indice .ec_add_constraints = {}, .honk_recursion_constraints = {}, .avm_recursion_constraints = {}, - .pg_recursion_constraints = {}, + .hn_recursion_constraints = {}, .chonk_recursion_constraints = {}, .assert_equalities = {}, .poly_triple_constraints = {}, @@ -77,8 +77,8 @@ void mock_opcode_indices(acir_format::AcirFormat& constraint_system) for (size_t i = 0; i < constraint_system.avm_recursion_constraints.size(); i++) { constraint_system.original_opcode_indices.avm_recursion_constraints.push_back(current_opcode++); } - for (size_t i = 0; i < constraint_system.pg_recursion_constraints.size(); i++) { - constraint_system.original_opcode_indices.pg_recursion_constraints.push_back(current_opcode++); + for (size_t i = 0; i < constraint_system.hn_recursion_constraints.size(); i++) { + constraint_system.original_opcode_indices.hn_recursion_constraints.push_back(current_opcode++); } for (size_t i = 0; i < constraint_system.chonk_recursion_constraints.size(); i++) { constraint_system.original_opcode_indices.chonk_recursion_constraints.push_back(current_opcode++); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp index 12aefe988271..b279f47e93c8 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp @@ -1,10 +1,10 @@ -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #ifndef __wasm__ #include "barretenberg/chonk/private_execution_steps.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/streams.hpp" #include "barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "barretenberg/honk/prover_instance_inspector.hpp" #include @@ -478,7 +478,7 @@ TEST_F(AcirIntegrationTest, DISABLED_HonkRecursion) } /** - * @brief Test LegacyChonk proof generation and verification given an ivc-inputs msgpack file + * @brief Test Chonk proof generation and verification given an ivc-inputs msgpack file * */ TEST_F(AcirIntegrationTest, DISABLED_ChonkMsgpackInputs) @@ -493,8 +493,8 @@ TEST_F(AcirIntegrationTest, DISABLED_ChonkMsgpackInputs) PrivateExecutionSteps steps; steps.parse(PrivateExecutionStepRaw::load_and_decompress(input_path)); - std::shared_ptr ivc = steps.accumulate(); - SumcheckChonk::Proof proof = ivc->prove(); + std::shared_ptr ivc = steps.accumulate(); + Chonk::Proof proof = ivc->prove(); EXPECT_TRUE(ivc->verify(proof, ivc->get_vk())); } @@ -521,10 +521,10 @@ TEST_F(AcirIntegrationTest, DISABLED_DummyWitnessVkConsistency) { auto program = program_in; program.witness = {}; // erase the witness to mimmic the "dummy witness" case - auto& ivc_constraints = program.constraints.pg_recursion_constraints; + auto& ivc_constraints = program.constraints.hn_recursion_constraints; const acir_format::ProgramMetadata metadata{ - .ivc = ivc_constraints.empty() ? nullptr - : acir_format::create_mock_sumcheck_ivc_from_constraints(ivc_constraints) + .ivc = + ivc_constraints.empty() ? nullptr : acir_format::create_mock_chonk_from_constraints(ivc_constraints) }; auto circuit = acir_format::create_circuit(program, metadata); @@ -534,10 +534,10 @@ TEST_F(AcirIntegrationTest, DISABLED_DummyWitnessVkConsistency) // Compute the verification key using the genuine witness { auto program = program_in; - auto& ivc_constraints = program.constraints.pg_recursion_constraints; + auto& ivc_constraints = program.constraints.hn_recursion_constraints; const acir_format::ProgramMetadata metadata{ - .ivc = ivc_constraints.empty() ? nullptr - : acir_format::create_mock_sumcheck_ivc_from_constraints(ivc_constraints) + .ivc = + ivc_constraints.empty() ? nullptr : acir_format::create_mock_chonk_from_constraints(ivc_constraints) }; auto circuit = acir_format::create_circuit(program, metadata); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp index b0304fbf1149..eb41d540005e 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp @@ -771,11 +771,11 @@ void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg, AcirFo af.original_opcode_indices.honk_recursion_constraints.push_back(opcode_index); break; case OINK: - case PG: - case PG_TAIL: - case PG_FINAL: - af.pg_recursion_constraints.push_back(c); - af.original_opcode_indices.pg_recursion_constraints.push_back(opcode_index); + case HN: + case HN_TAIL: + case HN_FINAL: + af.hn_recursion_constraints.push_back(c); + af.original_opcode_indices.hn_recursion_constraints.push_back(opcode_index); break; case AVM: af.avm_recursion_constraints.push_back(c); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/chonk_recursion_constraints.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/chonk_recursion_constraints.test.cpp index f0b92d92d56f..12dccc571d4b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/chonk_recursion_constraints.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/chonk_recursion_constraints.test.cpp @@ -1,4 +1,4 @@ -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" #include "barretenberg/dsl/acir_format/acir_format_mocks.hpp" #include "barretenberg/dsl/acir_format/proof_surgeon.hpp" @@ -14,22 +14,22 @@ class ChonkRecursionConstraintTest : public ::testing::Test { public: using Builder = UltraCircuitBuilder; - // Types for LegacyChonk recursive verifier + // Types for Chonk recursive verifier using Flavor = UltraRollupFlavor; using ProverInstance = ProverInstance_; using VerificationKey = Flavor::VerificationKey; using ChonkRecursiveVerifier = stdlib::recursion::honk::ChonkRecursiveVerifier; - // Types for LegacyChonk + // Types for Chonk using DeciderZKProvingKey = ProverInstance_; using MegaZKVerificationKey = MegaZKFlavor::VerificationKey; - // Public inputs added by bb to a LegacyChonk proof + // Public inputs added by bb to a Chonk proof static constexpr size_t PUBLIC_INPUTS_SIZE = bb::HidingKernelIO::PUBLIC_INPUTS_SIZE; struct ChonkData { std::shared_ptr mega_vk; - SumcheckChonk::Proof proof; + Chonk::Proof proof; }; static ChonkData get_chonk_data() @@ -38,13 +38,13 @@ class ChonkRecursionConstraintTest : public ::testing::Test { PrivateFunctionExecutionMockCircuitProducer circuit_producer(NUM_APP_CIRCUITS); const size_t num_circuits = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ num_circuits }; + Chonk ivc{ num_circuits }; for (size_t j = 0; j < num_circuits; ++j) { circuit_producer.construct_and_accumulate_next_circuit(ivc); } - SumcheckChonk::Proof proof = ivc.prove(); + Chonk::Proof proof = ivc.prove(); return { ivc.get_vk().mega, proof }; } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.cpp similarity index 66% rename from barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.cpp rename to barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.cpp index 9e994db8dafe..8e1ee94db645 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.cpp @@ -3,8 +3,7 @@ // external_1: { status: not started, auditors: [], date: YYYY-MM-DD } // external_2: { status: not started, auditors: [], date: YYYY-MM-DD } // ===================== - -#include "pg_recursion_constraint.hpp" +#include "hypernova_recursion_constraint.hpp" #include "barretenberg/common/assert.hpp" #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/dsl/acir_format/mock_verifier_inputs.hpp" @@ -27,58 +26,55 @@ using namespace bb; * @details Construction of a kernel circuit requires two inputs: kernel prgram acir constraints and an IVC instance * containing state needed to complete the kernel logic, e.g. proofs for input to recursive verifiers. To construct * verification keys for kernel circuits without running a full IVC, we mock the IVC state corresponding to a provided - * set of IVC recurson constraints. For example, if the constraints contain a single PG recursive verification, we + * set of IVC recurson constraints. For example, if the constraints contain a single HN recursive verification, we * initialize an IVC with mocked data for the verifier accumulator, the folding proof, the circuit verification key, * and a merge proof. * @note There are only three valid combinations of IVC recursion constraints for a kernel program. See below for * details. * * @param constraints IVC recursion constraints from a kernel circuit - * @return SumcheckChonk + * @return Chonk */ -std::shared_ptr create_mock_sumcheck_ivc_from_constraints( - const std::vector& constraints) +std::shared_ptr create_mock_chonk_from_constraints(const std::vector& constraints) { - auto ivc = std::make_shared(constraints.size()); + auto ivc = std::make_shared(constraints.size()); uint32_t oink_type = static_cast(PROOF_TYPE::OINK); - uint32_t pg_type = static_cast(PROOF_TYPE::PG); - uint32_t pg_final_type = static_cast(PROOF_TYPE::PG_FINAL); - uint32_t pg_tail_type = static_cast(PROOF_TYPE::PG_TAIL); + uint32_t hn_type = static_cast(PROOF_TYPE::HN); + uint32_t hn_final_type = static_cast(PROOF_TYPE::HN_FINAL); + uint32_t hn_tail_type = static_cast(PROOF_TYPE::HN_TAIL); // There is a fixed set of valid combinations of IVC recursion constraints for Aztec kernel circuits: // Case: INIT kernel; single Oink recursive verification of an app if (constraints.size() == 1 && constraints[0].proof_type == oink_type) { - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::OINK, /*is_kernel=*/false); + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::OINK, /*is_kernel=*/false); return ivc; } - // Case: RESET kernel; single PG recursive verification of a kernel - if (constraints.size() == 1 && constraints[0].proof_type == pg_type) { - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); + // Case: RESET kernel; single HN recursive verification of a kernel + if (constraints.size() == 1 && constraints[0].proof_type == hn_type) { + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/true); return ivc; } - // Case: TAIL kernel; single PG recursive verification of a kernel - if (constraints.size() == 1 && constraints[0].proof_type == pg_tail_type) { - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG_TAIL, /*is_kernel=*/true); + // Case: TAIL kernel; single HN recursive verification of a kernel + if (constraints.size() == 1 && constraints[0].proof_type == hn_tail_type) { + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN_TAIL, /*is_kernel=*/true); return ivc; } - - // Case: INNER kernel; two PG recursive verifications, kernel and app in that order if (constraints.size() == 2) { - BB_ASSERT_EQ(constraints[0].proof_type, pg_type); - BB_ASSERT_EQ(constraints[1].proof_type, pg_type); - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/false); + BB_ASSERT_EQ(constraints[0].proof_type, hn_type); + BB_ASSERT_EQ(constraints[1].proof_type, hn_type); + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/true); + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/false); return ivc; } - // Case: HIDING kernel; single PG_FINAL recursive verification of a kernel - if (constraints.size() == 1 && constraints[0].proof_type == pg_final_type) { - mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG_FINAL, /*is_kernel=*/true); + // Case: HIDING kernel; single HN_FINAL recursive verification of a kernel + if (constraints.size() == 1 && constraints[0].proof_type == hn_final_type) { + mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN_FINAL, /*is_kernel=*/true); return ivc; } @@ -91,10 +87,10 @@ std::shared_ptr create_mock_sumcheck_ivc_from_constraints( * necessarily valid * */ -SumcheckChonk::VerifierInputs create_mock_verification_queue_entry_nova( - const SumcheckChonk::QUEUE_TYPE verification_type, const bool is_kernel) +Chonk::VerifierInputs create_mock_verification_queue_entry(const Chonk::QUEUE_TYPE verification_type, + const bool is_kernel) { - using IvcType = SumcheckChonk; + using IvcType = Chonk; using FF = IvcType::FF; using MegaVerificationKey = IvcType::MegaVerificationKey; using Flavor = IvcType::Flavor; @@ -102,15 +98,14 @@ SumcheckChonk::VerifierInputs create_mock_verification_queue_entry_nova( size_t dyadic_size = 1 << Flavor::VIRTUAL_LOG_N; // maybe doesnt need to be correct size_t pub_inputs_offset = Flavor::has_zero_row ? 1 : 0; // always 1 - // Construct a mock Oink or PG proof and a mock MegaHonk verification key + // Construct a mock Oink or HN proof and a mock MegaHonk verification key std::vector proof; std::shared_ptr verification_key; if (is_kernel) { using KernelIO = stdlib::recursion::honk::KernelIO; - BB_ASSERT_EQ(verification_type == SumcheckChonk::QUEUE_TYPE::PG || - verification_type == SumcheckChonk::QUEUE_TYPE::PG_TAIL || - verification_type == SumcheckChonk::QUEUE_TYPE::PG_FINAL, + BB_ASSERT_EQ(verification_type == Chonk::QUEUE_TYPE::HN || verification_type == Chonk::QUEUE_TYPE::HN_TAIL || + verification_type == Chonk::QUEUE_TYPE::HN_FINAL, true); // kernel circuits are always folded, thus the proof always includes the nova fold proof @@ -120,18 +115,16 @@ SumcheckChonk::VerifierInputs create_mock_verification_queue_entry_nova( verification_key = create_mock_honk_vk(dyadic_size, pub_inputs_offset); } else { using AppIO = stdlib::recursion::honk::AppIO; - BB_ASSERT_EQ(verification_type == SumcheckChonk::QUEUE_TYPE::OINK || - verification_type == SumcheckChonk::QUEUE_TYPE::PG, - true); + BB_ASSERT_EQ(verification_type == Chonk::QUEUE_TYPE::OINK || verification_type == Chonk::QUEUE_TYPE::HN, true); // The first app is not folded thus the proof does not include the nova fold proof - bool include_fold = !(verification_type == SumcheckChonk::QUEUE_TYPE::OINK); + bool include_fold = !(verification_type == Chonk::QUEUE_TYPE::OINK); proof = create_mock_hyper_nova_proof(include_fold); verification_key = create_mock_honk_vk(dyadic_size, pub_inputs_offset); } - return SumcheckChonk::VerifierInputs{ proof, verification_key, verification_type, is_kernel }; + return Chonk::VerifierInputs{ proof, verification_key, verification_type, is_kernel }; } /** @@ -140,28 +133,26 @@ SumcheckChonk::VerifierInputs create_mock_verification_queue_entry_nova( * Also initializes the recursive verifier accumulator since it is hashed in circuit. * * @param ivc - * @param type The type of verification (OINK, PG, PG_TAIL, PG_FINAL) + * @param type The type of verification (OINK, HN, HN_TAIL, HN_FINAL) * @param is_kernel Whether this is a kernel circuit accumulation */ -void mock_sumcheck_ivc_accumulation(const std::shared_ptr& ivc, - SumcheckChonk::QUEUE_TYPE type, - const bool is_kernel) +void mock_chonk_accumulation(const std::shared_ptr& ivc, Chonk::QUEUE_TYPE type, const bool is_kernel) { - using FF = SumcheckChonk::FF; - using Commitment = SumcheckChonk::Commitment; + using FF = Chonk::FF; + using Commitment = Chonk::Commitment; // Initialize verifier accumulator with proper structure - ivc->recursive_verifier_native_accum.challenge = std::vector(SumcheckChonk::Flavor::VIRTUAL_LOG_N, FF::zero()); + ivc->recursive_verifier_native_accum.challenge = std::vector(Chonk::Flavor::VIRTUAL_LOG_N, FF::zero()); ivc->recursive_verifier_native_accum.non_shifted_evaluation = FF::zero(); ivc->recursive_verifier_native_accum.shifted_evaluation = FF::zero(); ivc->recursive_verifier_native_accum.non_shifted_commitment = Commitment::one(); ivc->recursive_verifier_native_accum.shifted_commitment = Commitment::one(); - SumcheckChonk::VerifierInputs entry = acir_format::create_mock_verification_queue_entry_nova(type, is_kernel); + Chonk::VerifierInputs entry = acir_format::create_mock_verification_queue_entry(type, is_kernel); ivc->verification_queue.emplace_back(entry); ivc->goblin.merge_verification_queue.emplace_back(acir_format::create_mock_merge_proof()); - if (type == SumcheckChonk::QUEUE_TYPE::PG_FINAL) { - ivc->decider_proof = acir_format::create_mock_pcs_proof(); + if (type == Chonk::QUEUE_TYPE::HN_FINAL) { + ivc->decider_proof = acir_format::create_mock_pcs_proof(); } ivc->num_circuits_accumulated++; } @@ -177,7 +168,7 @@ void populate_dummy_vk_in_constraint(MegaCircuitBuilder& builder, const std::shared_ptr& mock_verification_key, std::vector& key_witness_indices) { - using FF = SumcheckChonk::FF; + using FF = Chonk::FF; // Convert the VerificationKey to fields std::vector mock_vk_fields = mock_verification_key->to_field_elements(); diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp similarity index 66% rename from barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.hpp rename to barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp index 3686cb4e5f74..9c079bb34a8b 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp @@ -5,7 +5,7 @@ // ===================== #pragma once -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/dsl/acir_format/recursion_constraint.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" #include @@ -14,12 +14,9 @@ namespace acir_format { using namespace bb; -std::shared_ptr create_mock_sumcheck_ivc_from_constraints( - const std::vector& constraints); +std::shared_ptr create_mock_chonk_from_constraints(const std::vector& constraints); -void mock_sumcheck_ivc_accumulation(const std::shared_ptr& ivc, - SumcheckChonk::QUEUE_TYPE type, - const bool is_kernel); +void mock_chonk_accumulation(const std::shared_ptr& ivc, Chonk::QUEUE_TYPE type, const bool is_kernel); void populate_dummy_vk_in_constraint(MegaCircuitBuilder& builder, const std::shared_ptr& mock_verification_key, diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/sumcheck_pg_recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.test.cpp similarity index 78% rename from barretenberg/cpp/src/barretenberg/dsl/acir_format/sumcheck_pg_recursion_constraint.test.cpp rename to barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.test.cpp index ed3cd20dd04c..a8e1bbdc8c1c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/sumcheck_pg_recursion_constraint.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/hypernova_recursion_constraint.test.cpp @@ -1,9 +1,9 @@ +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "acir_format.hpp" #include "acir_format_mocks.hpp" #include "barretenberg/bbapi/bbapi_shared.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/dsl/acir_format/mock_verifier_inputs.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/ultra_honk/prover_instance.hpp" #include "barretenberg/ultra_honk/ultra_prover.hpp" @@ -17,18 +17,18 @@ using namespace acir_format; using namespace bb; -class SumcheckIvcRecursionConstraintTest : public ::testing::Test { +class HypernovaRecursionConstraintTest : public ::testing::Test { public: using Builder = MegaCircuitBuilder; using Flavor = MegaFlavor; using VerificationKey = MegaFlavor::VerificationKey; using FF = Flavor::FF; - using VerifierInputs = SumcheckChonk::VerifierInputs; - using QUEUE_TYPE = SumcheckChonk::QUEUE_TYPE; - using VerificationQueue = SumcheckChonk::VerificationQueue; + using VerifierInputs = Chonk::VerifierInputs; + using QUEUE_TYPE = Chonk::QUEUE_TYPE; + using VerificationQueue = Chonk::VerificationQueue; using ArithmeticConstraint = AcirFormat::PolyTripleConstraint; - using PairingPoints = SumcheckChonk::PairingPoints; + using PairingPoints = Chonk::PairingPoints; static constexpr size_t NUM_TRAILING_KERNELS = 3; // reset, tail, hiding @@ -36,7 +36,7 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { * @brief Constuct a simple arbitrary circuit to represent a mock app circuit * */ - static Builder construct_mock_app_circuit(const std::shared_ptr& ivc) + static Builder construct_mock_app_circuit(const std::shared_ptr& ivc) { Builder circuit{ ivc->goblin.op_queue }; GoblinMockCircuits::add_some_ecc_op_gates(circuit); @@ -55,28 +55,27 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { // Deepcopy the opqueue to avoid modifying the original one builder.op_queue = std::make_shared(*builder.op_queue); - std::shared_ptr prover_instance = - std::make_shared(builder); + std::shared_ptr prover_instance = std::make_shared(builder); std::shared_ptr vk = std::make_shared(prover_instance->get_precomputed()); return vk; } - static void construct_and_accumulate_trailing_kernels(const std::shared_ptr& ivc) + static void construct_and_accumulate_trailing_kernels(const std::shared_ptr& ivc) { // Reset kernel EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG); + EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN); construct_and_accumulate_mock_kernel(ivc); // Tail kernel EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_TAIL); + EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_TAIL); construct_and_accumulate_mock_kernel(ivc); // Hiding kernel EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_FINAL); + EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::HN_FINAL); construct_and_accumulate_mock_kernel(ivc); } @@ -108,8 +107,7 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { * @brief Constuct a mock app circuit with a UH recursive verifier * */ - static Builder construct_mock_UH_recursion_app_circuit(const std::shared_ptr& ivc, - const bool tamper_vk) + static Builder construct_mock_UH_recursion_app_circuit(const std::shared_ptr& ivc, const bool tamper_vk) { AcirProgram program; std::vector recursion_constraints; @@ -174,20 +172,20 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { ProofSurgeon::populate_recursion_witness_data( witness, proof_witnesses, key_witnesses, key_hash_witness, /*num_public_inputs_to_extract=*/0); - // The proof type can be either Oink or PG or PG_FINAL + // The proof type can be either Oink or HN or PG_FINAL PROOF_TYPE proof_type; switch (input.type) { case QUEUE_TYPE::OINK: proof_type = OINK; break; - case QUEUE_TYPE::PG: - proof_type = PG; + case QUEUE_TYPE::HN: + proof_type = HN; break; - case QUEUE_TYPE::PG_FINAL: - proof_type = PG_FINAL; + case QUEUE_TYPE::HN_FINAL: + proof_type = HN_FINAL; break; - case QUEUE_TYPE::PG_TAIL: - proof_type = PG_TAIL; + case QUEUE_TYPE::HN_TAIL: + proof_type = HN_TAIL; break; default: throw std::runtime_error("Invalid proof type"); @@ -220,23 +218,23 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { AcirProgram program; // Construct recursion constraints based on the ivc verification queue; populate the witness along the way - std::vector pg_recursion_constraints; - pg_recursion_constraints.reserve(verification_queue.size()); + std::vector hn_recursion_constraints; + hn_recursion_constraints.reserve(verification_queue.size()); for (const auto& queue_entry : verification_queue) { - pg_recursion_constraints.push_back(create_recursion_constraint(queue_entry, program.witness)); + hn_recursion_constraints.push_back(create_recursion_constraint(queue_entry, program.witness)); } // Construct a constraint system containing the business logic and ivc recursion constraints program.constraints.varnum = static_cast(program.witness.size()); - program.constraints.num_acir_opcodes = static_cast(pg_recursion_constraints.size()); - program.constraints.pg_recursion_constraints = pg_recursion_constraints; + program.constraints.num_acir_opcodes = static_cast(hn_recursion_constraints.size()); + program.constraints.hn_recursion_constraints = hn_recursion_constraints; program.constraints.original_opcode_indices = create_empty_original_opcode_indices(); mock_opcode_indices(program.constraints); return program; } - static void construct_and_accumulate_mock_kernel(std::shared_ptr ivc) + static void construct_and_accumulate_mock_kernel(std::shared_ptr ivc) { // construct a mock kernel program (acir) from the ivc verification queue const ProgramMetadata metadata{ ivc }; @@ -246,7 +244,7 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { ivc->accumulate(kernel, kernel_vk); } - static void construct_and_accumulate_mock_app(std::shared_ptr ivc) + static void construct_and_accumulate_mock_app(std::shared_ptr ivc) { // construct a mock kernel program (acir) from the ivc verification queue auto app_circuit = construct_mock_app_circuit(ivc); @@ -257,26 +255,23 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { * @brief Construct a kernel circuit VK from an acir program with IVC recursion constraints * * @param program Acir program representing a kernel circuit - * @return std::shared_ptr + * @return std::shared_ptr */ - static std::shared_ptr construct_kernel_vk_from_acir_program( - AcirProgram& program) + static std::shared_ptr construct_kernel_vk_from_acir_program(AcirProgram& program) { // Create kernel circuit from the kernel program Builder kernel = acir_format::create_circuit(program); // Manually construct the VK for the kernel circuit - auto prover_instance = std::make_shared(kernel); - auto verification_key = - std::make_shared(prover_instance->get_precomputed()); + auto prover_instance = std::make_shared(kernel); + auto verification_key = std::make_shared(prover_instance->get_precomputed()); return verification_key; } - static std::shared_ptr get_kernel_vk_from_circuit(Builder& kernel) + static std::shared_ptr get_kernel_vk_from_circuit(Builder& kernel) { - auto prover_instance = std::make_shared(kernel); - auto verification_key = - std::make_shared(prover_instance->get_precomputed()); + auto prover_instance = std::make_shared(kernel); + auto verification_key = std::make_shared(prover_instance->get_precomputed()); return verification_key; } @@ -287,7 +282,7 @@ class SumcheckIvcRecursionConstraintTest : public ::testing::Test { /** * @brief Check that the size of a mock merge proof matches expectation */ -TEST_F(SumcheckIvcRecursionConstraintTest, MockMergeProofSize) +TEST_F(HypernovaRecursionConstraintTest, MockMergeProofSize) { Goblin::MergeProof merge_proof = create_mock_merge_proof(); EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE); @@ -297,9 +292,9 @@ TEST_F(SumcheckIvcRecursionConstraintTest, MockMergeProofSize) * @brief Test IVC accumulation of a one app and one kernel; The kernel includes a recursive oink verification for the * app, specified via an ACIR RecursionConstraint. */ -TEST_F(SumcheckIvcRecursionConstraintTest, AccumulateSingleApp) +TEST_F(HypernovaRecursionConstraintTest, AccumulateSingleApp) { - auto ivc = std::make_shared(/*num_circuits=*/5 /* app, kernel, reset, tail, hiding */); + auto ivc = std::make_shared(/*num_circuits=*/5 /* app, kernel, reset, tail, hiding */); // construct a mock app_circuit construct_and_accumulate_mock_app(ivc); @@ -311,17 +306,17 @@ TEST_F(SumcheckIvcRecursionConstraintTest, AccumulateSingleApp) construct_and_accumulate_trailing_kernels(ivc); auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); + EXPECT_TRUE(Chonk::verify(proof, ivc->get_vk())); } /** * @brief Test IVC accumulation of two apps and two kernels; The first kernel contains a recursive oink verification and - * the second contains two recursive PG verifications, all specified via ACIR RecursionConstraints. + * the second contains two recursive HN verifications, all specified via ACIR RecursionConstraints. */ -TEST_F(SumcheckIvcRecursionConstraintTest, AccumulateTwoApps) +TEST_F(HypernovaRecursionConstraintTest, AccumulateTwoApps) { // 4 ciruits and the tail kernel - auto ivc = std::make_shared(/*num_circuits=*/7); + auto ivc = std::make_shared(/*num_circuits=*/7); // construct a mock app_circuit construct_and_accumulate_mock_app(ivc); @@ -341,17 +336,17 @@ TEST_F(SumcheckIvcRecursionConstraintTest, AccumulateTwoApps) construct_and_accumulate_trailing_kernels(ivc); auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); + EXPECT_TRUE(Chonk::verify(proof, ivc->get_vk())); } // Test generation of "init" kernel VK via dummy IVC data -TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInitKernelVKFromConstraints) +TEST_F(HypernovaRecursionConstraintTest, GenerateInitKernelVKFromConstraints) { BB_DISABLE_ASSERTS(); // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) std::shared_ptr expected_kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); // Construct and accumulate mock app_circuit construct_and_accumulate_mock_app(ivc); @@ -364,10 +359,10 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInitKernelVKFromConstraints) // Now, construct the kernel VK by mocking the post app accumulation state of the IVC std::shared_ptr kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::OINK, /*is_kernel=*/false); + acir_format::mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::OINK, /*is_kernel=*/false); AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); program.witness = {}; // remove the witness to mimick VK construction context @@ -379,13 +374,13 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInitKernelVKFromConstraints) } // Test generation of "reset" kernel VK via dummy IVC data -TEST_F(SumcheckIvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints) +TEST_F(HypernovaRecursionConstraintTest, GenerateResetKernelVKFromConstraints) { BB_DISABLE_ASSERTS(); // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) std::shared_ptr expected_kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); const ProgramMetadata metadata{ ivc }; @@ -395,9 +390,9 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints) // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) construct_and_accumulate_mock_kernel(ivc); EXPECT_TRUE(ivc->verification_queue.size() == 1); - EXPECT_TRUE(ivc->verification_queue[0].type == bb::SumcheckChonk::QUEUE_TYPE::PG); + EXPECT_TRUE(ivc->verification_queue[0].type == bb::Chonk::QUEUE_TYPE::HN); - // Construct and accumulate a mock RESET kernel (PG recursion for kernel accumulation) + // Construct and accumulate a mock RESET kernel (HN recursion for kernel accumulation) construct_and_accumulate_mock_kernel(ivc); expected_kernel_vk = ivc->verification_queue.back().honk_vk; } @@ -405,10 +400,10 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints) // Now, construct the kernel VK by mocking the IVC state prior to kernel construction std::shared_ptr kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); + acir_format::mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/true); AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); program.witness = {}; // remove the witness to mimick VK construction context kernel_vk = construct_kernel_vk_from_acir_program(program); @@ -419,13 +414,13 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints) } // Test generation of "tail" kernel VK via dummy IVC data -TEST_F(SumcheckIvcRecursionConstraintTest, GenerateTailKernelVKFromConstraints) +TEST_F(HypernovaRecursionConstraintTest, GenerateTailKernelVKFromConstraints) { BB_DISABLE_ASSERTS(); // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) std::shared_ptr expected_kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); const ProgramMetadata metadata{ ivc }; @@ -435,12 +430,12 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateTailKernelVKFromConstraints) // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) construct_and_accumulate_mock_kernel(ivc); - // Construct and accumulate a mock RESET kernel (PG recursion for kernel accumulation) + // Construct and accumulate a mock RESET kernel (HN recursion for kernel accumulation) construct_and_accumulate_mock_kernel(ivc); - // Construct and accumulate a mock TAIL kernel (PG recursion for kernel accumulation) + // Construct and accumulate a mock TAIL kernel (HN recursion for kernel accumulation) EXPECT_TRUE(ivc->verification_queue.size() == 1); - EXPECT_TRUE(ivc->verification_queue[0].type == bb::SumcheckChonk::QUEUE_TYPE::PG_TAIL); + EXPECT_TRUE(ivc->verification_queue[0].type == bb::Chonk::QUEUE_TYPE::HN_TAIL); construct_and_accumulate_mock_kernel(ivc); expected_kernel_vk = ivc->verification_queue.back().honk_vk; @@ -449,10 +444,10 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateTailKernelVKFromConstraints) // Now, construct the kernel VK by mocking the IVC state prior to kernel construction std::shared_ptr kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG_TAIL, /*is_kernel=*/true); + acir_format::mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN_TAIL, /*is_kernel=*/true); AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); program.witness = {}; // remove the witness to mimick VK construction context @@ -464,7 +459,7 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateTailKernelVKFromConstraints) } // Test generation of "inner" kernel VK via dummy IVC data -TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) +TEST_F(HypernovaRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) { BB_DISABLE_ASSERTS(); // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) @@ -472,7 +467,7 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) { // we have to set the number of circuits one more than the number of circuits we're accumulating as otherwise // the last circuit will be seen as a tail - auto ivc = std::make_shared(/*num_circuits=*/6); + auto ivc = std::make_shared(/*num_circuits=*/6); const ProgramMetadata metadata{ ivc }; @@ -487,9 +482,9 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) construct_and_accumulate_mock_app(ivc); } - { // Construct and accumulate a mock INNER kernel (PG recursion for kernel accumulation) + { // Construct and accumulate a mock INNER kernel (HN recursion for kernel accumulation) EXPECT_TRUE(ivc->verification_queue.size() == 2); - EXPECT_TRUE(ivc->verification_queue[1].type == bb::SumcheckChonk::QUEUE_TYPE::PG); + EXPECT_TRUE(ivc->verification_queue[1].type == bb::Chonk::QUEUE_TYPE::HN); construct_and_accumulate_mock_kernel(ivc); } @@ -499,11 +494,11 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) // Now, construct the kernel VK by mocking the IVC state prior to kernel construction std::shared_ptr kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/4); + auto ivc = std::make_shared(/*num_circuits=*/4); // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/false); + acir_format::mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/true); + acir_format::mock_chonk_accumulation(ivc, Chonk::QUEUE_TYPE::HN, /*is_kernel=*/false); AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); program.witness = {}; // remove the witness to mimick VK construction context @@ -515,13 +510,13 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) } // Test generation of "hiding" kernel VK via dummy IVC data -TEST_F(SumcheckIvcRecursionConstraintTest, GenerateHidingKernelVKFromConstraints) +TEST_F(HypernovaRecursionConstraintTest, GenerateHidingKernelVKFromConstraints) { BB_DISABLE_ASSERTS(); // First, construct the kernel VK by running the full IVC std::shared_ptr expected_hiding_kernel_vk; { - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); const ProgramMetadata metadata{ ivc }; { @@ -545,11 +540,11 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateHidingKernelVKFromConstraints { // mock IVC accumulation increases the num_circuits_accumualted, hence we need to assume the tail kernel has // been accumulated - auto ivc = std::make_shared(/*num_circuits=*/5); + auto ivc = std::make_shared(/*num_circuits=*/5); // construct a mock tail kernel - acir_format::mock_sumcheck_ivc_accumulation(ivc, - SumcheckChonk::QUEUE_TYPE::PG_FINAL, - /*is_kernel=*/true); + acir_format::mock_chonk_accumulation(ivc, + Chonk::QUEUE_TYPE::HN_FINAL, + /*is_kernel=*/true); AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); program.witness = {}; // remove the witness to mimick VK construction context kernel_vk = construct_kernel_vk_from_acir_program(program); @@ -562,9 +557,9 @@ TEST_F(SumcheckIvcRecursionConstraintTest, GenerateHidingKernelVKFromConstraints /** * @brief Test IVC accumulation of a one app and one kernel. The app includes a UltraHonk Recursive Verifier. */ -TEST_F(SumcheckIvcRecursionConstraintTest, RecursiveVerifierAppCircuit) +TEST_F(HypernovaRecursionConstraintTest, RecursiveVerifierAppCircuit) { - auto ivc = std::make_shared(/*num_circuits*/ 5); + auto ivc = std::make_shared(/*num_circuits*/ 5); // construct a mock app_circuit with an UH recursion call Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc, /*tamper_vk=*/false); @@ -578,18 +573,18 @@ TEST_F(SumcheckIvcRecursionConstraintTest, RecursiveVerifierAppCircuit) construct_and_accumulate_trailing_kernels(ivc); auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); + EXPECT_TRUE(Chonk::verify(proof, ivc->get_vk())); } /** * @brief Test IVC accumulation of a one app and one kernel. The app includes a UltraHonk Recursive Verifier that * verifies an invalid proof. */ -TEST_F(SumcheckIvcRecursionConstraintTest, RecursiveVerifierAppCircuitFailure) +TEST_F(HypernovaRecursionConstraintTest, RecursiveVerifierAppCircuitFailure) { - BB_DISABLE_ASSERTS(); // Disable assert in PG prover + BB_DISABLE_ASSERTS(); // Disable assert in HN prover - auto ivc = std::make_shared(/*num_circuits*/ 5); + auto ivc = std::make_shared(/*num_circuits*/ 5); // construct and accumulate mock app_circuit that has bad pairing point object Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc, /*tamper_vk=*/true); @@ -603,5 +598,5 @@ TEST_F(SumcheckIvcRecursionConstraintTest, RecursiveVerifierAppCircuitFailure) // We expect the Chonk proof to fail due to the app with a failed UH recursive verification auto proof = ivc->prove(); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc->get_vk())); + EXPECT_FALSE(Chonk::verify(proof, ivc->get_vk())); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.cpp index 998666e0dd14..79e8bd9df26f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.cpp @@ -372,7 +372,7 @@ template HonkProof create_mock_chonk_proof(const size_t inner ECCVMProof eccvm_proof{ create_mock_pre_ipa_proof(), create_mock_ipa_proof() }; HonkProof translator_proof = create_mock_translator_proof(); - SumcheckChonk::Proof chonk_proof{ mega_proof, { merge_proof, eccvm_proof, translator_proof } }; + Chonk::Proof chonk_proof{ mega_proof, { merge_proof, eccvm_proof, translator_proof } }; proof = chonk_proof.to_field_elements(); return proof; diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.hpp index 5fee91984786..2468655c4a22 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.hpp @@ -5,7 +5,7 @@ // ===================== #pragma once -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/dsl/acir_format/recursion_constraint.hpp" #include "barretenberg/goblin/goblin.hpp" #include "barretenberg/stdlib/primitives/bigfield/bigfield.hpp" diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.test.cpp index 8952962cdffa..c43742683b00 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.test.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/mock_verifier_inputs.test.cpp @@ -1,7 +1,7 @@ #include "barretenberg/dsl/acir_format/mock_verifier_inputs.hpp" #include "acir_format.hpp" #include "acir_format_mocks.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/goblin/mock_circuits.hpp" #include "barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp" #include "barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp" @@ -183,7 +183,7 @@ TYPED_TEST(MockVerifierInputsTest, MockUltraHonkProofSize) } /** - * @brief Check that the size of a mock LegacyChonk proof matches expectation + * @brief Check that the size of a mock Chonk proof matches expectation * */ TEST(MockVerifierInputsTest, MockChonkProofSize) @@ -191,5 +191,5 @@ TEST(MockVerifierInputsTest, MockChonkProofSize) using Builder = MegaCircuitBuilder; HonkProof chonk_proof = create_mock_chonk_proof(); - EXPECT_EQ(chonk_proof.size(), SumcheckChonk::Proof::PROOF_LENGTH()); + EXPECT_EQ(chonk_proof.size(), Chonk::Proof::PROOF_LENGTH()); } diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.test.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.test.cpp deleted file mode 100644 index 63a67e1d5942..000000000000 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/pg_recursion_constraint.test.cpp +++ /dev/null @@ -1,600 +0,0 @@ -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" -#include "acir_format.hpp" -#include "acir_format_mocks.hpp" -#include "barretenberg/chonk/sumcheck_chonk.hpp" -#include "barretenberg/chonk/sumcheck_mock_circuit_producer.hpp" -#include "barretenberg/dsl/acir_format/mock_verifier_inputs.hpp" -#include "barretenberg/goblin/mock_circuits.hpp" -#include "barretenberg/ultra_honk/prover_instance.hpp" -#include "barretenberg/ultra_honk/ultra_prover.hpp" -#include "barretenberg/ultra_honk/ultra_verifier.hpp" -#include "honk_recursion_constraint.hpp" -#include "proof_surgeon.hpp" - -#include -#include - -using namespace acir_format; -using namespace bb; - -class IvcRecursionConstraintTest : public ::testing::Test { - - public: - using Builder = MegaCircuitBuilder; - using Flavor = MegaFlavor; - using VerificationKey = MegaFlavor::VerificationKey; - using FF = Flavor::FF; - using VerifierInputs = SumcheckChonk::VerifierInputs; - using QUEUE_TYPE = SumcheckChonk::QUEUE_TYPE; - using VerificationQueue = SumcheckChonk::VerificationQueue; - using ArithmeticConstraint = AcirFormat::PolyTripleConstraint; - using PairingPoints = SumcheckChonk::PairingPoints; - - static constexpr size_t NUM_TRAILING_KERNELS = 3; // reset, tail, hiding - - /** - * @brief Constuct a simple arbitrary circuit to represent a mock app circuit - * - */ - static Builder construct_mock_app_circuit(const std::shared_ptr& ivc) - { - Builder circuit{ ivc->goblin.op_queue }; - GoblinMockCircuits::add_some_ecc_op_gates(circuit); - MockCircuits::add_arithmetic_gates(circuit); - stdlib::recursion::honk::AppIO::add_default(circuit); - return circuit; - } - - static std::shared_ptr get_verification_key(Builder& builder_in) - { - // This is a workaround to ensure that the circuit is finalized before we create the verification key - // In practice, this should not be needed as the circuit will be finalized when it is accumulated into the IVC - // but this is a workaround for the test setup. - // Create a copy of the input circuit - MegaCircuitBuilder_ builder{ builder_in }; - - // Deepcopy the opqueue to avoid modifying the original one - builder.op_queue = std::make_shared(*builder.op_queue); - std::shared_ptr prover_instance = - std::make_shared(builder); - std::shared_ptr vk = std::make_shared(prover_instance->get_precomputed()); - return vk; - } - - static void construct_and_accumulate_trailing_kernels(const std::shared_ptr& ivc) - { - // Reset kernel - EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG); - construct_and_accumulate_mock_kernel(ivc); - - // Tail kernel - EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_TAIL); - construct_and_accumulate_mock_kernel(ivc); - - // Hiding kernel - EXPECT_EQ(ivc->verification_queue.size(), 1); - EXPECT_EQ(ivc->verification_queue[0].type, QUEUE_TYPE::PG_FINAL); - construct_and_accumulate_mock_kernel(ivc); - } - - static UltraCircuitBuilder create_inner_circuit(size_t log_num_gates = 10) - { - UltraCircuitBuilder builder; - - // Create 2^log_n many add gates based on input log num gates - const size_t num_gates = (1 << log_num_gates); - for (size_t i = 0; i < num_gates; ++i) { - fr a = fr::random_element(); - uint32_t a_idx = builder.add_variable(a); - - fr b = fr::random_element(); - fr c = fr::random_element(); - fr d = a + b + c; - uint32_t b_idx = builder.add_variable(b); - uint32_t c_idx = builder.add_variable(c); - uint32_t d_idx = builder.add_variable(d); - - builder.create_big_add_gate({ a_idx, b_idx, c_idx, d_idx, fr(1), fr(1), fr(1), fr(-1), fr(0) }); - } - - stdlib::recursion::honk::DefaultIO::add_default(builder); - return builder; - } - - /** - * @brief Constuct a mock app circuit with a UH recursive verifier - * - */ - static Builder construct_mock_UH_recursion_app_circuit(const std::shared_ptr& ivc, - const bool tamper_vk) - { - AcirProgram program; - std::vector recursion_constraints; - - Builder circuit{ ivc->goblin.op_queue }; - GoblinMockCircuits::add_some_ecc_op_gates(circuit); - MockCircuits::add_arithmetic_gates(circuit); - - { - using RecursiveFlavor = UltraRecursiveFlavor_; - using VerifierOutput = bb::stdlib::recursion::honk::UltraRecursiveVerifierOutput; - using StdlibProof = bb::stdlib::Proof; - using StdlibIO = bb::stdlib::recursion::honk::DefaultIO; - - // Create an arbitrary inner circuit - auto inner_circuit = create_inner_circuit(); - - // Compute native verification key - auto prover_instance = std::make_shared>(inner_circuit); - auto honk_vk = std::make_shared(prover_instance->get_precomputed()); - UltraProver prover(prover_instance, honk_vk); // A prerequisite for computing VK - auto inner_proof = prover.construct_proof(); - - if (tamper_vk) { - honk_vk->q_l = g1::one; - UltraVerifier_ verifier(honk_vk); - EXPECT_FALSE(verifier.template verify_proof(inner_proof).result); - } - // Instantiate the recursive verifier using the native verification key - auto stdlib_vk_and_hash = std::make_shared(circuit, honk_vk); - stdlib::recursion::honk::UltraRecursiveVerifier_ verifier(&circuit, stdlib_vk_and_hash); - - StdlibProof stdlib_inner_proof(circuit, inner_proof); - VerifierOutput output = verifier.template verify_proof(stdlib_inner_proof); - - // IO - StdlibIO inputs; - inputs.pairing_inputs = output.points_accumulator; - inputs.set_public(); // propagate resulting pairing points on the public inputs - } - - return circuit; - } - - /** - * @brief Create an ACIR RecursionConstraint given the corresponding verifier inputs - * @brief In practice such constraints are created via a call to verify_proof(...) in noir - * - * @param input bberg style proof and verification key - * @param witness Array of witnesses into which the above data is placed - * @return RecursionConstraint - */ - static RecursionConstraint create_recursion_constraint(const VerifierInputs& input, SlabVector& witness) - { - // Assemble simple vectors of witnesses for vkey and proof - std::vector key_witnesses = input.honk_vk->to_field_elements(); - FF key_hash_witness = input.honk_vk->hash(); - std::vector proof_witnesses = input.proof; // proof contains the public inputs at this stage - - // Construct witness indices for each component in the constraint; populate the witness array - auto [key_indices, key_hash_index, proof_indices, public_inputs_indices] = - ProofSurgeon::populate_recursion_witness_data( - witness, proof_witnesses, key_witnesses, key_hash_witness, /*num_public_inputs_to_extract=*/0); - - // The proof type can be either Oink or PG or PG_FINAL - PROOF_TYPE proof_type; - switch (input.type) { - case QUEUE_TYPE::OINK: - proof_type = OINK; - break; - case QUEUE_TYPE::PG: - proof_type = PG; - break; - case QUEUE_TYPE::PG_FINAL: - proof_type = PG_FINAL; - break; - case QUEUE_TYPE::PG_TAIL: - proof_type = PG_TAIL; - break; - default: - throw std::runtime_error("Invalid proof type"); - } - - return RecursionConstraint{ - .key = key_indices, - .proof = {}, // the proof witness indices are not needed in an ivc recursion constraint - .public_inputs = public_inputs_indices, - .key_hash = key_hash_index, - .proof_type = proof_type, - }; - } - - /** - * @brief Generate an acir program {constraints, witness} for a mock kernel - * @details The IVC contains and internal verification queue that contains proofs to be recursively verified. - * Construct an AcirProgram with a RecursionConstraint for each entry in the ivc verification queue. (In practice - * these constraints would come directly from calls to verify_proof in noir). - * @note This method needs the number of public inputs in each proof-to-be-verified so they can be extracted and - * provided separately as is required in the acir constraint system. - * - * @param ivc - * @param inner_circuit_num_pub_inputs Num pub inputs for each circuit whose accumulation is recursively - * verified - * @return Builder - */ - static AcirProgram construct_mock_kernel_program(const VerificationQueue& verification_queue) - { - AcirProgram program; - - // Construct recursion constraints based on the ivc verification queue; populate the witness along the way - std::vector pg_recursion_constraints; - pg_recursion_constraints.reserve(verification_queue.size()); - for (const auto& queue_entry : verification_queue) { - pg_recursion_constraints.push_back(create_recursion_constraint(queue_entry, program.witness)); - } - - // Construct a constraint system containing the business logic and ivc recursion constraints - program.constraints.varnum = static_cast(program.witness.size()); - program.constraints.num_acir_opcodes = static_cast(pg_recursion_constraints.size()); - program.constraints.pg_recursion_constraints = pg_recursion_constraints; - program.constraints.original_opcode_indices = create_empty_original_opcode_indices(); - mock_opcode_indices(program.constraints); - - return program; - } - - static void construct_and_accumulate_mock_kernel(std::shared_ptr ivc) - { - // construct a mock kernel program (acir) from the ivc verification queue - const ProgramMetadata metadata{ ivc }; - AcirProgram mock_kernel_program = construct_mock_kernel_program(ivc->verification_queue); - auto kernel = acir_format::create_circuit(mock_kernel_program, metadata); - auto kernel_vk = get_kernel_vk_from_circuit(kernel); - ivc->accumulate(kernel, kernel_vk); - } - - static void construct_and_accumulate_mock_app(std::shared_ptr ivc) - { - // construct a mock kernel program (acir) from the ivc verification queue - auto app_circuit = construct_mock_app_circuit(ivc); - ivc->accumulate(app_circuit, get_verification_key(app_circuit)); - } - - /** - * @brief Construct a kernel circuit VK from an acir program with IVC recursion constraints - * - * @param program Acir program representing a kernel circuit - * @return std::shared_ptr - */ - static std::shared_ptr construct_kernel_vk_from_acir_program( - AcirProgram& program) - { - // Create kernel circuit from the kernel program - Builder kernel = acir_format::create_circuit(program); - - // Manually construct the VK for the kernel circuit - auto prover_instance = std::make_shared(kernel); - auto verification_key = - std::make_shared(prover_instance->get_precomputed()); - return verification_key; - } - - static std::shared_ptr get_kernel_vk_from_circuit(Builder& kernel) - { - auto prover_instance = std::make_shared(kernel); - auto verification_key = - std::make_shared(prover_instance->get_precomputed()); - return verification_key; - } - - protected: - void SetUp() override { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); } -}; - -/** - * @brief Check that the size of a mock merge proof matches expectation - */ -TEST_F(IvcRecursionConstraintTest, MockMergeProofSize) -{ - Goblin::MergeProof merge_proof = create_mock_merge_proof(); - EXPECT_EQ(merge_proof.size(), MERGE_PROOF_SIZE); -} - -/** - * @brief Test IVC accumulation of a one app and one kernel; The kernel includes a recursive oink verification for the - * app, specified via an ACIR RecursionConstraint. - */ -TEST_F(IvcRecursionConstraintTest, AccumulateSingleApp) -{ - auto ivc = std::make_shared(/*num_circuits=*/5 /* app, kernel, reset, tail, hiding */); - - // construct a mock app_circuit - construct_and_accumulate_mock_app(ivc); - - // Construct kernel consisting only of the kernel completion logic - construct_and_accumulate_mock_kernel(ivc); - - // add the trailing kernels - construct_and_accumulate_trailing_kernels(ivc); - - auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); -} - -/** - * @brief Test IVC accumulation of two apps and two kernels; The first kernel contains a recursive oink verification and - * the second contains two recursive PG verifications, all specified via ACIR RecursionConstraints. - */ -TEST_F(IvcRecursionConstraintTest, AccumulateTwoApps) -{ - // 4 ciruits and the tail kernel - auto ivc = std::make_shared(/*num_circuits=*/7); - - // construct a mock app_circuit - construct_and_accumulate_mock_app(ivc); - - const ProgramMetadata metadata{ ivc }; - - // Construct kernel_0; consists of a single oink recursive verification for app (plus databus/merge logic) - construct_and_accumulate_mock_kernel(ivc); - - // construct a mock app_circuit - construct_and_accumulate_mock_app(ivc); - - // Construct and accumulate another Kernel circuit - construct_and_accumulate_mock_kernel(ivc); - - // Accumulate the trailing kernels - construct_and_accumulate_trailing_kernels(ivc); - - auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); -} - -// Test generation of "init" kernel VK via dummy IVC data -TEST_F(IvcRecursionConstraintTest, GenerateInitKernelVKFromConstraints) -{ - // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) - std::shared_ptr expected_kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - // Construct and accumulate mock app_circuit - construct_and_accumulate_mock_app(ivc); - - // Construct and accumulate kernel consisting only of the kernel completion logic - construct_and_accumulate_mock_kernel(ivc); - expected_kernel_vk = ivc->verification_queue.back().honk_vk; - } - - // Now, construct the kernel VK by mocking the post app accumulation state of the IVC - std::shared_ptr kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::OINK, /*is_kernel=*/false); - AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); - program.witness = {}; // remove the witness to mimick VK construction context - - kernel_vk = construct_kernel_vk_from_acir_program(program); - } - - // Compare the VK constructed via running the IVc with the one constructed via mocking - EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); -} - -// Test generation of "reset" kernel VK via dummy IVC data -TEST_F(IvcRecursionConstraintTest, GenerateResetKernelVKFromConstraints) -{ - // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) - std::shared_ptr expected_kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - const ProgramMetadata metadata{ ivc }; - - // Construct and accumulate mock app_circuit - construct_and_accumulate_mock_app(ivc); - - // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) - construct_and_accumulate_mock_kernel(ivc); - EXPECT_TRUE(ivc->verification_queue.size() == 1); - EXPECT_TRUE(ivc->verification_queue[0].type == bb::SumcheckChonk::QUEUE_TYPE::PG); - - // Construct and accumulate a mock RESET kernel (PG recursion for kernel accumulation) - construct_and_accumulate_mock_kernel(ivc); - expected_kernel_vk = ivc->verification_queue.back().honk_vk; - } - - // Now, construct the kernel VK by mocking the IVC state prior to kernel construction - std::shared_ptr kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); - AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); - program.witness = {}; // remove the witness to mimick VK construction context - kernel_vk = construct_kernel_vk_from_acir_program(program); - } - - // Compare the VK constructed via running the IVc with the one constructed via mocking - EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); -} - -// Test generation of "tail" kernel VK via dummy IVC data -TEST_F(IvcRecursionConstraintTest, GenerateTailKernelVKFromConstraints) -{ - // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) - std::shared_ptr expected_kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - const ProgramMetadata metadata{ ivc }; - - // Construct and accumulate mock app_circuit - construct_and_accumulate_mock_app(ivc); - - // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) - construct_and_accumulate_mock_kernel(ivc); - - // Construct and accumulate a mock RESET kernel (PG recursion for kernel accumulation) - construct_and_accumulate_mock_kernel(ivc); - - // Construct and accumulate a mock TAIL kernel (PG recursion for kernel accumulation) - EXPECT_TRUE(ivc->verification_queue.size() == 1); - EXPECT_TRUE(ivc->verification_queue[0].type == bb::SumcheckChonk::QUEUE_TYPE::PG_TAIL); - construct_and_accumulate_mock_kernel(ivc); - - expected_kernel_vk = ivc->verification_queue.back().honk_vk; - } - - // Now, construct the kernel VK by mocking the IVC state prior to kernel construction - std::shared_ptr kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - - // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG_TAIL, /*is_kernel=*/true); - AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); - program.witness = {}; // remove the witness to mimick VK construction context - - kernel_vk = construct_kernel_vk_from_acir_program(program); - } - - // Compare the VK constructed via running the IVc with the one constructed via mocking - EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); -} - -// Test generation of "inner" kernel VK via dummy IVC data -TEST_F(IvcRecursionConstraintTest, GenerateInnerKernelVKFromConstraints) -{ - // First, construct the kernel VK by running the full IVC (accumulate one app and one kernel) - std::shared_ptr expected_kernel_vk; - { - // we have to set the number of circuits one more than the number of circuits we're accumulating as otherwise - // the last circuit will be seen as a tail - auto ivc = std::make_shared(/*num_circuits=*/6); - - const ProgramMetadata metadata{ ivc }; - - { // Construct and accumulate mock app_circuit - construct_and_accumulate_mock_app(ivc); - } - - // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) - construct_and_accumulate_mock_kernel(ivc); - - { // Construct and accumulate a second mock app_circuit - construct_and_accumulate_mock_app(ivc); - } - - { // Construct and accumulate a mock INNER kernel (PG recursion for kernel accumulation) - EXPECT_TRUE(ivc->verification_queue.size() == 2); - EXPECT_TRUE(ivc->verification_queue[1].type == bb::SumcheckChonk::QUEUE_TYPE::PG); - construct_and_accumulate_mock_kernel(ivc); - } - - expected_kernel_vk = ivc->verification_queue.back().honk_vk; - } - - // Now, construct the kernel VK by mocking the IVC state prior to kernel construction - std::shared_ptr kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/4); - - // Construct kernel consisting only of the kernel completion logic - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/true); - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG, /*is_kernel=*/false); - AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); - program.witness = {}; // remove the witness to mimick VK construction context - - kernel_vk = construct_kernel_vk_from_acir_program(program); - } - - // Compare the VK constructed via running the IVc with the one constructed via mocking - EXPECT_EQ(*kernel_vk.get(), *expected_kernel_vk.get()); -} - -// Test generation of "hiding" kernel VK via dummy IVC data -TEST_F(IvcRecursionConstraintTest, GenerateHidingKernelVKFromConstraints) -{ - // First, construct the kernel VK by running the full IVC - std::shared_ptr expected_hiding_kernel_vk; - { - auto ivc = std::make_shared(/*num_circuits=*/5); - const ProgramMetadata metadata{ ivc }; - - { - // Construct and accumulate mock app_circuit - construct_and_accumulate_mock_app(ivc); - } - - { - // Construct and accumulate a mock INIT kernel (oink recursion for app accumulation) - construct_and_accumulate_mock_kernel(ivc); - } - - construct_and_accumulate_trailing_kernels(ivc); - - // The single entry in the verification queue corresponds to the hiding kernel - expected_hiding_kernel_vk = ivc->verification_queue[0].honk_vk; - } - - // Now, construct the kernel VK by mocking the IVC state prior to kernel construction - std::shared_ptr kernel_vk; - { - // mock IVC accumulation increases the num_circuits_accumualted, hence we need to assume the tail kernel has - // been accumulated - auto ivc = std::make_shared(/*num_circuits=*/5); - // construct a mock tail kernel - acir_format::mock_sumcheck_ivc_accumulation(ivc, SumcheckChonk::QUEUE_TYPE::PG_FINAL, /*is_kernel=*/true); - AcirProgram program = construct_mock_kernel_program(ivc->verification_queue); - program.witness = {}; // remove the witness to mimick VK construction context - kernel_vk = construct_kernel_vk_from_acir_program(program); - } - - // Compare the VK constructed via running the IVc with the one constructed via mocking - EXPECT_EQ(*kernel_vk.get(), *expected_hiding_kernel_vk.get()); -} - -/** - * @brief Test IVC accumulation of a one app and one kernel. The app includes a UltraHonk Recursive Verifier. - * This test was copied from the AccumulateTwo test. - */ -TEST_F(IvcRecursionConstraintTest, RecursiveVerifierAppCircuitTest) -{ - auto ivc = std::make_shared(/*num_circuits*/ 5); - - // construct a mock app_circuit with an UH recursion call - Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc, /*tamper_vk=*/false); - - // Complete instance and generate an oink proof - ivc->accumulate(app_circuit, get_verification_key(app_circuit)); - - // Construct kernel consisting only of the kernel completion logic - construct_and_accumulate_mock_kernel(ivc); - - construct_and_accumulate_trailing_kernels(ivc); - - auto proof = ivc->prove(); - EXPECT_TRUE(SumcheckChonk::verify(proof, ivc->get_vk())); -} - -/** - * @brief Test IVC accumulation of a one app and one kernel. The app includes a UltraHonk Recursive Verifier that - * verifies a failed proof. This test was copied from the AccumulateTwo test. - */ -TEST_F(IvcRecursionConstraintTest, BadRecursiveVerifierAppCircuitTest) -{ - BB_DISABLE_ASSERTS(); // Disable assert in PG prover - - auto ivc = std::make_shared(/*num_circuits*/ 5); - - // construct and accumulate mock app_circuit that has bad pairing point object - Builder app_circuit = construct_mock_UH_recursion_app_circuit(ivc, /*tamper_vk=*/true); - ivc->accumulate(app_circuit, get_verification_key(app_circuit)); - - // Construct kernel consisting only of the kernel completion logic - construct_and_accumulate_mock_kernel(ivc); - - // add the trailing kernels - construct_and_accumulate_trailing_kernels(ivc); - - // We expect the Chonk proof to fail due to the app with a failed UH recursive verification - auto proof = ivc->prove(); - EXPECT_FALSE(SumcheckChonk::verify(proof, ivc->get_vk())); -} diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp index 86eaa09ae0a3..a25398d3379c 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/recursion_constraint.hpp @@ -17,7 +17,7 @@ namespace acir_format { // ACIR // Keep this enum values in sync with their noir counterpart constants defined in // noir-protocol-circuits/crates/types/src/constants.nr -enum PROOF_TYPE { PLONK, HONK, OINK, PG, AVM, ROLLUP_HONK, ROOT_ROLLUP_HONK, HONK_ZK, PG_FINAL, PG_TAIL, CHONK }; +enum PROOF_TYPE { PLONK, HONK, OINK, HN, AVM, ROLLUP_HONK, ROOT_ROLLUP_HONK, HONK_ZK, HN_FINAL, HN_TAIL, CHONK }; /** * @brief RecursionConstraint struct contains information required to recursively verify a proof! 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 d6107f5d7430..6781f4d72dff 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -14,7 +14,7 @@ #include "barretenberg/common/throw_or_abort.hpp" #include "barretenberg/common/zip_view.hpp" #include "barretenberg/dsl/acir_format/acir_format.hpp" -#include "barretenberg/dsl/acir_format/pg_recursion_constraint.hpp" +#include "barretenberg/dsl/acir_format/hypernova_recursion_constraint.hpp" #include "barretenberg/honk/execution_trace/mega_execution_trace.hpp" #include "barretenberg/serialize/msgpack.hpp" @@ -82,13 +82,13 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* ivc_inputs_buf, uint8_t* auto start = std::chrono::steady_clock::now(); PrivateExecutionSteps steps; steps.parse(PrivateExecutionStepRaw::parse_uncompressed(ivc_inputs_vec)); - std::shared_ptr ivc = steps.accumulate(); + std::shared_ptr ivc = steps.accumulate(); auto end = std::chrono::steady_clock::now(); auto diff = std::chrono::duration_cast(end - start); vinfo("time to construct and accumulate all circuits: ", diff.count()); vinfo("calling ivc.prove ..."); - SumcheckChonk::Proof proof = ivc->prove(); + Chonk::Proof proof = ivc->prove(); end = std::chrono::steady_clock::now(); diff = std::chrono::duration_cast(end - start); @@ -109,10 +109,10 @@ WASM_EXPORT void acir_prove_aztec_client(uint8_t const* ivc_inputs_buf, uint8_t* WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t const* vk_buf, bool* result) { - const auto proof = SumcheckChonk::Proof::from_msgpack_buffer(proof_buf); - const auto vk = from_buffer(from_buffer>(vk_buf)); + const auto proof = Chonk::Proof::from_msgpack_buffer(proof_buf); + const auto vk = from_buffer(from_buffer>(vk_buf)); - *result = SumcheckChonk::verify(proof, vk); + *result = Chonk::verify(proof, vk); } WASM_EXPORT void acir_prove_ultra_zk_honk(uint8_t const* acir_vec, @@ -442,7 +442,7 @@ WASM_EXPORT void acir_gates_aztec_client(uint8_t const* ivc_inputs_buf, uint8_t* auto raw_steps = PrivateExecutionStepRaw::parse_uncompressed(ivc_inputs_vec); std::vector totals; - auto ivc = std::make_shared(/*num_circuits=*/raw_steps.size()); + auto ivc = std::make_shared(/*num_circuits=*/raw_steps.size()); const acir_format::ProgramMetadata metadata{ ivc }; for (const PrivateExecutionStepRaw& step : raw_steps) { diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp index 323e5e1226cd..63b44546c74f 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -26,7 +26,7 @@ WASM_EXPORT void acir_prove_and_verify_ultra_honk(uint8_t const* constraint_syst bool* result); /** - * @brief Construct and verify a LegacyChonk proof + * @brief Construct and verify a Chonk proof * @deprecated */ WASM_EXPORT void acir_prove_and_verify_mega_honk(uint8_t const* constraint_system_buf, diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp index b5d5d695b74f..a363e31d01fe 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_flavor.hpp @@ -56,7 +56,7 @@ class ECCVMFlavor { static constexpr bool HasZK = true; // ECCVM proof size and its recursive verifier circuit are genuinely fixed, hence no padding is needed. static constexpr bool USE_PADDING = false; - // Fixed size of the ECCVM circuits used in LegacyChonk + // Fixed size of the ECCVM circuits used in Chonk // Important: these constants cannot be arbitrarily changes - please consult with a member of the Crypto team if // they become too small. static constexpr size_t ECCVM_FIXED_SIZE = 1UL << CONST_ECCVM_LOG_N; @@ -1023,7 +1023,7 @@ class ECCVMFlavor { * @brief When evaluating the sumcheck protocol - can we skip evaluation of _all_ relations for a given row? This * is purely a prover-side optimization. * - * @details When used in LegacyChonk, the ECCVM has a large fixed size, which is often not fully utilized. + * @details When used in Chonk, the ECCVM has a large fixed size, which is often not fully utilized. * If a row is completely empty, the values of `z_perm` and `z_perm_shift` will match, * we can use this as a proxy to determine if we can skip `Sumcheck::compute_univariate_with_row_skipping`. * In fact, here are several other conditions that need to be checked to see if we can skip the computation diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index 0823a4f62f0c..b516d3eecd56 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -131,7 +131,7 @@ class Goblin { /** * @brief Translator requires the op queue to start with a no-op to ensure op queue polynomials are shiftable and - * then expects three random ops. This is due to the ZK requirement in LegacyChonk. We need to also ensure + * then expects three random ops. This is due to the ZK requirement in Chonk. We need to also ensure * these ops are present when Goblin is used for AVM, although we only ever have a single table of ecc ops and no ZK * requiements. * diff --git a/barretenberg/cpp/src/barretenberg/honk/types/public_inputs_type.hpp b/barretenberg/cpp/src/barretenberg/honk/types/public_inputs_type.hpp index afe63648914f..5af662061fbf 100644 --- a/barretenberg/cpp/src/barretenberg/honk/types/public_inputs_type.hpp +++ b/barretenberg/cpp/src/barretenberg/honk/types/public_inputs_type.hpp @@ -30,7 +30,7 @@ static constexpr std::size_t GOBLIN_GROUP_PUBLIC_INPUTS_SIZE = 2 * GOBLIN_FIELD_ * Number of bb::fr elements used to represent a pair {P0, P1} of points in the public inputs * The formula assumes BIGGROUP_PUBLIC_INPUTS_SIZE == GOBLIN_GROUP_PUBLIC_INPUTS_SIZE, if this assumption * becomes incorrect, then the PAIRING_POINTS_SIZE should be split into two values: one for the pairing points used in - * LegacyChonk (Mega arithmetization), and one for the pairing points used in the Rollup (Ultra arithmetization) + * Chonk (Mega arithmetization), and one for the pairing points used in the Rollup (Ultra arithmetization) */ static constexpr std::size_t PAIRING_POINTS_SIZE = 2 * GOBLIN_GROUP_PUBLIC_INPUTS_SIZE; @@ -51,7 +51,7 @@ static constexpr std::size_t KERNEL_PUBLIC_INPUTS_SIZE = /*kernel_return_data*/ GOBLIN_GROUP_PUBLIC_INPUTS_SIZE + /*app_return_data*/ GOBLIN_GROUP_PUBLIC_INPUTS_SIZE + /*table_commitments*/ (MEGA_EXECUTION_TRACE_NUM_WIRES * GOBLIN_GROUP_PUBLIC_INPUTS_SIZE) + - /*output_pg_accum_hash*/ FR_PUBLIC_INPUTS_SIZE; + /*output_hn_accum_hash*/ FR_PUBLIC_INPUTS_SIZE; // Number of bb::fr elements used to represent the default public inputs, i.e., the pairing points static constexpr std::size_t DEFAULT_PUBLIC_INPUTS_SIZE = PAIRING_POINTS_SIZE; diff --git a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp index 60424d29322a..d56e805600d5 100644 --- a/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp +++ b/barretenberg/cpp/src/barretenberg/polynomials/polynomial_arithmetic.test.cpp @@ -491,7 +491,6 @@ TYPED_TEST(PolynomialTests, interpolation_constructor) } } -// LegacyPolynomials MLE TYPED_TEST(PolynomialTests, evaluate_mle_legacy) { using FF = TypeParam; diff --git a/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp index e2d5af22a3e8..9c7719f344d4 100644 --- a/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/databus_lookup_relation.hpp @@ -68,8 +68,7 @@ template class DatabusLookupRelationImpl { // degree to 4 which removes the need of having degree adjustments for folding. static constexpr size_t INVERSE_SUBREL_LENGTH = 5; // deg + 1 of inverse correctness subrelation static constexpr size_t INVERSE_SUBREL_LENGTH_ADJUSTMENT = 0; - // the max degree of this subrelation is 4 in both the sumcheck and protogalaxy contexts because in the latter case - // databus_id is always degree 0 when formed via interpolation across two instances + // the max degree of this subrelation is 4 static constexpr size_t LOOKUP_SUBREL_LENGTH = 5; // deg + 1 of log-deriv lookup subrelation static constexpr size_t LOOKUP_SUBREL_LENGTH_ADJUSTMENT = 0; static constexpr size_t READ_TAG_BOOLEAN_CHECK_SUBREL_LENGTH = @@ -326,10 +325,10 @@ template class DatabusLookupRelationImpl { const auto inverses_m = CoefficientAccumulator(BusData::inverses(in)); // Degree 1 Accumulator inverses(inverses_m); const auto read_counts_m = CoefficientAccumulator(BusData::read_counts(in)); // Degree 1 - const auto read_term = compute_read_term(in, params); // Degree 1 (2) - const auto write_term = compute_write_term(in, params); // Degree 1 (1) - const auto inverse_exists = compute_inverse_exists(in); // Degree 3 (3) - const auto read_selector = get_read_selector(in); // Degree 2 (2) + const auto read_term = compute_read_term(in, params); // Degree 1 + const auto write_term = compute_write_term(in, params); // Degree 1 + const auto inverse_exists = compute_inverse_exists(in); // Degree 3 + const auto read_selector = get_read_selector(in); // Degree 2 // Determine which pair of subrelations to update based on which bus column is being read // The inverse relation subrelation index @@ -340,25 +339,25 @@ template class DatabusLookupRelationImpl { constexpr size_t subrel_idx_3 = NUM_SUB_RELATION_PER_IDX * bus_idx + 2; // Establish the correctness of the polynomial of inverses I. Note: inverses is computed so that the value - // is 0 if !inverse_exists. Degree 3 (4) - // degrees 3(4) = 1(2) 1(1) 1(1) 3(3) + // is 0 if !inverse_exists. Degree 3 + // degrees 3 = 1 1 1 3 std::get(accumulator) += (read_term * write_term * inverses - inverse_exists) * scaling_factor; // Establish validity of the read. Note: no scaling factor here since this constraint is enforced across the // entire trace, not on a per-row basis. - // degree 3(3) = 2(2) 1(1) + // degree 3 = 2 1 Accumulator tmp = read_selector * write_term; - // degree 2(3) = 1(1) 1(2) + // degree 2 = 1 1 tmp -= Accumulator(read_counts_m) * read_term; - // degree 1(1) + // degree 1 tmp *= inverses; std::get(accumulator) += tmp; // Deg 4 (4) const auto read_tag_m = CoefficientAccumulator(BusData::read_tags(in)); const auto read_tag = ShortAccumulator(read_tag_m); // // this is done by row so we have to multiply by the scaling factor - // degree 1(1) 1(1) 1(1) = 2(2) + // degree 1 1 1 = 2 std::get(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor; } diff --git a/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp index 713a64806468..05cd95e8396b 100644 --- a/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/logderiv_lookup_relation.hpp @@ -67,7 +67,7 @@ template class LogDerivLookupRelationImpl { const auto row_has_write = CoefficientAccumulator(in.lookup_read_tags); const auto row_has_read = CoefficientAccumulator(in.q_lookup); - // degree 1(1) 1(1) 1 1 = 2(2) + // degree 1 1 1 1 = 2 return Accumulator(-(row_has_write * row_has_read) + row_has_write + row_has_read); } @@ -99,7 +99,7 @@ template class LogDerivLookupRelationImpl { auto table_3 = CoefficientAccumulator(in.table_3); auto table_4 = CoefficientAccumulator(in.table_4); - // degree 1 0(1) 1 0(1) 1 0(1) = 1(2) + // degree 1 0 1 0 1 0 = 1 auto result = (table_2 * eta) + (table_3 * eta_two) + (table_4 * eta_three); result += table_1; result += gamma; @@ -135,18 +135,18 @@ template class LogDerivLookupRelationImpl { // The wire values for lookup gates are accumulators structured in such a way that the differences w_i - // step_size*w_i_shift result in values present in column i of a corresponding table. See the documentation in // method get_lookup_accumulators() in for a detailed explanation. - // degree 1 1 1 0(1) = 2 + // degree 1 1 1 0 = 2 auto derived_table_entry_1 = (negative_column_1_step_size * w_1_shift) + (w_1 + gamma); // degree 1 1 1 = 2 auto derived_table_entry_2 = (negative_column_2_step_size * w_2_shift) + w_2; // degree 1 1 1 = 2 auto derived_table_entry_3 = (negative_column_3_step_size * w_3_shift) + w_3; - // 1 0 (1) = 1 (2) + // 1 0 = 1 auto table_index_entry = table_index * eta_three; // (w_1 + \gamma q_2*w_1_shift) + η(w_2 + q_m*w_2_shift) + η₂(w_3 + q_c*w_3_shift) + η₃q_index. // deg 2 or 3 - // degree 2 0(1) 2 0(1) = 2 (3) + // degree 2 0 2 0 = 2 auto result = Accumulator(derived_table_entry_2) * eta + Accumulator(derived_table_entry_3) * eta_two; result += Accumulator(derived_table_entry_1 + table_index_entry); return result; @@ -263,19 +263,19 @@ template class LogDerivLookupRelationImpl { const auto read_counts_m = CoefficientAccumulator(in.lookup_read_counts); // Degree 1 const auto read_selector_m = CoefficientAccumulator(in.q_lookup); // Degree 1 - const auto inverse_exists = compute_inverse_exists(in); // Degree 2 (2) - const auto read_term = compute_read_term(in, params); // Degree 2 (3) - const auto write_term = compute_write_term(in, params); // Degree 1 (2) + const auto inverse_exists = compute_inverse_exists(in); // Degree 2 + const auto read_term = compute_read_term(in, params); // Degree 2 + const auto write_term = compute_write_term(in, params); // Degree 1 // Establish the correctness of the polynomial of inverses I. Note: inverses is computed so that the value is 0 // if !inverse_exists. - // Degrees: 5(7) 2 (3) 1(2) 1 0(1) + // Degrees: 5 2 1 1 0 const Accumulator logderiv_first_term = (read_term * write_term * inverses - inverse_exists) * scaling_factor; - std::get<0>(accumulator) += ShortView(logderiv_first_term); // Deg 5(7) + std::get<0>(accumulator) += ShortView(logderiv_first_term); // Deg 5 // Establish validity of the read. Note: no scaling factor here since this constraint is 'linearly dependent, // i.e. enforced across the entire trace, not on a per-row basis. - // Degrees: 1 2 (3) = 3 (4) + // Degrees: 1 2 = 3 Accumulator tmp = Accumulator(read_selector_m) * write_term; tmp -= (Accumulator(read_counts_m) * read_term); tmp *= inverses; // degree 4(5) @@ -284,7 +284,7 @@ template class LogDerivLookupRelationImpl { // we should make sure that the read_tag is a boolean value const auto read_tag_m = CoefficientAccumulator(in.lookup_read_tags); const auto read_tag = BooleanCheckerAccumulator(read_tag_m); - // degree 1 1 0(1) = 2(3) + // degree 1 1 0(1) = 2 std::get<2>(accumulator) += (read_tag * read_tag - read_tag) * scaling_factor; } }; diff --git a/barretenberg/cpp/src/barretenberg/relations/memory_relation.hpp b/barretenberg/cpp/src/barretenberg/relations/memory_relation.hpp index 88f376f8874a..c9cee33d2ac2 100644 --- a/barretenberg/cpp/src/barretenberg/relations/memory_relation.hpp +++ b/barretenberg/cpp/src/barretenberg/relations/memory_relation.hpp @@ -136,7 +136,7 @@ template class MemoryRelationImpl { */ // memory_record_check and partial_record_check_m have either deg 1 or 2 (the latter refers to the - // functional univariate degree when we use PG as opposed to sumcheck.) + // functional univariate degree when we use HN as opposed to sumcheck.) auto memory_record_check_m = w_3_m * eta_three_m; memory_record_check_m += w_2_m * eta_two_m; memory_record_check_m += w_1_m * eta_m; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp index 1747bf903e33..a3e28905af41 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp @@ -5,7 +5,7 @@ // ===================== #pragma once -#include "barretenberg/chonk/sumcheck_chonk.hpp" +#include "barretenberg/chonk/chonk.hpp" #include "barretenberg/stdlib/goblin_verifier/goblin_recursive_verifier.hpp" #include "barretenberg/stdlib/honk_verifier/decider_recursive_verifier.hpp" @@ -33,18 +33,18 @@ class ChonkRecursiveVerifier { static constexpr size_t PROOF_LENGTH_WITHOUT_PUB_INPUTS(size_t virtual_log_n = Flavor::VIRTUAL_LOG_N) { - return bb::SumcheckChonk::Proof::PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n); + return bb::Chonk::Proof::PROOF_LENGTH_WITHOUT_PUB_INPUTS(virtual_log_n); } static constexpr size_t PROOF_LENGTH(size_t virtual_log_n = Flavor::VIRTUAL_LOG_N) { - return bb::SumcheckChonk::Proof::PROOF_LENGTH(virtual_log_n); + return bb::Chonk::Proof::PROOF_LENGTH(virtual_log_n); } StdlibHonkProof mega_proof; // proof of the hiding circuit StdlibGoblinProof goblin_proof; - StdlibProof(Builder& builder, const SumcheckChonk::Proof& proof) + StdlibProof(Builder& builder, const Chonk::Proof& proof) : mega_proof(builder, proof.mega_proof) , goblin_proof(builder, proof.goblin_proof) {} @@ -97,7 +97,7 @@ class ChonkRecursiveVerifier { BB_ASSERT_EQ(static_cast(end_idx), PROOF_LENGTH(virtual_log_n) + public_inputs_size, - "Reconstructed a LegacyChonk proof of wrong the length from proof indices."); + "Reconstructed a Chonk proof of wrong the length from proof indices."); } }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.test.cpp index 3e53bf23a8b9..da40f4e6e0a6 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.test.cpp @@ -1,5 +1,5 @@ #include "barretenberg/stdlib/chonk_verifier/chonk_recursive_verifier.hpp" -#include "barretenberg/chonk/test_bench_shared.hpp" +#include "barretenberg/chonk/mock_circuit_producer.hpp" #include "barretenberg/circuit_checker/circuit_checker.hpp" #include "barretenberg/common/test.hpp" #include "barretenberg/stdlib/honk_verifier/ultra_verification_keys_comparator.hpp" @@ -9,13 +9,13 @@ class ChonkRecursionTests : public testing::Test { public: using Builder = UltraCircuitBuilder; using ChonkVerifier = ChonkRecursiveVerifier; - using Proof = SumcheckChonk::Proof; + using Proof = Chonk::Proof; using StdlibProof = ChonkVerifier::StdlibProof; using RollupFlavor = UltraRollupRecursiveFlavor_; using NativeFlavor = RollupFlavor::NativeFlavor; using UltraRecursiveVerifier = UltraRecursiveVerifier_; using MockCircuitProducer = PrivateFunctionExecutionMockCircuitProducer; - using IVCVerificationKey = SumcheckChonk::VerificationKey; + using IVCVerificationKey = Chonk::VerificationKey; using PairingAccumulator = PairingPoints; static void SetUpTestSuite() { bb::srs::init_file_crs_factory(bb::srs::bb_crs_path()); } @@ -26,7 +26,7 @@ class ChonkRecursionTests : public testing::Test { }; /** - * @brief Construct a genuine LegacyChonk prover output based on accumulation of an arbitrary set of mock + * @brief Construct a genuine Chonk prover output based on accumulation of an arbitrary set of mock * circuits * */ @@ -35,7 +35,7 @@ class ChonkRecursionTests : public testing::Test { // Construct and accumulate a series of mocked private function execution circuits MockCircuitProducer circuit_producer{ num_app_circuits }; const size_t NUM_CIRCUITS = circuit_producer.total_num_circuits; - SumcheckChonk ivc{ NUM_CIRCUITS }; + Chonk ivc{ NUM_CIRCUITS }; for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) { circuit_producer.construct_and_accumulate_next_circuit(ivc); @@ -46,7 +46,7 @@ class ChonkRecursionTests : public testing::Test { }; /** - * @brief Ensure the LegacyChonk proof used herein can be natively verified + * @brief Ensure the Chonk proof used herein can be natively verified * */ TEST_F(ChonkRecursionTests, NativeVerification) @@ -54,21 +54,21 @@ TEST_F(ChonkRecursionTests, NativeVerification) auto [proof, vk] = construct_chonk_prover_output(); // Confirm that the IVC proof can be natively verified - EXPECT_TRUE(SumcheckChonk::verify(proof, vk)); + EXPECT_TRUE(Chonk::verify(proof, vk)); } /** - * @brief Construct and Check a recursive LegacyChonk verification circuit + * @brief Construct and Check a recursive Chonk verification circuit * */ TEST_F(ChonkRecursionTests, Basic) { using ChonkRecVerifierOutput = ChonkRecursiveVerifier::Output; - // Generate a genuine LegacyChonk prover output + // Generate a genuine Chonk prover output auto [proof, vk] = construct_chonk_prover_output(); - // Construct the LegacyChonk recursive verifier + // Construct the Chonk recursive verifier Builder builder; ChonkVerifier verifier{ &builder, vk.mega }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/recursive_verifier_instance.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/recursive_verifier_instance.hpp index 2b584ed64948..cba79d644a3a 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/recursive_verifier_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/recursive_verifier_instance.hpp @@ -44,7 +44,6 @@ template class RecursiveVerifierInstance_ { SubrelationSeparator alpha; RelationParameters relation_parameters; std::vector gate_challenges; - // The target sum, which is typically nonzero for a ProtogalaxyProver's accmumulator FF target_sum{ 0 }; WitnessCommitments witness_commitments; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp index 211f6bcd4d19..5e93b1d61e57 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.cpp @@ -196,7 +196,7 @@ template UltraRecursiveVerifier_> verify_proof>( const UltraRecursiveVerifier_>::StdlibProof& proof); -// LegacyChonk specialization +// Chonk specialization template UltraRecursiveVerifier_>::Output UltraRecursiveVerifier_< bb::MegaZKRecursiveFlavor_>:: verify_proof>( diff --git a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp index 15cacc33df01..589cb1ee8b93 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/honk_verifier/ultra_recursive_verifier.hpp @@ -30,7 +30,7 @@ template struct UltraRecursiveVerifierOutput { stdlib::Proof ipa_proof; G1 kernel_return_data; std::array ecc_op_tables; // Ecc op tables' commitments as extracted from the public inputs - // of the HidingKernel, only for LegacyChonk + // of the HidingKernel, only for Chonk FF mega_hash; // The hash of public inputs and VK of the inner circuit in the GoblinAvmRecursiveVerifier UltraRecursiveVerifierOutput() = default; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/merge_verifier/merge_recursive_verifier.hpp b/barretenberg/cpp/src/barretenberg/stdlib/merge_verifier/merge_recursive_verifier.hpp index 378d8921ba60..fb11cf98c96d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/merge_verifier/merge_recursive_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/merge_verifier/merge_recursive_verifier.hpp @@ -35,7 +35,7 @@ template class MergeRecursiveVerifier_ { /** * Commitments used by the verifier to run the verification algorithm. They contain: * - `t_commitments`: the subtable commitments data, containing the commitments to t_j read from the transcript by - * the PG verifier with which the Merge verifier shares a transcript + * the HN verifier with which the Merge verifier shares a transcript * - `T_prev_commitments`: the commitments to the full op_queue table after the previous iteration of merge */ struct InputCommitments { diff --git a/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp b/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp index 55718251a00e..1235bd6a06db 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.hpp @@ -65,7 +65,7 @@ class KernelIO { G1 kernel_return_data; // Commitment to the return data of a kernel circuit G1 app_return_data; // Commitment to the return data of an app circuit TableCommitments ecc_op_tables; // commitments to merged tables obtained from recursive Merge verification - FF output_pg_accum_hash; // hash of the output PG verifier accumulator + FF output_hn_accum_hash; // hash of the output HN verifier accumulator // Total size of the kernel IO public inputs static constexpr size_t PUBLIC_INPUTS_SIZE = KERNEL_PUBLIC_INPUTS_SIZE; @@ -90,7 +90,7 @@ class KernelIO { table_commitment = PublicPoint::reconstruct(public_inputs, PublicComponentKey{ index }); index += G1::PUBLIC_INPUTS_SIZE; } - output_pg_accum_hash = PublicFF::reconstruct(public_inputs, PublicComponentKey{ index }); + output_hn_accum_hash = PublicFF::reconstruct(public_inputs, PublicComponentKey{ index }); index += FF::PUBLIC_INPUTS_SIZE; } @@ -100,7 +100,7 @@ class KernelIO { */ void set_public() { - Builder* builder = output_pg_accum_hash.get_context(); + Builder* builder = output_hn_accum_hash.get_context(); if (pairing_inputs.P0.get_context() == nullptr) { // Add the default pairing points to the public inputs @@ -113,7 +113,7 @@ class KernelIO { for (auto& table_commitment : ecc_op_tables) { table_commitment.set_public(); } - output_pg_accum_hash.set_public(); + output_hn_accum_hash.set_public(); // Finalize the public inputs to ensure no more public inputs can be added hereafter. builder->finalize_public_inputs(); @@ -134,7 +134,7 @@ class KernelIO { table_commitment = G1(DEFAULT_ECC_COMMITMENT); table_commitment.convert_constant_to_fixed_witness(&builder); } - inputs.output_pg_accum_hash = FF::from_witness(&builder, typename FF::native(0)); + inputs.output_hn_accum_hash = FF::from_witness(&builder, typename FF::native(0)); inputs.set_public(); } }; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.test.cpp index 8273f2396373..3039931c575d 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/special_public_inputs/special_public_inputs.test.cpp @@ -31,7 +31,7 @@ TEST_F(SpecialPublicInputsTests, Basic) for (auto& commitment : ecc_op_tables_val) { commitment = G1Native::random_element(); } - FFNative output_pg_accum_hash_val = FFNative::random_element(); + FFNative output_hn_accum_hash_val = FFNative::random_element(); // Store the public inputs of the first circuit to be used by the second std::vector public_inputs; @@ -49,7 +49,7 @@ TEST_F(SpecialPublicInputsTests, Basic) for (auto [table_commitment, table_val] : zip_view(kernel_output.ecc_op_tables, ecc_op_tables_val)) { table_commitment = G1::from_witness(&builder, table_val); } - kernel_output.output_pg_accum_hash = FF::from_witness(&builder, output_pg_accum_hash_val); + kernel_output.output_hn_accum_hash = FF::from_witness(&builder, output_hn_accum_hash_val); // Propagate the kernel output via the public inputs kernel_output.set_public(); @@ -81,7 +81,7 @@ TEST_F(SpecialPublicInputsTests, Basic) for (auto [reconstructed_commitment, commitment] : zip_view(kernel_input.ecc_op_tables, ecc_op_tables_val)) { EXPECT_EQ(reconstructed_commitment.get_value(), commitment); } - EXPECT_EQ(kernel_input.output_pg_accum_hash.get_value(), output_pg_accum_hash_val); + EXPECT_EQ(kernel_input.output_hn_accum_hash.get_value(), output_hn_accum_hash_val); } } diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 55b694fb769a..43b3e6485c55 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -307,7 +307,6 @@ template class BaseTranscript { /** * @brief Given δ, compute the vector [δ, δ^2,..., δ^2^num_powers]. - * @details This is Step 2 of the protocol as written in the Protogalaxy paper. */ template std::vector compute_round_challenge_pows(const size_t num_powers, diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.cpp b/barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.cpp index d7c9fc0b5130..e199d60fbad7 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.cpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/translator_circuit_builder.cpp @@ -551,8 +551,8 @@ void TranslatorCircuitBuilder::feed_ecc_op_queue_into_circuit(const std::shared_ // When encountering the random operations in the op queue, populate the op wire without creating accumulation gates // These are present in the op queue at the beginning and end to ensure commitments and evaluations to op queue // polynomials do not reveal information about data in the op queue - // The position and number of these random ops are explained in LegacyChonk::hide_op_queue_content_tail_kernel - // and LegacyChonk::hide_op_queue_content_hiding_kernel + // The position and number of these random ops are explained in Chonk::hide_op_queue_content_tail_kernel + // and Chonk::hide_op_queue_content_hiding_kernel for (size_t i = NUM_NO_OPS_START; i <= NUM_RANDOM_OPS_START; ++i) { process_random_op(ultra_ops[i]); } diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp index 2e77e2c3066d..8d620f5097ea 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp @@ -984,7 +984,7 @@ class TranslatorFlavor { /** * @brief When evaluating the sumcheck protocol - can we skip evaluation of all relations for a given row? * - * @details When used in LegacyChonk, the Translator has a large fixed size, which is often not fully utilized. + * @details When used in Chonk, the Translator has a large fixed size, which is often not fully utilized. * If a row is completely empty, the values of z_perm and z_perm_shift will match, * we can use this as a proxy to determine if we can skip Sumcheck::compute_univariate **/ diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp index 6c983225ca75..2c05d2f13516 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_prover.cpp @@ -61,8 +61,8 @@ MergeProver::MergeProver(const std::shared_ptr& op_queue, * - \f$l_j = t_j, r_j = T_{prev,j}, m_j = T_j\f$ if we are prepending the subtable * - \f$l_j = T_{prev,j}, r_j = t_j, m_j = T_j\f$ if we are appending the subtable * - * @note The prover doesn't commit to t_j because it shares a transcript with the PG instance that folds the present - * circuit, and therefore t_j has already been added to the transcript by PG. + * @note The prover doesn't commit to t_j because it shares a transcript with the HN instance that folds the present + * circuit, and therefore t_j has already been added to the transcript by HN. * * @return MergeProver::MergeProof */ diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp index 3fb4468c4c70..5267a0d06377 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/merge_verifier.hpp @@ -37,7 +37,7 @@ class MergeVerifier { /** * Commitments used by the verifier to run the verification algorithm. They contain: * - `t_commitments`: the subtable commitments data, containing the commitments to t_j read from the transcript by - * the PG verifier with which the Merge verifier shares a transcript + * the HN verifier with which the Merge verifier shares a transcript * - `T_prev_commitments`: the commitments to the full op_queue table after the previous iteration of merge */ struct InputCommitments { diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/prover_instance.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/prover_instance.hpp index 02299f7a6387..cbc468e21a25 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/prover_instance.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/prover_instance.hpp @@ -92,7 +92,7 @@ template class ProverInstance_ { SubrelationSeparator alpha; // single challenge from which powers are computed for batching subrelations bb::RelationParameters relation_parameters; std::vector gate_challenges; - FF target_sum{ 0 }; // Sumcheck target sum; typically nonzero for a ProtogalaxyProver's accumulator + FF target_sum{ 0 }; // Sumcheck target sum HonkProof ipa_proof; // utilized only for UltraRollupFlavor diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 1987afe417e5..85294fac6bfc 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -73,7 +73,7 @@ UltraVerifier_::UltraVerifierOutput UltraVerifier_::verify_proof // Update output output.result &= ipa_result; } else if constexpr (std::is_same_v) { - // Add kernel return data and ecc op tables if we are verifying a LegacyChonk proof + // Add kernel return data and ecc op tables if we are verifying a Chonk proof output.kernel_return_data = inputs.kernel_return_data; output.ecc_op_tables = inputs.ecc_op_tables; } @@ -122,7 +122,7 @@ template UltraVerifier_::UltraVerifierOutput UltraVerifier_::UltraVerifierOutput UltraVerifier_::verify_proof( const Proof& proof, const Proof& ipa_proof); -// LegacyChonk specialization +// Chonk specialization template UltraVerifier_::UltraVerifierOutput UltraVerifier_::verify_proof( const Proof& proof, const Proof& ipa_proof); diff --git a/noir-projects/mock-protocol-circuits/crates/mock-hiding/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-hiding/src/main.nr index 4b6ff9068cb4..3a4322ed34c3 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-hiding/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-hiding/src/main.nr @@ -1,12 +1,12 @@ use dep::mock_types::{ - KernelPublicInputs, MEGA_VK_LENGTH_IN_FIELDS, PROOF_TYPE_PG_FINAL, VerificationKey, + KernelPublicInputs, MEGA_VK_LENGTH_IN_FIELDS, PROOF_TYPE_HN_FINAL, VerificationKey, }; fn main( prev_kernel_public_inputs: call_data(0) KernelPublicInputs, kernel_vk: VerificationKey, ) -> pub KernelPublicInputs { - std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_PG_FINAL); + std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_HN_FINAL); prev_kernel_public_inputs } diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr index 799ddc993e92..34299156a543 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-inner/src/main.nr @@ -1,6 +1,6 @@ use dep::mock_types::{ AppPublicInputs, MEGA_VK_LENGTH_IN_FIELDS, PrivateKernelPublicInputs, - PrivateKernelPublicInputsBuilder, PROOF_TYPE_PG, VerificationKey, + PrivateKernelPublicInputsBuilder, PROOF_TYPE_HN, VerificationKey, }; fn main( @@ -9,8 +9,8 @@ fn main( app_inputs: call_data(1) AppPublicInputs, app_vk: VerificationKey, ) -> return_data PrivateKernelPublicInputs { - std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_PG); - std::verify_proof_with_type(app_vk.key, [], [], app_vk.hash, PROOF_TYPE_PG); + std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_HN); + std::verify_proof_with_type(app_vk.key, [], [], app_vk.hash, PROOF_TYPE_HN); let mut private_kernel_inputs = PrivateKernelPublicInputsBuilder::from_previous_kernel(prev_kernel_public_inputs); diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr index 2ef2fc167062..966806ef93cb 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-reset/src/main.nr @@ -1,6 +1,6 @@ use dep::mock_types::{ MAX_COMMITMENT_READ_REQUESTS_PER_TX, MAX_COMMITMENTS_PER_TX, MEGA_VK_LENGTH_IN_FIELDS, - PrivateKernelPublicInputs, PROOF_TYPE_PG, VerificationKey, + PrivateKernelPublicInputs, PROOF_TYPE_HN, VerificationKey, }; // Mock reset kernel that reset read requests. @@ -10,7 +10,7 @@ fn main( kernel_vk: VerificationKey, commitment_read_hints: [u32; MAX_COMMITMENT_READ_REQUESTS_PER_TX], ) -> return_data PrivateKernelPublicInputs { - std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_PG); + std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_HN); for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX { if commitment_read_hints[i] != MAX_COMMITMENTS_PER_TX { diff --git a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr index 5da5105846c9..c6d3e2f8e08f 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-private-kernel-tail/src/main.nr @@ -1,6 +1,6 @@ use dep::mock_types::{ KernelPublicInputs, MAX_COMMITMENT_READ_REQUESTS_PER_TX, MEGA_VK_LENGTH_IN_FIELDS, - PrivateKernelPublicInputs, PROOF_TYPE_PG_TAIL, VerificationKey, + PrivateKernelPublicInputs, PROOF_TYPE_HN_TAIL, VerificationKey, }; // The tail kernel finishes the chonk chain exposing the final public inputs with no remaining calls or unfulfilled read requests. @@ -8,7 +8,7 @@ fn main( prev_kernel_public_inputs: call_data(0) PrivateKernelPublicInputs, kernel_vk: VerificationKey, ) -> return_data KernelPublicInputs { - std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_PG_TAIL); + std::verify_proof_with_type(kernel_vk.key, [], [], kernel_vk.hash, PROOF_TYPE_HN_TAIL); assert_eq(prev_kernel_public_inputs.remaining_calls, 0); for i in 0..MAX_COMMITMENT_READ_REQUESTS_PER_TX { diff --git a/noir-projects/mock-protocol-circuits/crates/mock-types/src/lib.nr b/noir-projects/mock-protocol-circuits/crates/mock-types/src/lib.nr index abfd6947efaa..c5b1677cc371 100644 --- a/noir-projects/mock-protocol-circuits/crates/mock-types/src/lib.nr +++ b/noir-projects/mock-protocol-circuits/crates/mock-types/src/lib.nr @@ -8,9 +8,9 @@ pub use protocol_types::{ constants::{ AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, CHONK_PROOF_LENGTH, CHONK_VK_LENGTH_IN_FIELDS, MEGA_VK_LENGTH_IN_FIELDS, - NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, PROOF_TYPE_AVM, PROOF_TYPE_CHONK, - PROOF_TYPE_OINK, PROOF_TYPE_PG, PROOF_TYPE_PG_FINAL, PROOF_TYPE_PG_TAIL, - PROOF_TYPE_ROLLUP_HONK, PROOF_TYPE_ROOT_ROLLUP_HONK, + NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH, PROOF_TYPE_AVM, PROOF_TYPE_CHONK, PROOF_TYPE_HN, + PROOF_TYPE_HN_FINAL, PROOF_TYPE_HN_TAIL, PROOF_TYPE_OINK, PROOF_TYPE_ROLLUP_HONK, + PROOF_TYPE_ROOT_ROLLUP_HONK, }, proof::{ traits::SerializeToColumns, diff --git a/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-public/src/main.nr b/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-public/src/main.nr index a7537f603596..729492dbfea6 100644 --- a/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-public/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-public/src/main.nr @@ -1,6 +1,6 @@ use types::{ abis::kernel_circuit_public_inputs::PrivateToPublicKernelCircuitPublicInputs, - constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PROOF_TYPE_PG_FINAL}, + constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_TO_PUBLIC_INDEX, PROOF_TYPE_HN_FINAL}, proof::vk_data::VkData, }; @@ -13,14 +13,14 @@ impl HidingKernelToPublicPrivateInputs { pub fn execute(self) { // Verify previous kernel, which contains a protogalaxy proof and a decider proof. // The associated public inputs and proofs are linked through the verification queue in the backend. - // The proof type `PROOF_TYPE_PG_FINAL` designates the final proof in the chonk sequence. + // The proof type `PROOF_TYPE_HN_FINAL` designates the final proof in the client IVC sequence. if !std::runtime::is_unconstrained() { std::verify_proof_with_type( self.previous_kernel_vk_data.vk.key, [], [], self.previous_kernel_vk_data.vk.hash, - PROOF_TYPE_PG_FINAL, + PROOF_TYPE_HN_FINAL, ); } diff --git a/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-rollup/src/main.nr b/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-rollup/src/main.nr index eafd6ae85f15..f6f355c44ac0 100644 --- a/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-rollup/src/main.nr +++ b/noir-projects/noir-protocol-circuits/crates/hiding-kernel-to-rollup/src/main.nr @@ -1,6 +1,6 @@ use types::{ abis::kernel_circuit_public_inputs::PrivateToRollupKernelCircuitPublicInputs, - constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_INDEX, PROOF_TYPE_PG_FINAL}, + constants::{MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_TAIL_INDEX, PROOF_TYPE_HN_FINAL}, proof::vk_data::VkData, }; @@ -13,14 +13,14 @@ impl HidingKernelToRollupPrivateInputs { pub fn execute(self) { // Verify previous kernel, which contains a protogalaxy proof and a decider proof. // The associated public inputs and proofs are linked through the verification queue in the backend. - // The proof type `PROOF_TYPE_PG_FINAL` designates the final proof in the chonk sequence. + // The proof type `PROOF_TYPE_HN_FINAL` designates the final proof in the chonk sequence. if !std::runtime::is_unconstrained() { std::verify_proof_with_type( self.previous_kernel_vk_data.vk.key, [], [], self.previous_kernel_vk_data.vk.hash, - PROOF_TYPE_PG_FINAL, + PROOF_TYPE_HN_FINAL, ); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr index c90b230cda7a..1951b2ce087b 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel/private_call_data.nr @@ -1,7 +1,7 @@ use crate::{ abis::private_circuit_public_inputs::PrivateCircuitPublicInputs, address::SaltedInitializationHash, - constants::{FUNCTION_TREE_HEIGHT, PROOF_TYPE_OINK, PROOF_TYPE_PG, PUBLIC_DATA_TREE_HEIGHT}, + constants::{FUNCTION_TREE_HEIGHT, PROOF_TYPE_HN, PROOF_TYPE_OINK, PUBLIC_DATA_TREE_HEIGHT}, data::public_data_tree_leaf_preimage::PublicDataTreeLeafPreimage, merkle_tree::MembershipWitness, proof::verification_key::ChonkVerificationKey, @@ -21,7 +21,7 @@ impl PrivateCallData { let proof_type = if is_first_app { PROOF_TYPE_OINK } else { - PROOF_TYPE_PG + PROOF_TYPE_HN }; // CHONK public inputs are linked in the backend via the databus. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr index 5cb200d893d0..3ffcf8b853a2 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/private_kernel_data.nr @@ -1,7 +1,7 @@ use crate::{ abis::kernel_circuit_public_inputs::PrivateKernelCircuitPublicInputs, constants::{ - MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_RESET_INDEX, PROOF_TYPE_PG, PROOF_TYPE_PG_TAIL, + MEGA_VK_LENGTH_IN_FIELDS, PRIVATE_KERNEL_RESET_INDEX, PROOF_TYPE_HN, PROOF_TYPE_HN_TAIL, }, proof::vk_data::VkData, utils::arrays::find_index_hint, @@ -41,10 +41,10 @@ impl PrivateKernelData { self.vk_data.validate_in_vk_tree(self.public_inputs.constants.vk_tree_root); } pub fn verify(self, is_last_inner_kernel: bool) { - let mut proof_type = PROOF_TYPE_PG; - // chonk public inputs are linked in the backend via the databus + let mut proof_type = PROOF_TYPE_HN; + // Chonk public inputs are linked in the backend via the databus if is_last_inner_kernel { - proof_type = PROOF_TYPE_PG_TAIL; + proof_type = PROOF_TYPE_HN_TAIL; } std::verify_proof_with_type( self.vk_data.vk.key, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr index abd21c0e0eef..36c96b26204a 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/constants.nr @@ -1098,13 +1098,13 @@ pub global BLOCK_END_PREFIX: Field = 0x626c6f636b5f656e64; // = "block_end".to_f pub global PROOF_TYPE_PLONK: u32 = 0; pub global PROOF_TYPE_HONK: u32 = 1; pub global PROOF_TYPE_OINK: u32 = 2; -pub global PROOF_TYPE_PG: u32 = 3; +pub global PROOF_TYPE_HN: u32 = 3; pub global PROOF_TYPE_AVM: u32 = 4; pub global PROOF_TYPE_ROLLUP_HONK: u32 = 5; pub global PROOF_TYPE_ROOT_ROLLUP_HONK: u32 = 6; // worktodo comment here where 7 is -pub global PROOF_TYPE_PG_FINAL: u32 = 8; -pub global PROOF_TYPE_PG_TAIL: u32 = 9; +pub global PROOF_TYPE_HN_FINAL: u32 = 8; +pub global PROOF_TYPE_HN_TAIL: u32 = 9; pub global PROOF_TYPE_CHONK: u32 = 10; // TODO: Make it 1_u128 << 64 as Field without breaking TS constants generator diff --git a/yarn-project/constants/src/constants.gen.ts b/yarn-project/constants/src/constants.gen.ts index 9e64f035ed12..6ecc2db1bceb 100644 --- a/yarn-project/constants/src/constants.gen.ts +++ b/yarn-project/constants/src/constants.gen.ts @@ -455,12 +455,12 @@ export const BLOCK_END_PREFIX = 1815594492414860291684n; export const PROOF_TYPE_PLONK = 0; export const PROOF_TYPE_HONK = 1; export const PROOF_TYPE_OINK = 2; -export const PROOF_TYPE_PG = 3; +export const PROOF_TYPE_HN = 3; export const PROOF_TYPE_AVM = 4; export const PROOF_TYPE_ROLLUP_HONK = 5; export const PROOF_TYPE_ROOT_ROLLUP_HONK = 6; -export const PROOF_TYPE_PG_FINAL = 8; -export const PROOF_TYPE_PG_TAIL = 9; +export const PROOF_TYPE_HN_FINAL = 8; +export const PROOF_TYPE_HN_TAIL = 9; export const PROOF_TYPE_CHONK = 10; export const TWO_POW_64 = 18446744073709551616n; export const AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_HEIGHT = 6; @@ -536,4 +536,4 @@ export enum GeneratorIndex { EVENT_COMMITMENT = 59, PUBLIC_BYTECODE = 60, PROTOCOL_CONTRACTS = 61, -} \ No newline at end of file +}