#[derive(Debug)]
pub enum PCError {
AnyhowError(anyhow::Error),
MissingPolynomial {
label: String,
},
MissingEvaluation {
label: String,
},
MissingRng,
DegreeIsZero,
TooManyCoefficients {
num_coefficients: usize,
num_powers: usize,
},
HidingBoundIsZero,
HidingBoundToolarge {
hiding_poly_degree: usize,
num_powers: usize,
},
LagrangeBasisSizeIsNotPowerOfTwo,
LagrangeBasisSizeIsTooLarge,
TrimmingDegreeTooLarge,
EquationHasDegreeBounds(String),
UnsupportedDegreeBound(usize),
UnsupportedLagrangeBasisSize(usize),
IncorrectDegreeBound {
poly_degree: usize,
degree_bound: usize,
max_degree: usize,
label: String,
},
Terminated,
}
impl snarkvm_utilities::error::Error for PCError {}
impl From<anyhow::Error> for PCError {
fn from(other: anyhow::Error) -> Self {
Self::AnyhowError(other)
}
}
impl core::fmt::Display for PCError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::AnyhowError(error) => write!(f, "{error}"),
Self::MissingPolynomial { label } => {
write!(f, "`QuerySet` refers to polynomial \"{label}\", but it was not provided.")
}
Self::MissingEvaluation { label } => write!(
f,
"`QuerySet` refers to polynomial \"{label}\", but `Evaluations` does not contain an evaluation for it."
),
Self::MissingRng => write!(f, "hiding commitments require `Some(rng)`"),
Self::DegreeIsZero => write!(f, "this scheme does not support committing to degree 0 polynomials"),
Self::TooManyCoefficients { num_coefficients, num_powers } => write!(
f,
"the number of coefficients in the polynomial ({num_coefficients:?}) is greater than\
the maximum number of powers in `Powers` ({num_powers:?})"
),
Self::HidingBoundIsZero => write!(f, "this scheme does not support non-`None` hiding bounds that are 0"),
Self::HidingBoundToolarge { hiding_poly_degree, num_powers } => write!(
f,
"the degree of the hiding poly ({hiding_poly_degree:?}) is not less than the maximum number of powers in `Powers` ({num_powers:?})"
),
Self::TrimmingDegreeTooLarge => write!(f, "the degree provided to `trim` was too large"),
Self::EquationHasDegreeBounds(e) => {
write!(f, "the eqaution \"{e}\" contained degree-bounded polynomials")
}
Self::UnsupportedDegreeBound(bound) => {
write!(f, "the degree bound ({bound:?}) is not supported by the parameters")
}
Self::LagrangeBasisSizeIsNotPowerOfTwo => {
write!(f, "the Lagrange Basis size is not a power of two")
}
Self::UnsupportedLagrangeBasisSize(size) => {
write!(f, "the Lagrange basis size ({size:?}) is not supported by the parameters")
}
Self::LagrangeBasisSizeIsTooLarge => {
write!(f, "the Lagrange Basis size larger than max supported degree")
}
Self::IncorrectDegreeBound { poly_degree, degree_bound, max_degree, label } => write!(
f,
"the degree bound ({degree_bound}) for the polynomial {label} \
(having degree {poly_degree}) is greater than the maximum degree ({max_degree})"
),
Self::Terminated => write!(f, "terminated"),
}
}
}