-
Notifications
You must be signed in to change notification settings - Fork 598
feat: goblin op queue transcript aggregation #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
eed0ec5
initial agg protocol in prover and verifier
ledwards2225 9c6c0ba
set ultra ops in op queue plus test
ledwards2225 75b568c
prover has a pointer to op queue
ledwards2225 485fd84
infra for getting prev agg transcript from op queue
ledwards2225 afe3a07
tests passing with only shifted t claims
ledwards2225 08bf084
op codes constrained to constant variables
ledwards2225 0f76d3b
passing with claims on t and T
ledwards2225 f29901d
verifier checks identity plus cleanup
ledwards2225 3ccc711
basic prover functionality in place
ledwards2225 1138b7d
full protocol passing with mock prev op queue data
ledwards2225 ce0e92e
test improvement, new right shift, cleanup
ledwards2225 81fbe06
resolve some todos in the builder
ledwards2225 9bb5889
fix build error
ledwards2225 61cae4a
splitting goblin builder into its own class
ledwards2225 578a646
chore: remove bb symlink
ludamad efebc27
chore: circuits/bb => bb
ludamad 11a3ae6
chore: Prepare for build system changes
ludamad a6ff45c
Merge remote-tracking branch 'origin/master' into lde/transcript_agg_new
ludamad 0f59546
Merge fixup
ludamad e281742
formatting
ledwards2225 6947053
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 51964dd
recursive flavor is templated by builder
ledwards2225 f1e3508
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 d04a518
more formatting
ledwards2225 97f5815
improve right shift fctn and add test
ledwards2225 7fe7291
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 24d8f47
clean up recursive verifier circuit tests
ledwards2225 d15c6fb
all 4 recursive vers working w op queue agg
ledwards2225 b8bfb1c
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 ebac0cc
fix ECCVM build error
ledwards2225 9e42d7e
format
ledwards2225 b1f18a4
comments and cleanup
ledwards2225 91589e6
brutal master merge
ledwards2225 18857dd
format
ledwards2225 98042d0
fpormatt
ledwards2225 9ad0e48
formewnt
ledwards2225 dd780a0
add todo for sumcheck
ledwards2225 7a4c584
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 e35d19a
cleanup
ledwards2225 be50dda
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 c0156af
initial version of simple full goblin test
ledwards2225 8af1b00
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 1e2d734
fix
ledwards2225 517ccba
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 9cfbaf9
Updates based on Keshas comments
ledwards2225 b46982f
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 2b476a1
add todo with issue for avoiding new challenge
ledwards2225 782cace
Merge branch 'master' into lde/transcript_aggregation_redux
ledwards2225 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
197 changes: 197 additions & 0 deletions
197
barretenberg/cpp/src/barretenberg/honk/composer/goblin/full_goblin_composer.test.cpp
This file contains hidden or 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,197 @@ | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "barretenberg/common/log.hpp" | ||
| #include "barretenberg/honk/composer/eccvm_composer.hpp" | ||
| #include "barretenberg/honk/composer/ultra_composer.hpp" | ||
| #include "barretenberg/honk/proof_system/ultra_prover.hpp" | ||
| #include "barretenberg/proof_system/circuit_builder/eccvm/eccvm_circuit_builder.hpp" | ||
| #include "barretenberg/proof_system/circuit_builder/goblin_ultra_circuit_builder.hpp" | ||
| #include "barretenberg/proof_system/circuit_builder/ultra_circuit_builder.hpp" | ||
|
|
||
| namespace test_full_goblin_composer { | ||
|
|
||
| namespace { | ||
| auto& engine = numeric::random::get_debug_engine(); | ||
| } | ||
|
|
||
| class FullGoblinComposerTests : public ::testing::Test { | ||
| protected: | ||
| static void SetUpTestSuite() | ||
| { | ||
| barretenberg::srs::init_crs_factory("../srs_db/ignition"); | ||
| barretenberg::srs::init_grumpkin_crs_factory("../srs_db/grumpkin"); | ||
| } | ||
|
|
||
| using Curve = curve::BN254; | ||
| using FF = Curve::ScalarField; | ||
| using Point = Curve::AffineElement; | ||
| using CommitmentKey = proof_system::honk::pcs::CommitmentKey<Curve>; | ||
| using GoblinUltraBuilder = proof_system::GoblinUltraCircuitBuilder; | ||
| using GoblinUltraComposer = proof_system::honk::GoblinUltraComposer; | ||
| using ECCVMFlavor = proof_system::honk::flavor::ECCVMGrumpkin; | ||
| using ECCVMBuilder = proof_system::ECCVMCircuitBuilder<ECCVMFlavor>; | ||
| using ECCVMComposer = proof_system::honk::ECCVMComposer_<ECCVMFlavor>; | ||
| using VMOp = proof_system_eccvm::VMOperation<ECCVMFlavor::CycleGroup>; | ||
| static constexpr size_t NUM_OP_QUEUE_COLUMNS = proof_system::honk::flavor::GoblinUltra::NUM_WIRES; | ||
|
|
||
| /** | ||
| * @brief Generate a simple test circuit with some ECC op gates and conventional arithmetic gates | ||
| * | ||
| * @param builder | ||
| */ | ||
| void generate_test_circuit(auto& builder) | ||
| { | ||
| // Add some arbitrary ecc op gates | ||
| for (size_t i = 0; i < 3; ++i) { | ||
| auto point = Point::random_element(); | ||
| auto scalar = FF::random_element(); | ||
| builder.queue_ecc_add_accum(point); | ||
| builder.queue_ecc_mul_accum(point, scalar); | ||
| } | ||
| builder.queue_ecc_eq(); | ||
|
|
||
| // Add some conventional gates that utilize public inputs | ||
| for (size_t i = 0; i < 10; ++i) { | ||
| FF a = FF::random_element(); | ||
| FF b = FF::random_element(); | ||
| FF c = FF::random_element(); | ||
| FF 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, FF(1), FF(1), FF(1), FF(-1), FF(0) }); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Mock the interactions of a simple curcuit with the op_queue | ||
| * @details The transcript aggregation protocol in the Goblin proof system can not yet support an empty "previous | ||
| * transcript" (see issue #723). This function mocks the interactions with the op queue of a fictional "first" | ||
| * circuit. This way, when we go to generate a proof over our first "real" circuit, the transcript aggregation | ||
| * protocol can proceed nominally. The mock data is valid in the sense that it can be processed by all stages of | ||
| * Goblin as if it came from a genuine circuit. | ||
| * | ||
| * @param op_queue | ||
| */ | ||
| static void perform_op_queue_interactions_for_mock_first_circuit( | ||
| std::shared_ptr<proof_system::ECCOpQueue>& op_queue) | ||
| { | ||
| auto builder = GoblinUltraBuilder(op_queue); | ||
|
|
||
| // Add a mul accum op and an equality op | ||
| auto point = Point::one() * FF::random_element(); | ||
| auto scalar = FF::random_element(); | ||
| builder.queue_ecc_mul_accum(point, scalar); | ||
| builder.queue_ecc_eq(); | ||
|
|
||
| op_queue->set_size_data(); | ||
|
|
||
| // Manually compute the op queue transcript commitments (which would normally be done by the prover) | ||
| auto crs_factory_ = barretenberg::srs::get_crs_factory(); | ||
| auto commitment_key = CommitmentKey(op_queue->get_current_size(), crs_factory_); | ||
| std::array<Point, NUM_OP_QUEUE_COLUMNS> op_queue_commitments; | ||
| size_t idx = 0; | ||
| for (auto& entry : op_queue->get_aggregate_transcript()) { | ||
| op_queue_commitments[idx++] = commitment_key.commit(entry); | ||
| } | ||
| // Store the commitment data for use by the prover of the next circuit | ||
| op_queue->set_commitment_data(op_queue_commitments); | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Test proof construction/verification for a circuit with ECC op gates, public inputs, and basic arithmetic | ||
| * gates | ||
| * @note We simulate op queue interactions with a previous circuit so the actual circuit under test utilizes an op queue | ||
| * with non-empty 'previous' data. This avoid complications with zero-commitments etc. | ||
| * | ||
| */ | ||
| TEST_F(FullGoblinComposerTests, SimpleCircuit) | ||
| { | ||
| auto op_queue = std::make_shared<proof_system::ECCOpQueue>(); | ||
|
|
||
| // Add mock data to op queue to simulate interaction with a "first" circuit | ||
| perform_op_queue_interactions_for_mock_first_circuit(op_queue); | ||
|
|
||
| // Construct a series of simple Goblin circuits; generate and verify their proofs | ||
| size_t NUM_CIRCUITS = 3; | ||
| for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { | ||
| auto builder = GoblinUltraBuilder(op_queue); | ||
|
|
||
| generate_test_circuit(builder); | ||
|
|
||
| auto composer = GoblinUltraComposer(); | ||
| auto instance = composer.create_instance(builder); | ||
| auto prover = composer.create_prover(instance); | ||
| auto verifier = composer.create_verifier(instance); | ||
| auto proof = prover.construct_proof(); | ||
| bool verified = verifier.verify_proof(proof); | ||
| EXPECT_EQ(verified, true); | ||
| } | ||
|
|
||
| // Construct an ECCVM circuit then generate and verify its proof | ||
| { | ||
| // Instantiate an ECCVM builder with the vm ops stored in the op queue | ||
| auto builder = ECCVMBuilder(op_queue->raw_ops); | ||
|
|
||
| // // Can fiddle with one of the operands to trigger a failure | ||
| // builder.vm_operations[0].z1 *= 2; | ||
Rumata888 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| auto composer = ECCVMComposer(); | ||
| auto prover = composer.create_prover(builder); | ||
| auto proof = prover.construct_proof(); | ||
| auto verifier = composer.create_verifier(builder); | ||
| bool verified = verifier.verify_proof(proof); | ||
| ASSERT_TRUE(verified); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Check that ECCVM verification fails if ECC op queue operands are tampered with | ||
| * | ||
| */ | ||
| TEST_F(FullGoblinComposerTests, SimpleCircuitFailureCase) | ||
| { | ||
| auto op_queue = std::make_shared<proof_system::ECCOpQueue>(); | ||
|
|
||
| // Add mock data to op queue to simulate interaction with a "first" circuit | ||
| perform_op_queue_interactions_for_mock_first_circuit(op_queue); | ||
|
|
||
| // Construct a series of simple Goblin circuits; generate and verify their proofs | ||
| size_t NUM_CIRCUITS = 3; | ||
| for (size_t circuit_idx = 0; circuit_idx < NUM_CIRCUITS; ++circuit_idx) { | ||
| auto builder = GoblinUltraBuilder(op_queue); | ||
|
|
||
| generate_test_circuit(builder); | ||
|
|
||
| auto composer = GoblinUltraComposer(); | ||
| auto instance = composer.create_instance(builder); | ||
| auto prover = composer.create_prover(instance); | ||
| auto verifier = composer.create_verifier(instance); | ||
| auto proof = prover.construct_proof(); | ||
| bool verified = verifier.verify_proof(proof); | ||
| EXPECT_EQ(verified, true); | ||
| } | ||
|
|
||
| // Construct an ECCVM circuit then generate and verify its proof | ||
| { | ||
| // Instantiate an ECCVM builder with the vm ops stored in the op queue | ||
| auto builder = ECCVMBuilder(op_queue->raw_ops); | ||
|
|
||
| // Fiddle with one of the operands to trigger a failure | ||
| builder.vm_operations[0].z1 += 1; | ||
|
|
||
| auto composer = ECCVMComposer(); | ||
| auto prover = composer.create_prover(builder); | ||
| auto proof = prover.construct_proof(); | ||
| auto verifier = composer.create_verifier(builder); | ||
| bool verified = verifier.verify_proof(proof); | ||
| EXPECT_EQ(verified, false); | ||
| } | ||
| } | ||
|
|
||
| } // namespace test_full_goblin_composer | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.