small value Neutronnova NIFS prove#127
Open
wu-s-john wants to merge 46 commits into
Open
Conversation
Add support for accumulating field × small_int products (i32, i64, i128) with delayed modular reduction using generic Barrett reduction: - SmallValueField<V> trait for small integer ↔ field conversion - WideMul trait for widening multiplication - BarrettReductionConstants with compile-time computed μ = ⌊2^512/p⌋ - SignedWideLimbs<N> accumulator for signed product sums - DelayedReduction<i32/i64/i128> implementations for all fields
This replaces expensive field multiplications with native integer
arithmetic during the first ℓ₀ rounds when polynomial values are
guaranteed small.
Key components:
Lagrange accumulator infrastructure (src/lagrange_accumulator/):
- LagrangeAccumulators: precomputed A_i(v, u) values for all rounds
- LagrangeIndex/LagrangePoint/LagrangeHatPoint: type-safe domain indices
- LagrangeBasisFactory: barycentric Lagrange basis with O(D) evaluation
- extend_to_lagrange_domain: batch extension from {0,1}^ℓ₀ to U_D^ℓ₀
- EqRoundFactor: tracks α = eq(τ_{<i}, r_{<i}) across rounds
- Csr: compressed sparse row storage (2 allocations vs N+1 for Vec<Vec>)
Performance optimizations:
- Thread-local SpartanThreadState eliminates per-iteration allocations
- Delayed modular reduction via SignedWideLimbs accumulators
- Skip binary betas (Az·Bz = Cz on {0,1}^n for satisfying witnesses)
- Batched eq-weighted binding in transition phase
API:
- SmallValue trait: WideMul + Copy + Zero + Add + Sub + Send + Sync
- SmallValueEngine<SV>: blanket impl consolidates field requirements
- prove_cubic_small_value<E, SV, const LB>: main entry point
The prove_cubic_small_value function produces identical proofs to the
standard prove_cubic_with_three_inputs, verified via equivalence tests.
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.
Small-Value NeutronNova NIFS Integration
Implement small-value NeutronNova NIFS support and integrate it into the NeutronNova ZK prover.
This PR adds backend-selectable NeutronNova NIFS proving. The regular NeutronNova path remains available, including an optional round-0 small-value optimization, and a new
SmallValueNeutronNovaNIFSbackend uses the generalized small-value accumulator for the firstL0NIFS rounds before continuing through the existing verifier-circuit transcript flow.What changed
NeutronNovaNifsStrategy, makingNeutronNovaZkSNARKgeneric over the NIFS backend.NeutronNovaNIFS<Input = bool>:false: full field pathtrue: regular NeutronNova with round-0 small A/B/C optimizationSmallValueNeutronNovaNIFS<E, SV, L0>:L0roundsi64andi32small-value backendsFieldStepMLEsSmallAbStepMLEsSmallAbcStepMLEsNeutronNovaStepMLEsSmallValueNeutronNovaStepMLEssrc/polys/outer_mles.rs.i64,L0 = 3i32,L0 = 3Files to check
Start with these:
src/neutronnova_zk.rsNeutronNovaNifsStrategyNeutronNovaZkSNARK<E, Nifs>NeutronNovaNIFSfull-field and round-0-small pathssrc/small_neutronnova.rsSmallValueNeutronNovaNIFSsrc/lagrange_accumulator/accumulator_builder.rssrc/polys/outer_mles.rsThen check supporting changes:
src/lagrange_accumulator/extension_bound.rssrc/lagrange_accumulator/extension.rssrc/lagrange_accumulator/thread_state.rssrc/small_sumcheck.rssrc/big_num/delayed_reduction.rsBench / validation:
benches/sha256_neutronnova.rsLight skim:
src/lagrange_accumulator/mod.rssrc/big_num/mod.rssrc/polys/mod.rssrc/polys/multilinear.rssrc/lib.rs