From 57af750a69f09a926d5ec33e383e086c79b337f1 Mon Sep 17 00:00:00 2001 From: ledwards2225 Date: Mon, 22 Jan 2024 17:45:40 +0000 Subject: [PATCH] additional comments --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 14 ++++++++++++-- .../barretenberg/dsl/acir_proofs/c_bind.hpp | 18 ++++++++++++++++++ .../cpp/src/barretenberg/goblin/goblin.hpp | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index d5d626bd8f2..b3d45629600 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -44,6 +44,12 @@ void init_bn254_crs(size_t dyadic_circuit_size) srs::init_crs_factory(bn254_g1_data, bn254_g2_data); } +/** + * @brief Initialize the global crs_factory for grumpkin based on a known dyadic circuit size + * @details Grumpkin crs is required only for the ECCVM + * + * @param dyadic_circuit_size power-of-2 circuit size + */ void init_grumpkin_crs(size_t eccvm_dyadic_circuit_size) { auto grumpkin_g1_data = get_grumpkin_g1_data(CRS_PATH, eccvm_dyadic_circuit_size); @@ -129,9 +135,11 @@ bool proveAndVerify(const std::string& bytecodePath, const std::string& witnessP */ bool accumulateAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath) { + // Populate the acir constraint system and witness from gzipped data auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); + // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation acir_proofs::GoblinAcirComposer acir_composer; acir_composer.create_circuit(constraint_system, witness); @@ -139,7 +147,7 @@ bool accumulateAndVerifyGoblin(const std::string& bytecodePath, const std::strin // to max circuit size present in acir tests suite. size_t hardcoded_bn254_dyadic_size_hack = 1 << 18; init_bn254_crs(hardcoded_bn254_dyadic_size_hack); - size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; + size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); // Call accumulate to generate a GoblinUltraHonk proof @@ -168,9 +176,11 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, const std::string& witnessPath, [[maybe_unused]] bool recursive) { + // Populate the acir constraint system and witness from gzipped data auto constraint_system = get_constraint_system(bytecodePath); auto witness = get_witness(witnessPath); + // Instantiate a Goblin acir composer and construct a bberg circuit from the acir representation acir_proofs::GoblinAcirComposer acir_composer; acir_composer.create_circuit(constraint_system, witness); @@ -178,7 +188,7 @@ bool proveAndVerifyGoblin(const std::string& bytecodePath, // to max circuit size present in acir tests suite. size_t hardcoded_bn254_dyadic_size_hack = 1 << 18; init_bn254_crs(hardcoded_bn254_dyadic_size_hack); - size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; + size_t hardcoded_grumpkin_dyadic_size_hack = 1 << 10; // For eccvm only init_grumpkin_crs(hardcoded_grumpkin_dyadic_size_hack); // Generate a GoblinUltraHonk proof and a full Goblin proof 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 91de508104a..76b24886b1d 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp @@ -34,11 +34,21 @@ WASM_EXPORT void acir_create_proof(in_ptr acir_composer_ptr, bool const* is_recursive, uint8_t** out); +/** + * @brief Perform the goblin accumulate operation + * @details Constructs a GUH proof and possibly handles transcript merge logic + * + */ WASM_EXPORT void acir_goblin_accumulate(in_ptr acir_composer_ptr, uint8_t const* constraint_system_buf, uint8_t const* witness_buf, uint8_t** out); +/** + * @brief Construct a full goblin proof + * @details Makes a call to accumulate to a final circuit before constructing a Goblin proof + * + */ WASM_EXPORT void acir_goblin_prove(in_ptr acir_composer_ptr, uint8_t const* constraint_system_buf, uint8_t const* witness_buf, @@ -57,8 +67,16 @@ WASM_EXPORT void acir_verify_proof(in_ptr acir_composer_ptr, bool const* is_recursive, bool* result); +/** + * @brief Verifies a GUH proof produced during goblin accumulation + * + */ WASM_EXPORT void acir_goblin_verify_accumulator(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); +/** + * @brief Verifies a full goblin proof (and the GUH proof produced by accumulation) + * + */ WASM_EXPORT void acir_goblin_verify(in_ptr acir_composer_ptr, uint8_t const* proof_buf, bool* result); WASM_EXPORT void acir_get_solidity_verifier(in_ptr acir_composer_ptr, out_str_buf out); diff --git a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp index a20bfdccb4e..aac0ef305ca 100644 --- a/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp +++ b/barretenberg/cpp/src/barretenberg/goblin/goblin.hpp @@ -84,7 +84,7 @@ class Goblin { std::unique_ptr eccvm_prover; std::unique_ptr translator_composer; - AccumulationOutput accumulator; // Used only for ACIR methods + AccumulationOutput accumulator; // Used only for ACIR methods for now public: /**