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
// Copyright 2024 Ulvetanna Inc.

use crate::{
	polynomial::Error as PolynomialError,
	protocols::abstract_sumcheck::Error as AbstractSumcheckError,
};

#[derive(Debug, thiserror::Error)]
pub enum Error {
	#[error("prover has mismatch between claim and witness")]
	ProverClaimWitnessMismatch,
	#[error("gkr_sumcheck polynomial degree must be greater than zero")]
	PolynomialDegreeIsZero,
	#[error("gkr_sumcheck claims may not be empty")]
	EmptyClaimsArray,
	#[error("gkr_sumcheck was not given enough challenges for its claim")]
	NotEnoughGkrRoundChallenges,
	#[error("finalize was called on gkr_sumcheck prover before all rounds were completed")]
	PrematureFinalizeCall,
	#[error("execute round was called on gkr_sumcheck prover too many times")]
	TooManyExecuteRoundCalls,
	#[error("the input argument for the current round number is not the expected value")]
	RoundArgumentRoundClaimMismatch,
	#[error("all claims in a batch must have the same gkr challenge")]
	MismatchedGkrChallengeInClaimsBatch,
	#[error("polynomial error: {0}")]
	Polynomial(#[from] PolynomialError),
	#[error("verification failure: {0}")]
	Verification(#[from] VerificationError),
	#[error("abstract sumcheck failure: {0}")]
	AbstractSumcheck(#[from] AbstractSumcheckError),
	#[error("{0}")]
	MathError(#[from] binius_math::Error),
}

#[derive(Debug, thiserror::Error)]
pub enum VerificationError {
	#[error("number of coefficients in round proof is incorrect, expected {expected}")]
	NumberOfCoefficients { expected: usize },
}