binius_core/protocols/evalcheck/
error.rs1use binius_field::TowerField;
4
5use crate::{
6 oracle::{CompositePolyOracle, Error as OracleError, OracleId},
7 polynomial::Error as PolynomialError,
8};
9
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("witness is unable to evaluate multilinear with ID: {0}")]
13 InvalidWitness(OracleId),
14 #[error("missing query")]
15 MissingQuery,
16 #[error("oracle error: {0}")]
17 Oracle(#[from] OracleError),
18 #[error("polynomial error: {0}")]
19 Polynomial(#[from] PolynomialError),
20 #[error("verification failure: {0}")]
21 Verification(#[from] VerificationError),
22 #[error("witness error: {0}")]
23 Witness(#[from] crate::witness::Error),
24 #[error("sumcheck error: {0}")]
25 Sumcheck(#[from] crate::protocols::sumcheck::Error),
26 #[error("HAL error: {0}")]
27 HalError(#[from] binius_hal::Error),
28 #[error("Math error: {0}")]
29 MathError(#[from] binius_math::Error),
30 #[error("Evalcheck serialization error")]
31 EvalcheckSerializationError,
32 #[error("transcript error: {0}")]
33 TranscriptError(#[from] crate::transcript::Error),
34}
35
36#[derive(Debug, thiserror::Error)]
37pub enum VerificationError {
38 #[error("evaluation is incorrect for oracle: {0}")]
39 IncorrectEvaluation(String),
40 #[error("CompositePolyOracle verification failed: {0}")]
41 IncorrectCompositePolyEvaluation(String),
42 #[error("subproof type or shape does not match the claim")]
43 SubproofMismatch,
44 #[error("LinearCombination must contain an eval")]
45 MissingLinearCombinationEval,
46 #[error("The referenced duplicate claim is different from expected")]
47 DuplicateClaimMismatch,
48}
49
50impl VerificationError {
51 pub fn incorrect_composite_poly_evaluation<F: TowerField>(
52 oracle: &CompositePolyOracle<F>,
53 ) -> Self {
54 let names = oracle
55 .inner_polys()
56 .iter()
57 .map(|inner| inner.label())
58 .collect::<Vec<_>>();
59 let s = format!("Composition: {:?} with inner: {:?}", oracle.composition(), names);
60 Self::IncorrectCompositePolyEvaluation(s)
61 }
62}