bls12_381_bls/error.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
use dusk_bytes::Error as DuskBytesError;
use core::fmt;
/// Standard error for the interface
#[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Error {
/// Dusk-bytes serialization error
BytesError(DuskBytesError),
/// Cryptographic invalidity
InvalidSignature,
/// Invalid Point
InvalidPoint,
/// Tried to aggregate an empty list of public keys
NoKeysProvided,
}
impl From<DuskBytesError> for Error {
fn from(bytes_err: DuskBytesError) -> Self {
Self::BytesError(bytes_err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::BytesError(err) => write!(f, "{:?}", err),
Self::InvalidSignature => {
write!(f, "Invalid Signature")
}
Self::InvalidPoint => {
write!(f, "Invalid Point")
}
Self::NoKeysProvided => {
write!(f, "No keys provided")
}
}
}
}