Skip to content

Conversation

@berZKerk
Copy link

@berZKerk berZKerk commented Dec 24, 2025

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant