Skip to content

fix: canonicalize duplicate witness terms in R1CS constraints [LA - C]#352

Merged
ashpect merged 1 commit into
v1from
px/fix-duplicate-witness-canonicalization
Mar 26, 2026
Merged

fix: canonicalize duplicate witness terms in R1CS constraints [LA - C]#352
ashpect merged 1 commit into
v1from
px/fix-duplicate-witness-canonicalization

Conversation

@Bisht13
Copy link
Copy Markdown
Collaborator

@Bisht13 Bisht13 commented Mar 20, 2026

Summary

  • Canonicalize linear combinations inside R1CS::add_constraint before inserting into sparse matrices, merging duplicate witness indices (summing coefficients) and dropping zeros
  • Add debug_assert in SparseMatrix::set to catch future regressions in debug builds

Addresses audit issue C (Least Authority, March 2026): duplicate witness terms in R1CS constraints silently overwrite coefficients via SparseMatrix::set, underconstraining the circuit.

Test plan

  • 5 new regression tests in r1cs::tests

@Bisht13 Bisht13 force-pushed the px/fix-duplicate-witness-canonicalization branch 2 times, most recently from ef1eee9 to b1f5edf Compare March 20, 2026 14:35
@ashpect ashpect changed the title fix: canonicalize duplicate witness terms in R1CS constraints [C] fix: canonicalize duplicate witness terms in R1CS constraints [LA - C] Mar 21, 2026
@Bisht13 Bisht13 force-pushed the px/fix-duplicate-witness-canonicalization branch from b1f5edf to b439f0a Compare March 22, 2026 15:24
Comment thread provekit/common/src/sparse_matrix.rs Outdated
@Bisht13 Bisht13 force-pushed the px/fix-duplicate-witness-canonicalization branch from b439f0a to 97b5705 Compare March 23, 2026 12:33
@ashpect ashpect merged commit a1c34b5 into v1 Mar 26, 2026
dcbuild3r pushed a commit that referenced this pull request May 16, 2026
…calization

fix: canonicalize duplicate witness terms in R1CS constraints [LA - C]
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.

3 participants