1use alloc::string::String;
3
4use crate::circuits::lookup::index::LookupError; use o1_utils::lazy_cache::{LazyCacheError, LazyCacheErrorOr};
6use poly_commitment::error::CommitmentError;
7use thiserror::Error;
8
9#[derive(Error, Debug, Clone)]
12pub enum ProverError {
13 #[error("the circuit is too large")]
14 NoRoomForZkInWitness,
15
16 #[error(
17 "there are not enough random rows to achieve zero-knowledge (expected: {0}, got: {1})"
18 )]
19 NotZeroKnowledge(usize, usize),
20
21 #[error("the witness columns are not all the same size")]
22 WitnessCsInconsistent,
23
24 #[error("the proof could not be constructed: {0}")]
25 Prover(&'static str),
26
27 #[error("the permutation was not constructed correctly: {0}")]
28 Permutation(&'static str),
29
30 #[error("the lookup failed to find a match in the table: row={0}")]
31 ValueNotInTable(usize),
32
33 #[error("the runtime tables provided did not match the index's configuration")]
34 RuntimeTablesInconsistent,
35
36 #[error("wrong number of custom blinders given: {0}")]
37 WrongBlinders(CommitmentError),
38
39 #[error("relation polynomials failed to initialize in lazy mode: {0}")]
40 LazySetup(SetupError),
41}
42
43#[derive(Error, Debug, Clone, Copy)]
45pub enum VerifyError {
46 #[error("the commitment to {0} is of an unexpected size (expected {1}, got {2})")]
47 IncorrectCommitmentLength(&'static str, usize, usize),
48
49 #[error("the public input is of an unexpected size (expected {0})")]
50 IncorrectPubicInputLength(usize),
51
52 #[error("the previous challenges have an unexpected length (expected {0}, got {1})")]
53 IncorrectPrevChallengesLength(usize, usize),
54
55 #[error(
56 "proof malformed: an evaluation for {2} was of the incorrect size (expected {0}, got {1})"
57 )]
58 IncorrectEvaluationsLength(usize, usize, &'static str),
59
60 #[error("the opening proof failed to verify")]
61 OpenProof,
62
63 #[error("lookup used in circuit, but proof is missing lookup commitments")]
64 LookupCommitmentMissing,
65
66 #[error("lookup used in circuit, but proof is missing lookup evaluations")]
67 LookupEvalsMissing,
68
69 #[error("lookup used in circuit, but proof has inconsistent number of lookup evaluations and commitments")]
70 ProofInconsistentLookup,
71
72 #[error("cannot batch proofs using different SRSes")]
73 DifferentSRS,
74
75 #[error("SRS size is smaller than the domain size required by the circuit")]
76 SRSTooSmall,
77
78 #[error("runtime tables are used, but missing from the proof")]
79 IncorrectRuntimeProof,
80
81 #[error("the evaluation for {0:?} is missing")]
82 MissingEvaluation(crate::circuits::berkeley_columns::Column),
83
84 #[error("the evaluation for PublicInput is missing")]
85 MissingPublicInputEvaluation,
86
87 #[error("the commitment for {0:?} is missing")]
88 MissingCommitment(crate::circuits::berkeley_columns::Column),
89}
90
91#[derive(Error, Debug, Clone)]
93pub enum DomainCreationError {
94 #[error("could not compute the size of domain for {0}")]
95 DomainSizeFailed(usize),
96
97 #[error("construction of domain {0} for size {1} failed")]
98 DomainConstructionFailed(String, usize),
99}
100
101#[derive(Error, Debug, Clone)]
103pub enum SetupError {
104 #[error("the domain could not be constructed: {0}")]
105 ConstraintSystem(String),
106
107 #[error("the domain could not be constructed: {0}")]
108 DomainCreation(DomainCreationError),
109
110 #[error("the lookup constraint system cannot not be constructed: {0}")]
111 LookupCreation(LookupError),
112
113 #[error("lazy evaluation failed")]
114 LazyEvaluation(LazyCacheError),
115}
116
117#[derive(Error, Debug, Clone)]
119pub enum VerifierIndexError {
120 #[error("srs has already been set")]
121 SRSHasBeenSet,
122}
123
124impl From<LazyCacheErrorOr<LookupError>> for SetupError {
126 fn from(e: LazyCacheErrorOr<LookupError>) -> Self {
127 match e {
128 LazyCacheErrorOr::Inner(inner) => SetupError::LookupCreation(inner.clone()),
129 LazyCacheErrorOr::Outer(err) => SetupError::LazyEvaluation(err),
130 }
131 }
132}
133
134impl From<LazyCacheErrorOr<LookupError>> for ProverError {
135 fn from(e: LazyCacheErrorOr<LookupError>) -> Self {
136 ProverError::LazySetup(SetupError::from(e))
137 }
138}