Skip to content

feat: GKR Add Instance #1504

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

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open

feat: GKR Add Instance #1504

wants to merge 39 commits into from

Conversation

Tabaie
Copy link
Contributor

@Tabaie Tabaie commented Jun 3, 2025

  • Change the GKR API so that defining the circuit and assigning instances are separated. It removes the necessity of defining hints for the output and deferred "finalize" functions.

  • Remove the Println function in favor of GetValue.

  • gkrgates.Register now checks if a gate of the same name has already been registered. If so, it compares the gates and returns an error if they are not equal. If they are equal, it returns false, nil.

  • Remove all logic pertaining to reordering of wires and instances.

  • Unless the user explicitly provides their own initial challenge, automatically use all input and output of the circuit as initial Fiat-Shamir challenge.

  • Rename GkrCompressions to GkrPermutations to correctly reflect its function. (Note: a future PR should implement compressions instead and revert the name change)

  • A benchmark for gkr-poseidon2

@Tabaie Tabaie requested a review from Copilot June 3, 2025 20:27
Copilot

This comment was marked as outdated.

@Tabaie Tabaie marked this pull request as ready for review June 3, 2025 21:05
@Tabaie Tabaie requested review from ivokub and gbotrel June 3, 2025 21:05
@Tabaie Tabaie requested a review from Copilot June 3, 2025 21:15
Copilot

This comment was marked as outdated.

@Tabaie Tabaie requested a review from Copilot June 4, 2025 04:56
Copilot

This comment was marked as outdated.

@Tabaie Tabaie requested a review from Copilot June 4, 2025 13:04
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the GKR API to decouple circuit definition from instance assignment, replaces the Println function with GetValue, and improves gate registration by checking for duplicate definitions and renaming GkrCompressions to GkrPermutations.

  • Separation of circuit definition and instance assignment in the GKR API
  • Removal of Println in favor of GetValue and updates in hint generation functions
  • Enhanced gate registration logic with duplicate checks and more precise error reporting

Reviewed Changes

Copilot reviewed 51 out of 51 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/gkr/bls24-315/gate_testing.go Added EqualGateFunction helper for comparing gate functions
internal/gkr/bls12-381/solver_hints.go Refactored SolvingData with new options and padding strategy
internal/gkr/bls12-381/gkr.go Fixed MulAcc to correctly multiply instead of adding
internal/gkr/bls12-377/solver_hints.go & gkr.go Similar refactoring as in bls12-381 modules
internal/generator/backend/template/* Updated template hints and solver generation to use the new SolvingData
constraint/solver/gkrgates/registry_test.go Modified tests to account for the updated Register API return values
constraint/solver/gkrgates/registry.go Revised Register function to return a (bool, error) tuple and added equality check
constraint/*/solver.go (across multiple curves) Updated solver initialization to use the new gkr.NewSolvingData helper
Comments suppressed due to low confidence (2)

constraint/solver/gkrgates/registry.go:113

  • Consider adding a comment explaining the rationale behind setting curvesForTesting to [ecc.BN254] and allowedCurves to gnark.Curves() when no curves are specified, to improve maintainability.
if len(curvesForTesting) == 0 {

constraint/solver/gkrgates/registry.go:122

  • The updated Register function returns (false, nil) when a gate is already registered. Consider updating the documentation to clearly define this behavior for API consumers.
if g, ok := gates[s.name]; ok {

@Tabaie Tabaie marked this pull request as draft June 5, 2025 22:32
@Tabaie Tabaie linked an issue Jun 5, 2025 that may be closed by this pull request
@Tabaie Tabaie marked this pull request as ready for review June 5, 2025 23:22
@Tabaie Tabaie marked this pull request as draft June 10, 2025 22:03
@Tabaie Tabaie marked this pull request as ready for review June 10, 2025 22:55
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.

Enable the GKR API to add instances
1 participant