Cleanup obsolete code
Remove ContextFlag enum Remove InvalidContext error-enum variant Remove unused imports
This commit is contained in:
parent
bb77741e47
commit
be7134c7f4
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use super::{Secp256k1, ContextFlag};
|
use super::{Secp256k1};
|
||||||
use super::Error::{self, IncapableContext, InvalidPublicKey, InvalidSecretKey};
|
use super::Error::{self, InvalidPublicKey, InvalidSecretKey};
|
||||||
use Signing;
|
use Signing;
|
||||||
use Verification;
|
use Verification;
|
||||||
use constants;
|
use constants;
|
||||||
|
@ -270,8 +270,8 @@ impl From<ffi::PublicKey> for PublicKey {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::super::{Secp256k1, ContextFlag};
|
use super::super::{Secp256k1};
|
||||||
use super::super::Error::{InvalidPublicKey, InvalidSecretKey, IncapableContext};
|
use super::super::Error::{InvalidPublicKey, InvalidSecretKey};
|
||||||
use super::{PublicKey, SecretKey};
|
use super::{PublicKey, SecretKey};
|
||||||
use super::super::constants;
|
use super::super::constants;
|
||||||
|
|
||||||
|
|
29
src/lib.rs
29
src/lib.rs
|
@ -336,9 +336,6 @@ impl From<[u8; constants::MESSAGE_SIZE]> for Message {
|
||||||
/// An ECDSA error
|
/// An ECDSA error
|
||||||
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
|
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
|
||||||
pub enum Error {
|
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
|
/// Signature failed verification
|
||||||
IncorrectSignature,
|
IncorrectSignature,
|
||||||
/// Badly sized message ("messages" are actually fixed-sized digests; see the `MESSAGE_SIZE`
|
/// 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 {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
Error::IncapableContext => "secp: context does not have sufficient capabilities",
|
|
||||||
Error::IncorrectSignature => "secp: signature failed verification",
|
Error::IncorrectSignature => "secp: signature failed verification",
|
||||||
Error::InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)",
|
Error::InvalidMessage => "secp: message was not 32 bytes (do you need to hash?)",
|
||||||
Error::InvalidPublicKey => "secp: malformed public key",
|
Error::InvalidPublicKey => "secp: malformed public key",
|
||||||
|
@ -400,28 +396,6 @@ pub struct Secp256k1<C> {
|
||||||
unsafe impl<C> Send for Secp256k1<C> {}
|
unsafe impl<C> Send for Secp256k1<C> {}
|
||||||
unsafe impl<C> Sync 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> {
|
impl<C> Clone for Secp256k1<C> {
|
||||||
fn clone(&self) -> Secp256k1<C> {
|
fn clone(&self) -> Secp256k1<C> {
|
||||||
Secp256k1 {
|
Secp256k1 {
|
||||||
|
@ -586,8 +560,7 @@ mod tests {
|
||||||
use key::{SecretKey, PublicKey};
|
use key::{SecretKey, PublicKey};
|
||||||
use super::constants;
|
use super::constants;
|
||||||
use super::{Secp256k1, Signature, RecoverableSignature, Message, RecoveryId};
|
use super::{Secp256k1, Signature, RecoverableSignature, Message, RecoveryId};
|
||||||
use super::Error::{InvalidMessage, InvalidPublicKey, IncorrectSignature, InvalidSignature,
|
use super::Error::{InvalidMessage, InvalidPublicKey, IncorrectSignature, InvalidSignature};
|
||||||
IncapableContext};
|
|
||||||
|
|
||||||
macro_rules! hex {
|
macro_rules! hex {
|
||||||
($hex:expr) => {
|
($hex:expr) => {
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
//! # Schnorr signatures
|
//! # Schnorr signatures
|
||||||
|
|
||||||
use ContextFlag;
|
|
||||||
use Error;
|
use Error;
|
||||||
use Message;
|
use Message;
|
||||||
use Secp256k1;
|
use Secp256k1;
|
||||||
|
@ -106,10 +105,8 @@ impl<C: Verification> Secp256k1<C> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use rand::{Rng, thread_rng};
|
use rand::{Rng, thread_rng};
|
||||||
use ContextFlag;
|
|
||||||
use Message;
|
use Message;
|
||||||
use Secp256k1;
|
use Secp256k1;
|
||||||
use Error::IncapableContext;
|
|
||||||
use super::Signature;
|
use super::Signature;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue