proof_of_sql/base/proof/
error.rs

1use crate::base::database::ColumnType;
2use snafu::Snafu;
3
4#[derive(Snafu, Debug)]
5/// These errors occur when a proof failed to verify.
6pub enum ProofError {
7    #[snafu(display("Verification error: {error}"))]
8    /// This error occurs when a proof failed to verify.
9    VerificationError { error: &'static str },
10    /// This error occurs when a query plan is not supported.
11    #[snafu(display("Unsupported query plan: {error}"))]
12    UnsupportedQueryPlan { error: &'static str },
13    /// This error occurs the type coercion of the result table failed.
14    #[snafu(display("Result does not match query: type mismatch"))]
15    InvalidTypeCoercion,
16    /// This error occurs when the field names of the result table do not match the query.
17    #[snafu(display("Result does not match query: field names mismatch"))]
18    FieldNamesMismatch,
19    /// This error occurs when the number of fields in the result table does not match the query.
20    #[snafu(display("Result does not match query: field count mismatch"))]
21    FieldCountMismatch,
22    #[snafu(transparent)]
23    ProofSizeMismatch { source: ProofSizeMismatch },
24    #[snafu(transparent)]
25    PlaceholderError { source: PlaceholderError },
26}
27
28#[derive(Snafu, Debug)]
29/// These errors occur when the proof size does not match the expected size.
30pub enum ProofSizeMismatch {
31    /// This error occurs when the sumcheck proof doesn't have enough coefficients.
32    #[snafu(display("Sumcheck proof is too small"))]
33    SumcheckProofTooSmall,
34    /// This error occurs when the proof has too few MLE evaluations.
35    #[snafu(display("Proof has too few MLE evaluations"))]
36    TooFewMLEEvaluations,
37    /// This error occurs when the number of post result challenges in the proof plan doesn't match the number specified in the proof
38    #[snafu(display("Post result challenge count mismatch"))]
39    PostResultCountMismatch,
40    /// This error occurs when the number of constraints in the proof plan doesn't match the number specified in the proof
41    #[snafu(display("Constraint count mismatch"))]
42    ConstraintCountMismatch,
43    /// This error occurs when the proof has too few bit distributions.
44    #[snafu(display("Proof has too few bit distributions"))]
45    TooFewBitDistributions,
46    /// This error occurs when the proof has too few one lengths.
47    #[snafu(display("Proof has too few one lengths"))]
48    TooFewChiLengths,
49    /// This error occurs when the proof has too few rho lengths.
50    #[snafu(display("Proof has too few rho lengths"))]
51    TooFewRhoLengths,
52    /// This error occurs when the proof has too few sumcheck variables.
53    #[snafu(display("Proof has too few sumcheck variables"))]
54    TooFewSumcheckVariables,
55    /// This error occurs when a requested one length is not found.
56    #[snafu(display("Proof doesn't have requested one length"))]
57    ChiLengthNotFound,
58    /// This error occurs when a requested rho length is not found.
59    #[snafu(display("Proof doesn't have requested rho length"))]
60    RhoLengthNotFound,
61}
62
63/// Errors related to placeholders
64#[derive(Snafu, Debug, PartialEq, Eq)]
65pub enum PlaceholderError {
66    #[snafu(display("Invalid placeholder id: {id}, number of params: {num_params}"))]
67    /// Placeholder id is invalid
68    InvalidPlaceholderId {
69        /// The invalid placeholder id
70        id: usize,
71        /// The number of parameters
72        num_params: usize,
73    },
74
75    #[snafu(display("Invalid placeholder type: {id}, expected: {expected}, actual: {actual}"))]
76    /// Placeholder type is invalid
77    InvalidPlaceholderType {
78        /// The invalid placeholder id
79        id: usize,
80        /// The expected type
81        expected: ColumnType,
82        /// The actual type
83        actual: ColumnType,
84    },
85
86    #[snafu(display("Placeholder id must be greater than 0"))]
87    /// Placeholder id is zero
88    ZeroPlaceholderId,
89}
90
91/// Result type for placeholder errors
92pub type PlaceholderResult<T> = Result<T, PlaceholderError>;