From be7134c7f4b930958c1a2ff4dee9f61f665cffdd Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 3 Jun 2018 18:48:21 +1000 Subject: [PATCH] Cleanup obsolete code Remove ContextFlag enum Remove InvalidContext error-enum variant Remove unused imports --- src/key.rs | 8 ++++---- src/lib.rs | 29 +---------------------------- src/schnorr.rs | 3 --- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/key.rs b/src/key.rs index 7e8a5c1..60ab40d 100644 --- a/src/key.rs +++ b/src/key.rs @@ -19,8 +19,8 @@ use std::mem; -use super::{Secp256k1, ContextFlag}; -use super::Error::{self, IncapableContext, InvalidPublicKey, InvalidSecretKey}; +use super::{Secp256k1}; +use super::Error::{self, InvalidPublicKey, InvalidSecretKey}; use Signing; use Verification; use constants; @@ -270,8 +270,8 @@ impl From for PublicKey { #[cfg(test)] mod test { - use super::super::{Secp256k1, ContextFlag}; - use super::super::Error::{InvalidPublicKey, InvalidSecretKey, IncapableContext}; + use super::super::{Secp256k1}; + use super::super::Error::{InvalidPublicKey, InvalidSecretKey}; use super::{PublicKey, SecretKey}; use super::super::constants; diff --git a/src/lib.rs b/src/lib.rs index 49eb9ff..945feb1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -336,9 +336,6 @@ impl From<[u8; constants::MESSAGE_SIZE]> for Message { /// An ECDSA error #[derive(Copy, PartialEq, Eq, Clone, Debug)] pub enum Error { - /// A `Secp256k1` was used for an operation, but it was not created to - /// support this (so necessary precomputations have not been done) - IncapableContext, /// Signature failed verification IncorrectSignature, /// Badly sized message ("messages" are actually fixed-sized digests; see the `MESSAGE_SIZE` @@ -366,7 +363,6 @@ impl error::Error for Error { fn description(&self) -> &str { match *self { - Error::IncapableContext => "secp: context does not have sufficient capabilities", Error::IncorrectSignature => "secp: signature failed verification", Error::InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)", Error::InvalidPublicKey => "secp: malformed public key", @@ -400,28 +396,6 @@ pub struct Secp256k1 { unsafe impl Send for Secp256k1 {} unsafe impl Sync for Secp256k1 {} -/// Flags used to determine the capabilities of a `Secp256k1` object; -/// the more capabilities, the more expensive it is to create. -#[derive(PartialEq, Eq, Copy, Clone, Debug)] -pub enum ContextFlag { - /// Can neither sign nor verify signatures (cheapest to create, useful - /// for cases not involving signatures, such as creating keys from slices) - None, - /// Can sign but not verify signatures - SignOnly, - /// Can verify but not create signatures - VerifyOnly, - /// Can verify and create signatures - Full -} - -// Passthrough Debug to Display, since caps should be user-visible -impl fmt::Display for ContextFlag { - fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { - fmt::Debug::fmt(self, f) - } -} - impl Clone for Secp256k1 { fn clone(&self) -> Secp256k1 { Secp256k1 { @@ -586,8 +560,7 @@ mod tests { use key::{SecretKey, PublicKey}; use super::constants; use super::{Secp256k1, Signature, RecoverableSignature, Message, RecoveryId}; - use super::Error::{InvalidMessage, InvalidPublicKey, IncorrectSignature, InvalidSignature, - IncapableContext}; + use super::Error::{InvalidMessage, InvalidPublicKey, IncorrectSignature, InvalidSignature}; macro_rules! hex { ($hex:expr) => { diff --git a/src/schnorr.rs b/src/schnorr.rs index 4923cff..1b2d091 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -15,7 +15,6 @@ //! # Schnorr signatures -use ContextFlag; use Error; use Message; use Secp256k1; @@ -106,10 +105,8 @@ impl Secp256k1 { #[cfg(test)] mod tests { use rand::{Rng, thread_rng}; - use ContextFlag; use Message; use Secp256k1; - use Error::IncapableContext; use super::Signature; #[test]