Skip to content
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

feat: Add Goblin Ultra Circuit builder #587

Merged
merged 9 commits into from
Jul 19, 2023
Merged

Conversation

ledwards2225
Copy link
Collaborator

@ledwards2225 ledwards2225 commented Jul 7, 2023

Description

Initial conception of the Ultra Goblin Circuit Builder.

The Goblin builder extends the existing Ultra builder. For now I've implemented the new methods directly in the existing UltraCircuitBuilder. So essentially the UltraCircuitBuilder now is the Goblin Ultra circuit builder.

This work essentially adds three components on top of the Ultra builder: 1) An op_queue that stores the ecc operations in a raw form, e.g. {op, point, scalar}, and also computes the corresponding operations natively behind the scenes, 2) op_wires which are similar to the existing wires object but are used to store the values in the "ecc op gates", and 3) methods like queue_ecc_mul_accum() and queue_ecc_add_accum() which update both the op_queue and the op_wires accordingly.

I've included some tests that check the underlying native ECC operations in the op queue, the consistency of the values written to the op_wires by the builder, and some checks of higher level functionality like batch_mul().

There are lot's of small TODOs to be addressed in the coming weeks.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • The branch has been merged with/rebased against the head of its merge target.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • There are no circuit changes, OR a cryptographer has been assigned for review.
  • New functions, classes, etc. have been documented according to the doxygen comment format. Classes and structs must have @brief describing the intended functionality.
  • If existing code has been modified, such documentation has been added or updated.
  • No superfluous include directives have been added.
  • I have linked to any issue(s) it resolves.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@kevaundray kevaundray changed the title Lde/goblin builder feat: Add Goblin Ultra Circuit builder Jul 7, 2023
@ledwards2225 ledwards2225 marked this pull request as ready for review July 18, 2023 17:31
@ledwards2225 ledwards2225 requested a review from Rumata888 July 18, 2023 17:57
@ledwards2225 ledwards2225 linked an issue Jul 18, 2023 that may be closed by this pull request
@@ -11,4 +11,30 @@ TEST(ECCOpQueueTest, Basic)
EXPECT_EQ(op_queue.raw_ops[1].add, false);
}

TEST(ECCOpQueueTest, Accumulator)
Copy link
Contributor

@Rumata888 Rumata888 Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what the test is supposed to test from the name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to InternalAccumulatorCorrectness

* @param expected
* @return whether accumulator point == expected point
*/
bool eq(const Point& expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This interface forces us to always redo this computation. First you need to compute the value externally, then the same value is computed in OpQueue. What do you think of making the return value the point and having no argument to the function? Then we can check the value correctness in tests

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this so that instead of calling get_accumulator() explicitly, the equality op implicitly uses used the internal accumulator and that value is returned when calling queue_ecc_eq() for use elsewhere in the circuit if necessary.

Copy link
Contributor

@Rumata888 Rumata888 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ledwards2225 ledwards2225 merged commit 2d38c25 into master Jul 19, 2023
@ledwards2225 ledwards2225 deleted the lde/goblin_builder branch July 19, 2023 15:15
ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 22, 2023
Co-authored-by: codygunton <codygunton@gmail.com>
ludamad pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jul 24, 2023
Co-authored-by: codygunton <codygunton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ultra Goblin Circuit Builder
3 participants