Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

fix: implement CheckUnconstrainedWires validation#1667

Open
berZKerk wants to merge 1 commit intoConsensys:master from
berZKerk:fix/implement-check-unconstrained-wires
Open

fix: implement CheckUnconstrainedWires validation #1667
berZKerk wants to merge 1 commit intoConsensys:master from
berZKerk:fix/implement-check-unconstrained-wires

Conversation

@berZKerk
Copy link

@berZKerk berZKerk commented Dec 24, 2025
edited by cursor bot
Loading

Implements CheckUnconstrainedWires method that was previously a stub.

The method now validates that all input wires (public and secret) are constrained in at least one constraint, and checks that hint output wires are used in the constraint system. Unconstrained inputs return an error, while unconstrained hints only log a warning (matching the old implementation behavior).

Supports both R1CS and SparseR1CS constraint systems using the new Instructions/Blueprints architecture.


Note

Implements input/hint validation in CheckUnconstrainedWires, scanning Instructions via BlueprintR1C and BlueprintSparseR1C to detect usage.

  • Errors when no inputs are defined or when public/secret inputs are unconstrained; includes input names in the message
  • Warns (does not fail) for unconstrained hint output wires created via NewHint()
  • Early exits once all inputs and hint wires are accounted for; ignores zero coefficients when walking expressions
  • Minor plumbing: adds strings import and uses logger for warnings

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

if nbInputs > 0 {
inputConstrained[0] = true // wire 0 is constant ONE
}
cptInputs := nbInputs - 1 // count unconstrained inputs (excluding wire 0)
Copy link

@cursor cursor bot Dec 24, 2025

Choose a reason for hiding this comment

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

Wire 0 incorrectly skipped for SparseR1CS systems

The new unified CheckUnconstrainedWires implementation unconditionally marks wire 0 as constrained with the assumption that it's always the constant ONE. However, this is only true for R1CS systems where the frontend explicitly adds AddPublicVariable("1") at initialization. For SparseR1CS (Plonk) systems, wire 0 is the first user-defined public variable and must be validated for constraints. The old commented-out implementations in r1cs.go and r1cs_sparse.go handled this correctly - R1CS skipped wire 0 (cptInputs = len - 1) while SparseR1CS checked all inputs (cptInputs = len). The fix requires checking system.Type == SystemR1CS before skipping wire 0.

Fix in Cursor Fix in Web

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

Reviewers

@cursor cursor[bot] cursor[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /