diff --git a/src/key.rs b/src/key.rs index a266162..0aec673 100644 --- a/src/key.rs +++ b/src/key.rs @@ -122,20 +122,6 @@ impl SecretKey { } impl PublicKey { - /// Creates a new zeroed out public key - #[inline] - pub fn new() -> PublicKey { - PublicKey(ffi::PublicKey::new()) - } - - /// Determines whether a pubkey is valid - #[inline] - pub fn is_valid(&self) -> bool { - // The only invalid pubkey the API should be able to create is - // the zero one. - self.0[..].iter().any(|&x| x != 0) - } - /// Obtains a raw pointer suitable for use with FFI functions #[inline] pub fn as_ptr(&self) -> *const ffi::PublicKey { diff --git a/src/lib.rs b/src/lib.rs index b9ae6ab..1b9818f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -552,14 +552,12 @@ impl Secp256k1 { /// verify-capable context. #[inline] pub fn verify(&self, msg: &Message, sig: &Signature, pk: &key::PublicKey) -> Result<(), Error> { - - if !pk.is_valid() { - Err(Error::InvalidPublicKey) - } else if unsafe { ffi::secp256k1_ecdsa_verify(self.ctx, sig.as_ptr(), msg.as_ptr(), - pk.as_ptr()) } == 0 { - Err(Error::IncorrectSignature) - } else { - Ok(()) + unsafe { + if ffi::secp256k1_ecdsa_verify(self.ctx, sig.as_ptr(), msg.as_ptr(), pk.as_ptr()) == 0 { + Err(Error::IncorrectSignature) + } else { + Ok(()) + } } } } @@ -571,7 +569,7 @@ mod tests { use key::{SecretKey, PublicKey}; use super::constants; use super::{Secp256k1, Signature, RecoverableSignature, Message, RecoveryId}; - use super::Error::{InvalidMessage, InvalidPublicKey, IncorrectSignature, InvalidSignature}; + use super::Error::{InvalidMessage, IncorrectSignature, InvalidSignature}; macro_rules! hex { ($hex:expr) => { @@ -642,18 +640,6 @@ mod tests { assert_eq!(one, one.clone()); } - #[test] - fn invalid_pubkey() { - let s = Secp256k1::new(); - let sig = RecoverableSignature::from_compact(&s, &[1; 64], RecoveryId(0)).unwrap(); - let pk = PublicKey::new(); - let mut msg = [0u8; 32]; - thread_rng().fill_bytes(&mut msg); - let msg = Message::from_slice(&msg).unwrap(); - - assert_eq!(s.verify(&msg, &sig.to_standard(&s), &pk), Err(InvalidPublicKey)); - } - #[test] fn sign() { let mut s = Secp256k1::new();