Repository navigation
Description
A chained SHA circuit currently replays through one eager witness generator. Dependency between chaining states serializes the replay even though the native hash computation can determine all those states cheaply.
This issue owns a native chaining-state prepass followed by independent per-compression hint/witness generation and deterministic assembly into the target's established coordinate layout.
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
- Compute states and padding using the same public message-length and SHA semantics as the circuit; validate each generated circuit output against its expected next state.
- Run independent compression jobs with the existing Rayon pool and a serial fallback; keep per-worker ownership local and assemble in compression order.
- Preserve existing input-before-hint ordering unless the repetition work explicitly introduces a reviewed new layout. Coordinate shared constants and boundary aliases with Avoid materialising the global R1CS matrix when the relation is one local circuit repeated over instances #42.
Out of scope: new SHA equations, new public inputs, changing the global thread-pool policy (#48), or parallelizing ECDSA.
Potential impact
The expensive replay portion can benefit from worker parallelism. Native preprocessing, packing, scheduling and any ECDSA tail remain serial or independently bounded, so worker count is not an overall speedup claim. Shard retention may increase peak memory.
Done when
- Serial and parallel generation agree bit-for-bit on witness, products when retained, digest and all boundary states across worker counts.
- Compare complete proof/transcript golden bytes; inject an incorrect prepass state, output or padding block and demonstrate rejection.
- Cover one block, multi-block messages, empty-message padding where supported and non-power-of-two compression counts.
- Profile native prepass, replay, assembly, allocations and peak memory separately on matched shapes and worker counts.
Activity
zkfriendly commentedon Nov 24, 2026
Closing as low impact: after #149, 600-block SHA-256 witness generation already takes only ~10.3 ms (<1% of total prove time). Reopen if much longer SHA chains make witgen measurable.