Repository navigation
Description
Intern public exact-integer coefficients as they are recorded and store compact coefficient IDs on raw edges.
Current behavior and sources
The target deduplicates coefficients when finishing its tape, after raw recording has allocated repeated boxed coefficient values. The final table therefore understates temporary recording memory.
The target's current field profile, relation, index ordering, transcript, and terminal-claim contracts remain authoritative (including #19 and the specification tracked by #2). The current target implementation establishes the behavior to preserve. The PoC implementation reference is an implementation reference, not a replacement protocol specification. Preserve the target arithmetic representations; convert explicitly when crossing between canonical Barrett field elements and tape Montgomery residues.
In scope
- Use a canonical signed-magnitude/equivalent exact-value key while retaining enough declared-width information for correct later embedding.
- Replace raw edge coefficient ownership with checked IDs; preserve deterministic compilation and ensure discarded/dead nodes cannot leave invalid references.
- Reuse the resulting table during final tape construction, avoiding a second independent coefficient-copy path.
Done when
- Compare compiled arithmetic and downstream transcript outputs with the existing recorder for repeated coefficients across widths, zero, ±1 and signed extrema.
- Test hash collisions through equality semantics, invalid IDs at checked construction boundaries, dead-node removal and reproducible tape output.
- Preserve proof messages, Fiat–Shamir absorb/squeeze order, verifier-derived points and final PCS handoff; assert transcript-byte equivalence against the existing implementation for valid inputs.
- Report matched release-build phase timings and named-buffer/peak-memory measurements with fixed field, input, compiler, thread count and proof validation. State regressions and setup amortization separately.
Impact and boundaries
Eliminates repeated recording-time coefficient allocations and reduces raw edge payload. Final tape interning already exists, so this primarily improves setup cost and peak temporary memory. Wall-clock improvement is unmeasured on the target and is not an acceptance assumption.
Out of scope: changing matrix coefficient semantics, general circuit container work in #44, or changing statement digests without an explicit compatibility decision.
Difficulty: medium; urgency: med. Medium priority bounded preprocessing work; exact signed normalization and deterministic graph output make this more than a mechanical container replacement.
Activity
zkfriendly commentedon Nov 24, 2026
Status update (
main34addac): partially mitigated for SHA-256 by #149, which madeStoredInteger(crates/circuit/src/matrix_products.rs:297) store single-word (<= 64-bit) values inline (Words::Inline(u64)), removing per-edge heap allocations for narrow coefficients. Still relevant for multi-limb circuits (P-256) and shrinkingRawTerm(crates/circuit/src/matrix_wengert.rs:45) from a 16-byteStoredIntegerto a compact coefficient ID.zkfriendly commentedon Nov 24, 2026
Closing as premature while Wengert binding is not yet integrated into production Spartan (#90), and already partially mitigated for SHA-256 by inline
StoredIntegerin #149. Referenced from #90.