Skip to content

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


Note

Introduce a compile-then-add-instances GKR API with GetValue, enforce gate registry validation (incl. curve support and equality checks), refactor hints/solvers, and update Poseidon2 compressor, generators, and tests.

  • GKR API:
    • Add compile-then-add pattern: API.NewInput, API.Compile, Circuit.AddInstance, and Circuit.GetValue; remove old Solve/Verify flow and Println.
    • Default Fiat–Shamir seed uses commitment to all inputs/outputs unless overridden.
  • Gate Registry (gkrgates):
    • New RegisterOptions with validation; prevent conflicting duplicate registrations by function equality checks; support per-gate allowed curves; add EqualGateFunction.
  • Solvers/Hints:
    • Override hints with new gkrhints engine (GetAssignment, Solve, Prove) across curves; generate-new solver_hints and fix MulAcc to multiply.
  • GKR internals:
    • Gates carry allowed curves; simplify gkrinfo (remove dependency/permutation logic); export ComputeLogNbInstances; add utils SliceOfRefs, ExtendRepeatLast.
  • Poseidon2:
    • Replace GkrCompressions with GkrCompressor; add RegisterGkrGates; adapt circuits/tests.
  • Generator:
    • Include gate_testing.go generation; adjust outputs when not generating test vectors.
  • Examples/Tests:
    • Update examples and unit tests to new API and default challenges; add coverage for single/no-instance cases and gate registration behaviors.

Written by Cursor Bugbot for commit f05b1c1. This will update automatically on new commits. Configure here.

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

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 gbotrel and ivokub June 3, 2025 21:05
@Tabaie Tabaie requested a review from Copilot June 3, 2025 21:15
cursor[bot]

This comment was marked as outdated.

@ivokub ivokub added the feat: gkr PRs related to GKR label Sep 11, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@Tabaie Tabaie requested a review from ivokub October 2, 2025 13:33
c.assignments[wI] = utils.ExtendRepeatLast(c.assignments[wI], nbPaddedInstances)
}
for _, wI := range c.outs {
c.assignments[wI] = utils.ExtendRepeatLast(c.assignments[wI], nbPaddedInstances)
Copy link

Choose a reason for hiding this comment

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

Bug: Intermediate wires not padded in finalize

The padding logic only extends input and output wire assignments to the next power of 2, but intermediate wires are not padded. This creates an inconsistency because the ProveHint calls repeatUntilEnd which pads all wires including intermediate ones. The mismatch between frontend and hint padding could cause the GKR proof verification to fail or produce incorrect results when intermediate wire values are accessed after padding.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat: gkr PRs related to GKR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable the GKR API to add instances

3 participants