Cleanup obsolete code

Remove ContextFlag enum
Remove InvalidContext error-enum variant
Remove unused imports
This commit is contained in:
Thomas Eizinger 2018-06-03 18:48:21 +10:00
parent bb77741e47
commit be7134c7f4
3 changed files with 5 additions and 35 deletions

View File

@ -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<ffi::PublicKey> 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;

View File

@ -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<C> {
unsafe impl<C> Send for Secp256k1<C> {}
unsafe impl<C> Sync for Secp256k1<C> {}
/// 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<C> Clone for Secp256k1<C> {
fn clone(&self) -> Secp256k1<C> {
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) => {

View File

@ -15,7 +15,6 @@
//! # Schnorr signatures
use ContextFlag;
use Error;
use Message;
use Secp256k1;
@ -106,10 +105,8 @@ impl<C: Verification> Secp256k1<C> {
#[cfg(test)]
mod tests {
use rand::{Rng, thread_rng};
use ContextFlag;
use Message;
use Secp256k1;
use Error::IncapableContext;
use super::Signature;
#[test]