binius_core/protocols/sumcheck/
error.rs1use crate::{
4 oracle::Error as OracleError, polynomial::Error as PolynomialError,
5 witness::Error as WitnessError,
6};
7
8#[derive(Debug, thiserror::Error)]
9pub enum Error {
10 #[error(
11 "composition polynomial has an incorrect number of variables; expected {expected}, got {actual}"
12 )]
13 InvalidComposition { actual: usize, expected: usize },
14 #[error("claims must be sorted by number of variables")]
15 ClaimsOutOfOrder,
16 #[error("claims have inconsistent evaluation orders")]
17 InconsistentEvaluationOrder,
18 #[error("failed to downcast a composition expression into a subfield expression")]
19 CircuitFieldDowncastFailed,
20 #[error("expected a call to try_finish_claim")]
21 ExpectedFinishClaim,
22 #[error("expected a call to finish_round")]
23 ExpectedFinishRound,
24 #[error("expected a call to receive_coeffs")]
25 ExpectedReceiveCoeffs,
26 #[error("expected call to finish")]
27 ExpectedFinish,
28 #[error("expected call to execute")]
29 ExpectedExecution,
30 #[error("expected call to fold")]
31 ExpectedFold,
32 #[error("the number of variables for the prover multilinears must all be equal")]
33 NumberOfVariablesMismatch,
34 #[error(
35 "ProverState::execute called with incorrect number of evaluators, expected {expected}"
36 )]
37 IncorrectNumberOfEvaluators { expected: usize },
38 #[error("sumcheck naive witness validation failed: composition index {composition_index}")]
39 SumcheckNaiveValidationFailure { composition_index: usize },
40 #[error("zerocheck naive witness validation failed: {composition_name}, vertex index {vertex_index}")]
41 ZerocheckNaiveValidationFailure {
42 composition_name: String,
43 vertex_index: usize,
44 },
45 #[error("nonzerocheck naive witness validation failed: oracle {oracle}, hypercube index {hypercube_index}")]
46 NonzerocheckNaiveValidationFailure {
47 oracle: String,
48 hypercube_index: usize,
49 },
50 #[error("evaluation domain should start with zero and one, and contain Karatsuba infinity for degrees above 1")]
51 IncorrectSumcheckEvaluationDomain,
52 #[error("evaluation domains are not proper prefixes of each other")]
53 NonProperPrefixEvaluationDomain,
54 #[error("constraint set contains multilinears of different heights")]
55 ConstraintSetNumberOfVariablesMismatch,
56 #[error("batching sumchecks and zerochecks is not supported yet")]
57 MixedBatchingNotSupported,
58 #[error("base field and extension field constraint sets don't match")]
59 BaseAndExtensionFieldConstraintSetsMismatch,
60 #[error("some multilinear evals cannot be embedded into base field in the first round")]
61 MultilinearEvalsCannotBeEmbeddedInBaseField,
62 #[error("zerocheck challenges number does not equal number of variables")]
63 IncorrectZerocheckChallengesLength,
64 #[error("number of specified multilinears and switchover rounds does not match")]
65 MultilinearSwitchoverSizeMismatch,
66 #[error("incorrect size of the partially evaluated zerocheck equality indicator")]
67 IncorrectZerocheckPartialEqIndSize,
68 #[error(
69 "the number of prime polynomial sums does not match the number of zerocheck compositions"
70 )]
71 IncorrectClaimedPrimeSumsLength,
72 #[error("batch proof shape does not conform to the provided indexed claims")]
73 ClaimProofMismatch,
74 #[error("either too many or too few sumcheck challenges")]
75 IncorrectNumberOfChallenges,
76 #[error("cannot skip more rounds than the total number of variables")]
77 TooManySkippedRounds,
78 #[error("there are more prebatched coefficients than claims")]
79 TooManyPrebatchedCoeffs,
80 #[error(
81 "specified Lagrange evaluation domain is too small to uniquely recover round polynomial"
82 )]
83 LagrangeDomainTooSmall,
84 #[error("adding together Lagrange basis evaluations over domains of different sizes")]
85 LagrangeRoundEvalsSizeMismatch,
86 #[error("length of the zero prefix does not match the expected value")]
87 IncorrectZerosPrefixLen,
88 #[error("oracle error: {0}")]
89 Oracle(#[from] OracleError),
90 #[error("witness error: {0}")]
91 Witness(#[from] WitnessError),
92 #[error("polynomial error: {0}")]
93 Polynomial(#[from] PolynomialError),
94 #[error("verification failure: {0}")]
95 Verification(#[from] VerificationError),
96 #[error("ntt error: {0}")]
97 NttError(#[from] binius_ntt::Error),
98 #[error("math error: {0}")]
99 MathError(#[from] binius_math::Error),
100 #[error("HAL error: {0}")]
101 HalError(#[from] binius_hal::Error),
102 #[error("Transcript error: {0}")]
103 TranscriptError(#[from] crate::transcript::Error),
104}
105
106#[derive(Debug, thiserror::Error)]
107pub enum VerificationError {
108 #[error("number of coefficients in round {round} proof is incorrect, expected {expected}")]
109 NumberOfCoefficients { round: usize, expected: usize },
110 #[error("incorrect number of rounds")]
111 NumberOfRounds,
112 #[error("the number of final evaluations must match the number of instances")]
113 NumberOfFinalEvaluations,
114 #[error("the final batch composite evaluation is incorrect")]
115 IncorrectBatchEvaluation,
116 #[error("the proof contains an incorrect evaluation of the eq indicator")]
117 IncorrectEqIndEvaluation,
118 #[error(
119 "the proof contains an incorrect Lagrange coefficients multilinear extension evaluation"
120 )]
121 IncorrectLagrangeMultilinearEvaluation,
122 #[error("skipped rounds count is more than the number of variables in a univariate claim")]
123 IncorrectSkippedRoundsCount,
124 #[error("zero eval prefix does not match the skipped variables of the smaller univariate multinears")]
125 IncorrectZerosPrefixLen,
126 #[error("non-zero Lagrange evals count does not match expected univariate domain size")]
127 IncorrectLagrangeRoundEvalsLen,
128 #[error("claimed multilinear evaluations do not match univariate round at challenge point")]
129 ClaimedSumRoundEvalsMismatch,
130}