proof-cat 0.3.0

PLONKish bridge to sumcheck proving (built on proof-cat-core)
Documentation
//! Project-wide error type.

/// All errors that can arise in proof-cat.
#[derive(Debug)]
pub enum Error {
    /// An error propagated from plonkish-cat.
    Plonkish(plonkish_cat::Error),
    /// An error propagated from proof-cat-core (transcript, sumcheck, Merkle, multilinear poly).
    ProofCatCore(proof_cat_core::Error),
    /// Witness length does not match the wire count.
    WitnessSizeMismatch {
        /// The number of wires expected.
        expected: usize,
        /// The number of wire values provided.
        actual: usize,
    },
    /// A constraint was not satisfied by the witness.
    UnsatisfiedConstraint {
        /// The zero-based index of the failing constraint.
        index: usize,
    },
    /// Constraint set is empty; nothing to prove.
    EmptyConstraintSet,
}

impl core::fmt::Display for Error {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::Plonkish(e) => write!(f, "plonkish-cat error: {e}"),
            Self::ProofCatCore(e) => write!(f, "proof-cat-core error: {e}"),
            Self::WitnessSizeMismatch { expected, actual } => {
                write!(
                    f,
                    "witness size mismatch: expected {expected}, got {actual}"
                )
            }
            Self::UnsatisfiedConstraint { index } => {
                write!(f, "constraint {index} not satisfied by witness")
            }
            Self::EmptyConstraintSet => write!(f, "constraint set is empty"),
        }
    }
}

impl std::error::Error for Error {
    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
        match self {
            Self::Plonkish(e) => Some(e),
            Self::ProofCatCore(e) => Some(e),
            Self::WitnessSizeMismatch { .. }
            | Self::UnsatisfiedConstraint { .. }
            | Self::EmptyConstraintSet => None,
        }
    }
}

impl From<plonkish_cat::Error> for Error {
    fn from(e: plonkish_cat::Error) -> Self {
        Self::Plonkish(e)
    }
}

impl From<proof_cat_core::Error> for Error {
    fn from(e: proof_cat_core::Error) -> Self {
        Self::ProofCatCore(e)
    }
}