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

Revamps GKR with Compile/AddInstance API and default Fiat–Shamir challenge, adds a reusable hints engine wired into solvers, and hardens gate registration and codegen across curves.

  • GKR API:
    • Introduces API.NewInput, API.Compile (returns *Circuit), and per-instance Circuit.AddInstance; removes old Solve/Println paths.
    • Adds Circuit.GetValue (debug), automatic padding, and default initial Fiat–Shamir challenge (commitment to inputs/outputs) unless provided.
  • Solvers/Hints:
    • New gkrhints engine (GetAssignment, Solve, Prove) and solvers now override these hints for all curves.
    • Generates solver_hints.go and gate_testing.go per curve; fixes MulAcc to multiply.
  • Gate Registry:
    • gkrgates.Register options validate exclusivity, support per-gate curve allowlists, detect and compare duplicate registrations, and expose EqualGateFunction checks; updated tests.
  • Internal Types/Utils:
    • Simplifies gkrinfo.StoringInfo (removes dependency/print logic); CircuitInfoToCircuit sets NbUniqueOutputs and validates curves.
    • Adds helpers (SliceOfRefs, ExtendRepeatLast) and exports ComputeLogNbInstances.
  • Poseidon2 GKR:
    • Renames to GkrCompressor, builds circuit via new API, and adds RegisterGkrGates.
  • Examples/Tests:
    • Updates all examples and tests to new API (per-instance, default FS, GetValue), adds new benchmarks; removes legacy hint/test paths.
  • Docs:
    • Fixes package doc name for log-derivative lookup.

Written by Cursor Bugbot for commit dec4b30. 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
@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