use thiserror::Error;
use crate::registry::VkId;
#[derive(Error, Debug)]
pub enum Error {
#[error("verification key {0:?} not found in registry")]
UnknownVk(VkId),
#[error("proof verification failed: {0}")]
VerificationFailed(String),
#[error("batch size {got} exceeds maximum {max}")]
BatchTooLarge { got: usize, max: usize },
#[error("cannot aggregate empty batch")]
EmptyBatch,
#[error("public input count mismatch: expected {expected}, got {got}")]
PublicInputMismatch { expected: usize, got: usize },
#[error("SRS size {srs_k} too small for circuit size {circuit_k}")]
InsufficientSrs { srs_k: u32, circuit_k: u32 },
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Serialization(#[from] bincode::Error),
}
#[derive(Error, Debug)]
pub enum ConfigError {
#[error("SRS not provided in configuration")]
MissingSrs,
#[error("batch size must be positive, got {0}")]
InvalidBatchSize(usize),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn error_display_unknown_vk() {
let err = Error::UnknownVk(VkId::new(42));
assert!(err.to_string().contains("42"));
}
#[test]
fn error_display_batch_too_large() {
let err = Error::BatchTooLarge { got: 100, max: 32 };
assert!(err.to_string().contains("100"));
assert!(err.to_string().contains("32"));
}
#[test]
fn config_error_display() {
let err = ConfigError::MissingSrs;
assert!(err.to_string().contains("SRS"));
}
}