Skip to content

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

Open
Bisht13 wants to merge 1 commit intomainfrom
px/fix-duplicate-witness-canonicalization-main
Open

fix: canonicalize duplicate witness terms in R1CS constraints [LA - C]#354
Bisht13 wants to merge 1 commit intomainfrom
px/fix-duplicate-witness-canonicalization-main

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-main branch 2 times, most recently from 1953b68 to f6a4f40 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-main branch from f6a4f40 to af56e43 Compare March 22, 2026 15:24
@Bisht13 Bisht13 force-pushed the px/fix-duplicate-witness-canonicalization-main branch from af56e43 to b48cb38 Compare March 23, 2026 12:33
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.

2 participants