use crate::String;
#[derive(Debug)]
pub enum Error {
MissingPolynomial {
label: String,
},
MissingEvaluation {
label: String,
},
MissingLHS {
label: String,
},
MissingRng,
DegreeIsZero,
TooManyCoefficients {
num_coefficients: usize,
num_powers: usize,
},
HidingBoundIsZero,
HidingBoundToolarge {
hiding_poly_degree: usize,
num_powers: usize,
},
TrimmingDegreeTooLarge,
EmptyDegreeBounds,
EquationHasDegreeBounds(String),
UnsupportedDegreeBound(usize),
IncorrectDegreeBound {
poly_degree: usize,
degree_bound: usize,
supported_degree: usize,
label: String,
},
IncorrectInputLength(String),
MalformedCommitment(String),
}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Error::MissingPolynomial { label } => write!(
f,
"`QuerySet` refers to polynomial \"{}\", but it was not provided.",
label
),
Error::MissingEvaluation { label } => write!(
f,
"`QuerySet` refers to polynomial \"{}\", but `Evaluations` does not contain an evaluation for it.",
label
),
Error::MissingLHS { label } => write!(f, "Equation \"{}\" does not have a LHS.", label),
Error::MissingRng => write!(f, "hiding commitments require `Some(rng)`"),
Error::DegreeIsZero => write!(f, "this scheme does not support committing to degree 0 polynomials"),
Error::TooManyCoefficients {
num_coefficients,
num_powers,
} => write!(
f,
"the number of coefficients in the polynomial ({:?}) is greater than\
the maximum number of powers in `Powers` ({:?})",
num_coefficients, num_powers
),
Error::HidingBoundIsZero => write!(f, "this scheme does not support non-`None` hiding bounds that are 0"),
Error::HidingBoundToolarge {
hiding_poly_degree,
num_powers,
} => write!(
f,
"the degree of the hiding poly ({:?}) is not less than the maximum number of powers in `Powers` ({:?})",
hiding_poly_degree, num_powers
),
Error::TrimmingDegreeTooLarge => write!(f, "the degree provided to `trim` was too large"),
Error::EmptyDegreeBounds => write!(f, "provided `enforced_degree_bounds` was `Some<&[]>`"),
Error::EquationHasDegreeBounds(e) => {
write!(f, "the eqaution \"{}\" contained degree-bounded polynomials", e)
}
Error::UnsupportedDegreeBound(bound) => {
write!(f, "the degree bound ({:?}) is not supported by the parameters", bound,)
}
Error::IncorrectDegreeBound {
poly_degree,
degree_bound,
supported_degree,
label,
} => write!(
f,
"the degree bound ({:?}) for the polynomial {} \
(having degree {:?}) is greater than the maximum \
supported degree ({:?})",
degree_bound, label, poly_degree, supported_degree
),
Error::IncorrectInputLength(err) => write!(f, "{}", err),
Error::MalformedCommitment(err) => write!(f, "{}", err),
}
}
}
impl snarkos_utilities::error::Error for Error {}