Repository navigation
Description
Circuit output matrices retain per-row vectors and arbitrary-precision coefficient objects, while later consumers construct separate compact representations. The target already has a compact Boolean M-transpose.
This issue owns migrating the finished circuit matrices and their consumers onto the canonical sparse core. It does not reimplement the core requested in #20 or the temporary expression accumulators requested in #44.
Sources
The target repository's existing relation, field encoding, coordinate order, and transcript contracts are authoritative. The current target implementation determines compatibility; the PoC implementation is reference-only and must be re-derived against those contracts.
In scope
- Integrate Sparse matrix core: reusable matrix operations for PIOP (Spartan) #20's reviewed representation, preserving row/column order, duplicate handling and matrix-digest encoding. Do not create another competing sparse crate or arithmetic-trait hierarchy.
- Support width-segmented exact coefficients and implicit-one Boolean entries without allocating one coefficient object per nonzero.
- Reuse validated topology across row traversal, transpose views and downstream preparation; document where physical reordering still requires an allocation.
Out of scope: replacing BTreeMap/BTreeSet expression accumulators (#44), changing relation geometry, or rewriting Spartan/GKR protocols.
Potential impact
Flattening finished storage removes row-local owners and repeated representation copies. Implicit Boolean coefficients save coefficient payload. Compare the complete lifecycle: keeping CSR and CSC copies simultaneously can offset these savings.
Done when
- All required Sparse matrix core: reusable matrix operations for PIOP (Spartan) #20 operations remain correct; cross-check products, transposes and bilinear evaluations against existing matrices on signed and Boolean cases.
- Reject malformed offsets, out-of-range columns, index overflow and inconsistent coefficient counts; preserve the target's canonicalization policy.
- Matrix digests, witness order, proof bytes and transcript goldens are identical for unchanged relations; existing negative proof tests continue to reject.
- Report setup time, allocations and peak/live matrix bytes for SHA and P-256, with consumer conversion costs included.
Activity
zkfriendly commentedon Nov 24, 2026
Status update (
main34addac): partially implemented by #141 and #151.crates/spartan/src/matrix.rsalready flattensA/B/Cinto CSR (Positions { row_starts, columns }+ interned coefficients), and #151 narrowed SHA-256 coefficients toi64and closed #44. Remaining scope is flatteningSparseMatrix<C>andSparseBoolMatrixincrates/circuit/src/constraints.rs(stillVec<SparseRow<C>>per-row allocations). Note #20 is now closed/superseded.zkfriendly commentedon Nov 24, 2026
Closing as out of current focus: circuit R1CS matrix storage refactor; current focus is on the BitZ PCS.