diff --git a/Cargo.toml b/Cargo.toml index 433e628..9877385 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ categories = ["cryptography"] [dependencies] byteorder = "1.2.3" -error-chain = "0.12.0" +failure = "0.1" init_with = "1.1.0" log = "0.4.1" pairing = { version = "0.14.2", features = ["u128-support"] } diff --git a/src/error.rs b/src/error.rs index 96f2427..87123dc 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,10 +1,13 @@ -error_chain! { - errors { - NotEnoughShares { - description("not enough signature shares") - } - DuplicateEntry { - description("signature shares contain a duplicated index") - } - } +//! Crypto errors. + +/// A crypto error. +#[derive(Clone, Eq, PartialEq, Debug, Fail)] +pub enum Error { + #[fail(display = "Not enough signature shares")] + NotEnoughShares, + #[fail(display = "Signature shares contain a duplicated index")] + DuplicateEntry, } + +/// A crypto result. +pub type Result = ::std::result::Result; diff --git a/src/lib.rs b/src/lib.rs index a845e6e..90849f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ extern crate bincode; extern crate byteorder; #[macro_use] -extern crate error_chain; +extern crate failure; extern crate init_with; #[macro_use] extern crate log; @@ -39,7 +39,7 @@ use pairing::{CurveAffine, CurveProjective, Engine, Field}; use rand::{ChaChaRng, OsRng, Rng, SeedableRng}; use ring::digest; -use error::{ErrorKind, Result}; +use error::{Error, Result}; use into_fr::IntoFr; use poly::{Commitment, Poly}; @@ -499,13 +499,13 @@ where .map(|(i, sample)| (into_fr_plus_1(i), sample)) .collect(); if samples.len() < t { - return Err(ErrorKind::NotEnoughShares.into()); + return Err(Error::NotEnoughShares); } let mut result = C::zero(); let mut indexes = Vec::new(); for (x, sample) in samples.iter().take(t) { if indexes.contains(x) { - return Err(ErrorKind::DuplicateEntry.into()); + return Err(Error::DuplicateEntry); } indexes.push(x.clone()); // Compute the value at 0 of the Lagrange polynomial that is `0` at the other data