Skip to main content

rune_ring/
error.rs

1//! Error type for Rune operations.
2
3/// Errors returned by Rune key, signing, and verification operations.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum RuneError {
6    /// Ring size is less than 2.
7    RingTooSmall,
8    /// Signer index is out of range for the given ring.
9    SignerIndexOutOfRange,
10    /// Not all public keys in the ring share the same public matrix seed.
11    InconsistentRingParameter,
12    /// A signature field has wrong length or structure.
13    MalformedSignature,
14    /// A supplied challenge polynomial has invalid weight or coefficients.
15    MalformedChallenge,
16    /// A public key has invalid structure.
17    MalformedPublicKey,
18    /// Rejection sampling did not terminate within the maximum number of attempts.
19    RejectionSamplingFailed,
20}
21
22impl std::fmt::Display for RuneError {
23    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24        match self {
25            Self::RingTooSmall => f.write_str("ring size is less than 2"),
26            Self::SignerIndexOutOfRange => f.write_str("signer index is out of range"),
27            Self::InconsistentRingParameter => {
28                f.write_str("public keys do not share the same ring parameter")
29            }
30            Self::MalformedSignature => f.write_str("signature has malformed structure"),
31            Self::MalformedChallenge => f.write_str("challenge polynomial is malformed"),
32            Self::MalformedPublicKey => f.write_str("public key has malformed structure"),
33            Self::RejectionSamplingFailed => {
34                f.write_str("rejection sampling failed within the attempt limit")
35            }
36        }
37    }
38}
39
40impl std::error::Error for RuneError {}