Skip to content

small value Neutronnova NIFS prove#127

Open
wu-s-john wants to merge 46 commits into
microsoft:mainfrom
wu-s-john:neutronnova-small-value-sumcheck
Open

small value Neutronnova NIFS prove#127
wu-s-john wants to merge 46 commits into
microsoft:mainfrom
wu-s-john:neutronnova-small-value-sumcheck

Conversation

@wu-s-john

@wu-s-john wu-s-john commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Small-Value NeutronNova NIFS Integration

Note: This PR builds on the small-value sumcheck work from #112. The main review target is the NeutronNova integration layer on top of that work. Please start with the Files to check section below.

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 SmallValueNeutronNovaNIFS backend uses the generalized small-value accumulator for the first L0 NIFS rounds before continuing through the existing verifier-circuit transcript flow.

What changed

  • Added NeutronNovaNifsStrategy, making NeutronNovaZkSNARK generic over the NIFS backend.
  • Integrated two NeutronNova NIFS strategies:
    • NeutronNovaNIFS<Input = bool>:
      • false: full field path
      • true: regular NeutronNova with round-0 small A/B/C optimization
    • SmallValueNeutronNovaNIFS<E, SV, L0>:
      • certified small-value accumulator path for the first L0 rounds
      • supports both i64 and i32 small-value backends
  • Replaced ad hoc step matvec caches with shared MLE cache types:
    • FieldStepMLEs
    • SmallAbStepMLEs
    • SmallAbcStepMLEs
    • NeutronNovaStepMLEs
    • SmallValueNeutronNovaStepMLEs
  • Added small-value NeutronNova proving logic:
    • certified small A/B/C construction from field MLEs
    • prefix materialization
    • scalar C-claim suffix folding
    • final folded A/B/C output
    • folded witness/instance output after the transcript is fixed
  • Generalized the Lagrange accumulator builder so it supports NeutronNova's small-value A/B accumulator, including sparse field corrections for large positions.
  • Restored regular NeutronNova performance behavior:
    • full-field mode keeps the materialized C suffix path
    • optimized regular mode uses small A/B/C claims where intended
  • Consolidated field-to-small conversion and delayed-reduction helpers.
  • Added shared outer-MLE container types in src/polys/outer_mles.rs.
  • Updated the SHA-256 NeutronNova bench to compare:
    • regular field
    • regular round-0 small
    • small-value i64, L0 = 3
    • small-value i32, L0 = 3

Files to check

Start with these:

  • src/neutronnova_zk.rs

    • NeutronNovaNifsStrategy
    • generic NeutronNovaZkSNARK<E, Nifs>
    • regular NeutronNovaNIFS full-field and round-0-small paths
    • shared NIFS transcript/folding helpers
  • src/small_neutronnova.rs

    • SmallValueNeutronNovaNIFS
    • certified small A/B/C cache construction
    • small-value NeutronNova proving flow
    • prefix materialization and suffix continuation
  • src/lagrange_accumulator/accumulator_builder.rs

    • NeutronNova small-value accumulator construction
    • large-position field correction handling
    • shared prefix-extension traversal
  • src/polys/outer_mles.rs

    • shared field and small step-MLE cache structs

Then check supporting changes:

  • src/lagrange_accumulator/extension_bound.rs

    • field-to-small conversion helpers
    • extension-bound certification used by small-value MLEs
  • src/lagrange_accumulator/extension.rs

    • generalized prefix gather/extension helpers
  • src/lagrange_accumulator/thread_state.rs

    • shared prefix-extension scratch state
  • src/small_sumcheck.rs

    • small-value sumcheck integration with the generalized accumulator/certificate naming
  • src/big_num/delayed_reduction.rs

    • delayed-reduction support used by small NeutronNova accumulation

Bench / validation:

  • benches/sha256_neutronnova.rs
    • four-backend SHA-256 benchmark comparison

Light skim:

  • src/lagrange_accumulator/mod.rs
  • src/big_num/mod.rs
  • src/polys/mod.rs
  • src/polys/multilinear.rs
  • src/lib.rs

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.
@wu-s-john wu-s-john changed the title Neutronnova small value sumcheck small value Neutronnova NIFS Jun 16, 2026
@wu-s-john wu-s-john changed the title small value Neutronnova NIFS small value Neutronnova NIFS prove Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant