Tidy up sumcheck RoundCoeffs/RoundProof and add tests#1765
Open
tcoratger wants to merge 1 commit into
Open
Conversation
Unify the trait bounds on the round-polynomial helpers around FieldOps. The endpoint helpers, the arithmetic operators, and the iterator Sum used a narrower Field bound, while evaluate and recover (and the mlecheck twin) already required FieldOps. That seam meant a round polynomial over a packed field could be evaluated but not added or scaled. Everything now lives on FieldOps, matching what the abstraction was built for, with no caller change. Fix an over-constrained Default: the derive demanded F: Default even though the type just wraps a Vec, which is always Default. A manual impl makes both types Default for every F (also required once the bound moved to FieldOps, which does not imply Default). Extract a private endpoints() helper to remove the duplicated (R(0), R(1)) prologue, drop a redundant where-bound on recover, add an as_slice accessor to retire the self.0.0 double-tuple, and document the two silent contracts (truncate's non-empty precondition and why recover subtracts the constant term twice so the identity holds over any field, not only characteristic 2). Add the module's first tests: recover round-trip, the R(0)+R(1)=s identity, both endpoint helpers, ragged-length addition, scaling, iterator Sum, and the empty/zero-polynomial edge case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Cleans up the sumcheck round-polynomial helpers and gives the module its first tests.
Pure refactor — no protocol change, no behavior change at any call site.
The problem
RoundCoeffs/RoundProofare the round-polynomial types the sumcheck and MLE-check verifiers use.Their methods were split across three different trait bounds with no stated reason:
evaluateandrecoverrequiredFieldOps.Add/Mul/Sumoperators required the narrowerField.The only thing the narrower bound bought was
Copy.So a round polynomial over a packed field could be evaluated but not added or scaled — an arbitrary, undocumented restriction, and a seam inconsistent with the
mlechecktwin which already commits toFieldOps.Two smaller issues rode along:
Defaultdemanded$F$: Defaulteven though the type just wraps aVec, which is alwaysDefault.mlechecksibling tests the same round-trip.The idea
Unify every method on
FieldOps— the more general bound the abstraction was built for (packed and symbolic fields), and the oneevaluate/recoveralready require.$F$: Fieldstill satisfies$F$: FieldOpsvia the blanket impl, so every existing scalar call site is unaffected.The change
impl<F> Defaulton both types, so they areDefaultfor every$F$(also required once the bound moved toFieldOps, which does not implyDefault).endpoints() -> (F, F)to remove the duplicated(R(0), R(1))prologue shared by the two endpoint helpers.where F: FieldOpsonrecover; added anas_sliceaccessor to retire theself.0.0double-tuple incoeffs.truncate's non-empty precondition, and whyrecoversubtracts the constant term twice (the two copies cancel in characteristic 2 but keep the identity correct over any field).Soundness
Nothing changes on the wire.
The bound widening is a pure generalization — every scalar caller resolves to the identical code.
The
recoverarithmetic is byte-for-byte the same; only its doc and a redundant bound changed.Scope
crates/ip/src/sumcheck/common.rsonly.testsmodule (8 tests) —recoverround-trip, thes = R(0) + R(1)identity, both endpoint helpers, ragged-length addition, scaling, iteratorSum, and the empty/zero-polynomial edge case.mlechecktwin (itstruncateAPI-shape divergence is left for a separate change).Verification
cargo check -p binius-ip --all-targets— clean.cargo clippy -p binius-ip— clean.cargo +nightly fmt --all— clean.cargo test -p binius-ip -p binius-ip-prover— 70 passed, 0 failed (8 new).Note:
cargo check --workspace --all-targetscurrently fails on an unrelated pre-existing error incrates/ip/src/channel.rs(call_nativeonFieldFn) that reproduces on a cleanmainunder full-workspace feature unification — it is not introduced by this PR.🤖 Generated with Claude Code