ark_relations/r1cs/
error.rs

1use core::fmt;
2
3/// This is an error that could occur during circuit synthesis contexts,
4/// such as CRS generation, proving or verification.
5#[derive(PartialEq, Eq, Clone, Copy, Debug)]
6pub enum SynthesisError {
7    /// During synthesis, we tried to allocate a variable when
8    /// `ConstraintSystemRef` was `None`.
9    MissingCS,
10    /// During synthesis, we lacked knowledge of a variable assignment.
11    AssignmentMissing,
12    /// During synthesis, we divided by zero.
13    DivisionByZero,
14    /// During synthesis, we constructed an unsatisfiable constraint system.
15    Unsatisfiable,
16    /// During synthesis, our polynomials ended up being too high of degree
17    PolynomialDegreeTooLarge,
18    /// During proof generation, we encountered an identity in the CRS
19    UnexpectedIdentity,
20    /// During verification, our verifying key was malformed.
21    MalformedVerifyingKey,
22    /// During CRS generation, we observed an unconstrained auxiliary variable
23    UnconstrainedVariable,
24}
25
26impl ark_std::error::Error for SynthesisError {}
27
28impl fmt::Display for SynthesisError {
29    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
30        match self {
31            SynthesisError::MissingCS => write!(f, "the constraint system was `None`"),
32            SynthesisError::AssignmentMissing => {
33                write!(f, "an assignment for a variable could not be computed")
34            },
35            SynthesisError::DivisionByZero => write!(f, "division by zero"),
36            SynthesisError::Unsatisfiable => write!(f, "unsatisfiable constraint system"),
37            SynthesisError::PolynomialDegreeTooLarge => write!(f, "polynomial degree is too large"),
38            SynthesisError::UnexpectedIdentity => {
39                write!(f, "encountered an identity element in the CRS")
40            },
41            SynthesisError::MalformedVerifyingKey => write!(f, "malformed verifying key"),
42            SynthesisError::UnconstrainedVariable => {
43                write!(f, "auxiliary variable was unconstrained")
44            },
45        }
46    }
47}