-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Goblin Honk Composer/Prover/Verifier (#1220)
# Description The Composer, Prover and Verifier for Goblin Ultra Honk. These are implemented as instantiations of the existing "Ultra" template classes, e.g. `GoblinUltraComposer = UltraComposer_<flavor::GoblinUltra>`, etc. This work makes it possible to create and verify a Goblin Ultra Honk proof. "Verification" here means confirmation that the ECC op gates have been correctly incorporated into the circuit (checked via a new relation) plus genuine verification of the conventional UltraHonk proof. The _correctness_ of the the ECC op gates is of course not verified, as that is the role of the other components of the Goblin stack. The new "op gate consistency" relation simply checks that the op wire values have been correctly copied into the conventional wires (needed for copy constraints) and that the op wire polynomials vanish everywhere outside the range of ECC op gates. # Checklist: - [ ] I have reviewed my diff in github, line by line. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to the issue(s) that it resolves. - [ ] There are no unexpected formatting changes, superfluous debug logs, or commented-out code. - [ ] The branch has been merged or rebased against the head of its merge target. - [ ] I'm happy for the PR to be merged at the reviewer's next convenience. --------- Co-authored-by: ludamad <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,158 additions
and
216 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
cpp/src/barretenberg/honk/composer/goblin_ultra_composer.test.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <cstddef> | ||
#include <cstdint> | ||
#include <gtest/gtest.h> | ||
|
||
#include "barretenberg/common/log.hpp" | ||
#include "barretenberg/honk/composer/ultra_composer.hpp" | ||
#include "barretenberg/honk/proof_system/ultra_prover.hpp" | ||
#include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" | ||
|
||
using namespace proof_system::honk; | ||
|
||
namespace test_ultra_honk_composer { | ||
|
||
namespace { | ||
auto& engine = numeric::random::get_debug_engine(); | ||
} | ||
|
||
class GoblinUltraHonkComposerTests : public ::testing::Test { | ||
protected: | ||
static void SetUpTestSuite() { barretenberg::srs::init_crs_factory("../srs_db/ignition"); } | ||
}; | ||
|
||
/** | ||
* @brief Test proof construction/verification for a circuit with ECC op gates, public inputs, and basic arithmetic | ||
* gates | ||
* | ||
*/ | ||
TEST_F(GoblinUltraHonkComposerTests, SimpleCircuit) | ||
{ | ||
auto builder = UltraCircuitBuilder(); | ||
|
||
// Define an arbitrary number of operations/gates | ||
size_t num_ecc_ops = 3; | ||
size_t num_conventional_gates = 10; | ||
|
||
// Add some ecc op gates | ||
for (size_t i = 0; i < num_ecc_ops; ++i) { | ||
auto point = g1::affine_one * fr::random_element(); | ||
auto scalar = fr::random_element(); | ||
builder.queue_ecc_mul_accum(point, scalar); | ||
} | ||
|
||
// Add some conventional gates that utlize public inputs | ||
for (size_t i = 0; i < num_conventional_gates; ++i) { | ||
fr a = fr::random_element(); | ||
fr b = fr::random_element(); | ||
fr c = fr::random_element(); | ||
fr d = a + b + c; | ||
uint32_t a_idx = builder.add_public_variable(a); | ||
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) }); | ||
} | ||
|
||
auto composer = GoblinUltraComposer(); | ||
auto prover = composer.create_prover(builder); | ||
auto verifier = composer.create_verifier(builder); | ||
auto proof = prover.construct_proof(); | ||
bool verified = verifier.verify_proof(proof); | ||
EXPECT_EQ(verified, true); | ||
} | ||
|
||
} // namespace test_ultra_honk_composer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.