Skip to content

Commit

Permalink
additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ledwards2225 committed Jan 22, 2024
1 parent 91fc81e commit 57af750
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
14 changes: 12 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -129,17 +135,19 @@ 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);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set
// 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
Expand Down Expand Up @@ -168,17 +176,19 @@ 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);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/811): Don't hardcode dyadic circuit size. Currently set
// 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
Expand Down
18 changes: 18 additions & 0 deletions barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/goblin/goblin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Goblin {
std::unique_ptr<ECCVMProver> eccvm_prover;
std::unique_ptr<TranslatorComposer> translator_composer;

AccumulationOutput accumulator; // Used only for ACIR methods
AccumulationOutput accumulator; // Used only for ACIR methods for now

public:
/**
Expand Down

0 comments on commit 57af750

Please sign in to comment.