ironfish_reddsa/
error.rs

1// -*- mode: rust; -*-
2//
3// This file is part of reddsa.
4// Copyright (c) 2019-2021 Zcash Foundation
5// See LICENSE for licensing information.
6//
7// Authors:
8// - Deirdre Connolly <deirdre@zfnd.org>
9// - Henry de Valence <hdevalence@hdevalence.ca>
10
11use core::fmt;
12
13/// An error related to RedDSA signatures.
14#[derive(Debug, Copy, Clone, Eq, PartialEq)]
15pub enum Error {
16    /// The encoding of a signing key was malformed.
17    MalformedSigningKey,
18    /// The encoding of a verification key was malformed.
19    MalformedVerificationKey,
20    /// Signature verification failed.
21    InvalidSignature,
22}
23
24#[cfg(feature = "std")]
25impl std::error::Error for Error {}
26
27impl fmt::Display for Error {
28    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29        match self {
30            Self::MalformedSigningKey => write!(f, "Malformed signing key encoding."),
31            Self::MalformedVerificationKey => write!(f, "Malformed verification key encoding."),
32            Self::InvalidSignature => write!(f, "Invalid signature."),
33        }
34    }
35}