binius_core/protocols/sumcheck/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Copyright 2024 Irreducible Inc.

use crate::{
	oracle::Error as OracleError, polynomial::Error as PolynomialError,
	witness::Error as WitnessError,
};

#[derive(Debug, thiserror::Error)]
pub enum Error {
	#[error(
		"composition polynomial has an incorrect number of variables, expected {expected_n_vars}"
	)]
	InvalidComposition { expected_n_vars: usize },
	#[error("claims must be sorted in descending order by number of variables")]
	ClaimsOutOfOrder,
	#[error("expected call to execute")]
	ExpectedFinish,
	#[error("expected call to execute")]
	ExpectedExecution,
	#[error("expected call to fold")]
	ExpectedFold,
	#[error("the number of variables for the prover multilinears must all be equal")]
	NumberOfVariablesMismatch,
	#[error(
		"ProverState::execute called with incorrect number of evaluators, expected {expected}"
	)]
	IncorrectNumberOfEvaluators { expected: usize },
	#[error("sumcheck naive witness validation failed: composition index {composition_index}")]
	SumcheckNaiveValidationFailure { composition_index: usize },
	#[error("zerocheck naive witness validation failed: composition index {composition_index}, vertex index {vertex_index}")]
	ZerocheckNaiveValidationFailure {
		composition_index: usize,
		vertex_index: usize,
	},
	#[error("nonzerocheck naive witness validation failed: oracle {oracle}, hypercube index {hypercube_index}")]
	NonzerocheckNaiveValidationFailure {
		oracle: String,
		hypercube_index: usize,
	},
	#[error("constraint set containts multilinears of different heights")]
	ConstraintSetNumberOfVariablesMismatch,
	#[error("batching sumchecks and zerochecks is not supported yet")]
	MixedBatchingNotSupported,
	#[error("base field and extension field constraint sets don't match")]
	BaseAndExtensionFieldConstraintSetsMismatch,
	#[error("some multilinear evals cannot be embedded into base field in the first round")]
	MultilinearEvalsCannotBeEmbeddedInBaseField,
	#[error("zerocheck challenges number does not equal number of variables")]
	IncorrectZerocheckChallengesLength,
	#[error("number of specified multilinears and switchover rounds does not match")]
	MultilinearSwitchoverSizeMismatch,
	#[error("incorrect size of the partially evaluated zerocheck equality indicator")]
	IncorrectZerocheckPartialEqIndSize,
	#[error(
		"the number of prime polynomial sums does not match the number of zerocheck compositions"
	)]
	IncorrectClaimedPrimeSumsLength,
	#[error("batch proof shape does not conform to the provided indexed claims")]
	ClaimProofMismatch,
	#[error("either too many or too few sumcheck challenges")]
	IncorrectNumberOfChallenges,
	#[error("cannot skip more rounds than the total number of variables")]
	TooManySkippedRounds,
	#[error("there are more prebatched coefficients than claims")]
	TooManyPrebatchedCoeffs,
	#[error(
		"specified Lagrange evaluation domain is too small to uniquely recover round polynomial"
	)]
	LagrangeDomainTooSmall,
	#[error("adding together Lagrange basis evaluations over domains of different sizes")]
	LagrangeRoundEvalsSizeMismatch,
	#[error("length of the zero prefix does not match the expected value")]
	IncorrectZerosPrefixLen,
	#[error("oracle error: {0}")]
	Oracle(#[from] OracleError),
	#[error("witness error: {0}")]
	Witness(#[from] WitnessError),
	#[error("polynomial error: {0}")]
	Polynomial(#[from] PolynomialError),
	#[error("verification failure: {0}")]
	Verification(#[from] VerificationError),
	#[error("ntt error: {0}")]
	NttError(#[from] binius_ntt::Error),
	#[error("math error: {0}")]
	MathError(#[from] binius_math::Error),
	#[error("HAL error: {0}")]
	HalError(#[from] binius_hal::Error),
	#[error("Transcript error: {0}")]
	TranscriptError(#[from] crate::transcript::Error),
}

#[derive(Debug, thiserror::Error)]
pub enum VerificationError {
	#[error("number of coefficients in round {round} proof is incorrect, expected {expected}")]
	NumberOfCoefficients { round: usize, expected: usize },
	#[error("incorrect number of rounds")]
	NumberOfRounds,
	#[error("the number of final evaluations must match the number of instances")]
	NumberOfFinalEvaluations,
	#[error("the final batch composite evaluation is incorrect")]
	IncorrectBatchEvaluation,
	#[error("the proof contains an incorrect evaluation of the eq indicator")]
	IncorrectEqIndEvaluation,
	#[error(
		"the proof contains an incorrect Lagrange coefficients multilinear extension evaluation"
	)]
	IncorrectLagrangeMultilinearEvaluation,
	#[error("skipped rounds count is more than the number of variables in a univariate claim")]
	IncorrectSkippedRoundsCount,
	#[error("zero eval prefix does not match the skipped variables of the smaller univariate multinears")]
	IncorrectZerosPrefixLen,
	#[error("non-zero Lagrange evals count does not match expected univariate domain size")]
	IncorrectLagrangeRoundEvalsLen,
	#[error("claimed multilinear evaluations do not match univariate round at challenge point")]
	ClaimedSumRoundEvalsMismatch,
}