Skip to main content

eyvara/
error.rs

1//! Error types for Eyvara VRF operations.
2
3/// Errors that can occur during Eyvara VRF operations.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum EyvaraError {
6    /// Proof structure is invalid.
7    MalformedProof,
8    /// Public key structure is invalid.
9    MalformedPublicKey,
10    /// Hint weight exceeds omega.
11    HintWeightExceeded,
12    /// Response norm exceeds the bound.
13    NormBoundExceeded,
14    /// Fiat-Shamir challenge mismatch.
15    ChallengeMismatch,
16    /// Output does not match the proof.
17    OutputMismatch,
18    /// Rejection sampling exhausted all attempts.
19    RejectionSamplingFailed,
20}
21
22impl std::fmt::Display for EyvaraError {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        match self {
25            Self::MalformedProof => write!(f, "malformed proof"),
26            Self::MalformedPublicKey => write!(f, "malformed public key"),
27            Self::HintWeightExceeded => write!(f, "hint weight exceeded omega"),
28            Self::NormBoundExceeded => write!(f, "response norm exceeded bound"),
29            Self::ChallengeMismatch => write!(f, "Fiat-Shamir challenge mismatch"),
30            Self::OutputMismatch => write!(f, "VRF output does not match proof"),
31            Self::RejectionSamplingFailed => {
32                write!(f, "rejection sampling failed after max attempts")
33            }
34        }
35    }
36}
37
38impl std::error::Error for EyvaraError {}