#[cfg(not(feature = "std"))]
use alloc::string::String;
#[cfg(feature = "std")]
use thiserror::Error;
#[cfg_attr(feature = "std", derive(Error))]
#[derive(Debug)]
pub enum ZkError {
#[cfg_attr(feature = "std", error("Invalid proof"))]
InvalidProof,
#[cfg_attr(feature = "std", error("Invalid parameters"))]
InvalidParameters,
#[cfg_attr(feature = "std", error("Computation error: {0}"))]
ComputationError(String),
#[cfg(feature = "std")]
#[cfg_attr(feature = "std", error("Serialization error: {0}"))]
SerializationError(String),
#[cfg(not(feature = "std"))]
SerializationError,
#[cfg_attr(feature = "std", error("IO error: {0}"))]
IoError(String),
}
#[cfg(not(feature = "std"))]
impl core::fmt::Display for ZkError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ZkError::InvalidProof => write!(f, "Invalid proof"),
ZkError::InvalidParameters => write!(f, "Invalid parameters"),
ZkError::ComputationError(msg) => write!(f, "Computation error: {}", msg),
ZkError::SerializationError => write!(f, "Serialization error"),
ZkError::IoError(msg) => write!(f, "IO error: {}", msg),
}
}
}