Optimizations: ROM Fusion, Spread Multiset Fusion & Constant Spread Path#297
Open
Optimizations: ROM Fusion, Spread Multiset Fusion & Constant Spread Path#297
Conversation
added 3 commits
February 22, 2026 01:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ROM Table Constraint Fusion (
rom.rs)Added
add_indexed_table_entry_quotient()replacing the oldadd_indexed_lookup_factor()+add_product()pattern.Before:
(denominator definition + denom × inverse = 1 + mult × inverse = quotient)
After:
(denominator definition + fused denom × quotient = mult)
The inverse witness is still created for batch inversion but is no longer separately constrained.
Soundness holds since
denom × quotient = multuniquely impliesquotient = mult / denomin the field.Spread Table Multiset Fusion (
spread.rs)Replaced two
add_sum()calls + grand sum equality with a single fused A-vector constraint (same pattern asadd_range_check_via_lookup()).Before:
After:
((Σ table_quotients − Σ query_inverses) × 1 = 0)Savings: 2 witnesses + 2 constraints per spread table instance.
Updated cost model:
2 × 2^w + 4 → 2 × 2^w + 2decompose_constant_to_spread_word— Constant-Path Spread DecompositionPreviously, spread decomposition panicked for constant witnesses.
Now constants (e.g. SHA256 IV
H[0]..H[7]) are handled via a dedicated compile-time path:Saves ~3 spread table lookups per constant
(no multiplicity / inverse / quotient witnesses)
Soundness
packed_witness = constant_valueinside the function, preventing under-constrained usage