use thiserror::Error;

/// The error types generated by this library
#[derive(Error, Clone, Debug)]
pub enum BlsError {
    /// Invalid signing operation
    #[error("invalid signing operation: {0}")]
    SigningError(String),
    /// Invalid inputs to a function
    #[error("invalid inputs: {0}")]
    InvalidInputs(String),
    /// An invalid signature error
    #[error("invalid signature")]
    InvalidSignature,
    /// The proof was invalid
    #[error("invalid proof")]
    InvalidProof,
    /// The signature schemes don't match
    #[error("Invalid signature scheme")]
    InvalidSignatureScheme,
    /// The decryption share is invalid
    #[error("Invalid sign cryption share")]
    InvalidDecryptionShare,
    /// A verifiable secret sharing scheme error
    #[error("an error occurred during secret sharing")]
    VsssError,
}

/// The result type generated by this library
pub type BlsResult<T> = anyhow::Result<T, BlsError>;

impl From<vsss_rs::Error> for BlsError {
    fn from(_: vsss_rs::Error) -> Self {
        Self::VsssError
    }
}
