binius_hal/
sumcheck_evaluator.rs

1// Copyright 2024-2025 Irreducible Inc.
2
3use std::ops::Range;
4
5use binius_field::{Field, PackedField};
6use binius_math::RowsBatchRef;
7
8/// Evaluations of a polynomial at a set of evaluation points.
9#[derive(Debug, Clone)]
10pub struct RoundEvals<F: Field>(pub Vec<F>);
11
12pub trait SumcheckEvaluator<P: PackedField, Composition> {
13	/// The range of eval point indices over which composition evaluation and summation should
14	/// happen. Returned range must equal the result of `n_round_evals()` in length.
15	fn eval_point_indices(&self) -> Range<usize>;
16
17	/// Compute composition evals over a subcube.
18	///
19	/// `batch_query` should contain multilinears evals over a subcube represented
20	/// by `subcube_vars` and `subcube_index`.
21	///
22	/// See doc comments to [EvaluationDomain](binius_math::EvaluationDomain) for the intuition
23	/// behind `is_infinity_point`.
24	///
25	/// Returns a packed sum (which may be spread across scalars).
26	fn process_subcube_at_eval_point(
27		&self,
28		subcube_vars: usize,
29		subcube_index: usize,
30		is_infinity_point: bool,
31		batch_query: &RowsBatchRef<P>,
32	) -> P;
33
34	/// Compute sum of evals over the suffix where the composite is guaranteed to evaluate to a
35	/// constant.
36	///
37	/// It is assumed that all required inputs are known at the evaluator creation time, as
38	/// `const_eval_suffix` is determined dynamically by the sumcheck round calculator and may be
39	/// _smaller_ than the return value of the method with the same name.
40	///
41	/// See doc comments to [EvaluationDomain](binius_math::EvaluationDomain) for the intuition
42	/// behind `is_infinity_point`.
43	fn process_constant_eval_suffix(
44		&self,
45		_const_eval_suffix: usize,
46		_is_infinity_point: bool,
47	) -> P::Scalar {
48		P::Scalar::ZERO
49	}
50
51	/// Returns the composition evaluated by this object.
52	fn composition(&self) -> &Composition;
53
54	/// In case of zerocheck returns eq_ind that the results should be folded with.
55	/// In case of sumcheck returns None.
56	fn eq_ind_partial_eval(&self) -> Option<&[P]>;
57
58	/// Trace suffix where the composite is guaranteed to evaluate to a constant. The non-constant
59	/// prefix would get processed via `process_subcube_at_eval_point`, whereas the remainder gets
60	/// handled via `process_constant_eval_suffix`. Due to the fact that sumcheck operates over
61	/// whole subcubes the `const_eval_suffix` passed to `process_constant_eval_suffix` may be
62	/// _smaller_ that the return value of this method.
63	fn const_eval_suffix(&self) -> usize {
64		0
65	}
66}