-
Notifications
You must be signed in to change notification settings - Fork 509
Comments
fix: implement CheckUnconstrainedWires validation#1667
fix: implement CheckUnconstrainedWires validation #1667berZKerk wants to merge 1 commit intoConsensys:master from
Conversation
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
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, scanningInstructionsviaBlueprintR1CandBlueprintSparseR1Cto detect usage.NewHint()stringsimport and usesloggerfor warningsWritten by Cursor Bugbot for commit 8d94665. This will update automatically on new commits. Configure here.