libspartan/
errors.rs

1use core::{
2  fmt::Display,
3  fmt::{self, Debug},
4};
5
6#[derive(Debug, Default)]
7pub enum ProofVerifyError {
8  #[default]
9  InternalError,
10  DecompressionError([u8; 32]),
11}
12
13impl Display for ProofVerifyError {
14  fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15    match &self {
16      ProofVerifyError::DecompressionError(bytes) => write!(
17        f,
18        "Compressed group element failed to decompress: {bytes:?}",
19      ),
20      ProofVerifyError::InternalError => {
21        write!(f, "Proof verification failed",)
22      }
23    }
24  }
25}
26
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub enum R1CSError {
29  /// returned if the number of constraints is not a power of 2
30  NonPowerOfTwoCons,
31  /// returned if the number of variables is not a power of 2
32  NonPowerOfTwoVars,
33  /// returned if a wrong number of inputs in an assignment are supplied
34  InvalidNumberOfInputs,
35  /// returned if a wrong number of variables in an assignment are supplied
36  InvalidNumberOfVars,
37  /// returned if a [u8;32] does not parse into a valid Scalar in the field of ristretto255
38  InvalidScalar,
39  /// returned if the supplied row or col in (row,col,val) tuple is out of range
40  InvalidIndex,
41}