winter_prover/
errors.rs

1// Copyright (c) Facebook, Inc. and its affiliates.
2//
3// This source code is licensed under the MIT license found in the
4// LICENSE file in the root directory of this source tree.
5
6//! Contains common error types for prover and verifier.
7
8use core::fmt;
9
10// PROVER ERROR
11// ================================================================================================
12/// Represents an error returned by the prover during an execution of the protocol.
13#[derive(Debug, Clone, PartialEq, Eq)]
14pub enum ProverError {
15    /// This error occurs when a transition constraint evaluated over a specific execution trace
16    /// does not evaluate to zero at any of the steps.
17    UnsatisfiedTransitionConstraintError(usize),
18    /// This error occurs when polynomials built from the columns of a constraint evaluation
19    /// table do not all have the same degree.
20    MismatchedConstraintPolynomialDegree(usize, usize),
21    /// This error occurs when the base field specified by the AIR does not support field extension
22    /// of degree specified by proof options.
23    UnsupportedFieldExtension(usize),
24}
25
26impl fmt::Display for ProverError {
27    #[rustfmt::skip]
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        match self {
30            Self::UnsatisfiedTransitionConstraintError(step) => {
31                write!(f, "a transition constraint was not satisfied at step {step}")
32            }
33            Self::MismatchedConstraintPolynomialDegree(expected, actual) => {
34                write!(f, "the constraint polynomial's components do not all have the same degree; expected {expected}, but was {actual}")
35            }
36            Self::UnsupportedFieldExtension(degree) => {
37                write!(f, "field extension of degree {degree} is not supported for the specified base field")
38            }
39        }
40    }
41}
42
43impl core::error::Error for ProverError {}