reddsa/src/error.rs

36 lines
1.0 KiB
Rust
Raw Normal View History

// -*- mode: rust; -*-
//
2021-03-01 06:38:25 -08:00
// This file is part of reddsa.
// Copyright (c) 2019-2021 Zcash Foundation
// See LICENSE for licensing information.
//
// Authors:
// - Deirdre Connolly <deirdre@zfnd.org>
// - Henry de Valence <hdevalence@hdevalence.ca>
use core::fmt;
2019-12-02 21:36:47 -08:00
/// An error related to RedDSA signatures.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
2019-12-02 21:36:47 -08:00
pub enum Error {
/// The encoding of a signing key was malformed.
MalformedSigningKey,
/// The encoding of a verification key was malformed.
MalformedVerificationKey,
2019-12-03 22:32:30 -08:00
/// Signature verification failed.
InvalidSignature,
2019-12-02 21:36:47 -08:00
}
#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::MalformedSigningKey => write!(f, "Malformed signing key encoding."),
Self::MalformedVerificationKey => write!(f, "Malformed verification key encoding."),
Self::InvalidSignature => write!(f, "Invalid signature."),
}
}
}