Allow to owned on coeff sumcheck prover#102
Merged
Merged
Conversation
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.
Summary
Add
finalize(self) -> (Vec<Vec<Vec<F>>>, Vec<Vec<F>>)toCoefficientProverandCoefficientProverLSB, alongside the existing borrow accessors. Lets downstream callers extract the post-sumcheck reduced state by move instead of cloning out of a borrow.Before
CoefficientProver{,LSB}own their working buffers (tablewise: Vec<Vec<Vec<F>>>,pairwise: Vec<Vec<F>>) but expose them only behind&selfaccessors. Callers that have finished sumcheck and need the folded state — to feed a witness, embed in a transcript, hand to a downstream protocol — cannot take it. They must clone:Each
.clone()is a heap allocation plus k field-element copies (k = constraint arity). The pattern itself is a Rust API smell: a borrow returned solely so the caller can immediately clone it back to owned. The library knows the prover won't be used again. The caller knows. The type system can't express "transfer ownership of the post-fold buffers."This isn't unique to one downstream — anyone composing
CoefficientProverLSBinto a larger proof system hits the identical shape (run sumcheck, extract reduced state, feed next phase, drop prover).After
Canonical Rust pattern:
foo(&self) -> &Tfor inspection, consume-and-return for extraction. Single method returning both buffers in a tuple, so callers can't accidentally try to move out the same prover twice:The
&selfaccessors stay — they remain correct for inspection / asserts / debugging mid-sumcheck. Existing call sites compile unchanged.