Merge rust-bitcoin/rust-secp256k1#374: Do trivial Clippy fixes

72f5e0441e Do not use deprecated functions (Tobin Harding)
3840ce914b Add Debug/Copy/Clone derives (Tobin Harding)
63ae716e6f Add clippy.toml (Tobin Harding)

Pull request description:

  Add `clippy.toml` and fix a few trivial Clippy warnings.

ACKs for top commit:
  elichai:
    ACK 72f5e04
  apoelstra:
    ACK 72f5e0441e

Tree-SHA512: 5310832d9a4d864a118fef41e275304b912d1c8997060e1eaba95e12700a0b551e846309f9765e10a9a886a03f65b90fcda31d6bf92188791b3c73f97a14e18d
This commit is contained in:
Andrew Poelstra 2022-01-12 18:28:35 +00:00
commit 7b8392057c
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 17 additions and 15 deletions

1
clippy.toml Normal file
View File

@ -0,0 +1 @@
msrv = "1.29"

View File

@ -21,6 +21,7 @@ pub mod global {
use {Secp256k1, All}; use {Secp256k1, All};
/// Proxy struct for global `SECP256K1` context /// Proxy struct for global `SECP256K1` context
#[derive(Debug, Copy, Clone)]
pub struct GlobalContext { pub struct GlobalContext {
__private: (), __private: (),
} }

View File

@ -223,16 +223,16 @@ mod tests {
let (sk, pk) = full.generate_keypair(&mut thread_rng()); let (sk, pk) = full.generate_keypair(&mut thread_rng());
// Try signing // Try signing
assert_eq!(sign.sign_recoverable(&msg, &sk), full.sign_recoverable(&msg, &sk)); assert_eq!(sign.sign_ecdsa_recoverable(&msg, &sk), full.sign_ecdsa_recoverable(&msg, &sk));
let sigr = full.sign_recoverable(&msg, &sk); let sigr = full.sign_ecdsa_recoverable(&msg, &sk);
// Try pk recovery // Try pk recovery
assert!(vrfy.recover(&msg, &sigr).is_ok()); assert!(vrfy.recover_ecdsa(&msg, &sigr).is_ok());
assert!(full.recover(&msg, &sigr).is_ok()); assert!(full.recover_ecdsa(&msg, &sigr).is_ok());
assert_eq!(vrfy.recover(&msg, &sigr), assert_eq!(vrfy.recover_ecdsa(&msg, &sigr),
full.recover(&msg, &sigr)); full.recover_ecdsa(&msg, &sigr));
assert_eq!(full.recover(&msg, &sigr), Ok(pk)); assert_eq!(full.recover_ecdsa(&msg, &sigr), Ok(pk));
} }
#[test] #[test]
@ -252,7 +252,7 @@ mod tests {
let sk = SecretKey::from_slice(&one).unwrap(); let sk = SecretKey::from_slice(&one).unwrap();
let msg = Message::from_slice(&one).unwrap(); let msg = Message::from_slice(&one).unwrap();
let sig = s.sign_recoverable(&msg, &sk); let sig = s.sign_ecdsa_recoverable(&msg, &sk);
assert_eq!(Ok(sig), RecoverableSignature::from_compact(&[ assert_eq!(Ok(sig), RecoverableSignature::from_compact(&[
0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f, 0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f,
0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6, 0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6,
@ -276,7 +276,7 @@ mod tests {
let (sk, pk) = s.generate_keypair(&mut thread_rng()); let (sk, pk) = s.generate_keypair(&mut thread_rng());
let sigr = s.sign_recoverable(&msg, &sk); let sigr = s.sign_ecdsa_recoverable(&msg, &sk);
let sig = sigr.to_standard(); let sig = sigr.to_standard();
let mut msg = [0u8; 32]; let mut msg = [0u8; 32];
@ -284,7 +284,7 @@ mod tests {
let msg = Message::from_slice(&msg).unwrap(); let msg = Message::from_slice(&msg).unwrap();
assert_eq!(s.verify_ecdsa(&msg, &sig, &pk), Err(Error::IncorrectSignature)); assert_eq!(s.verify_ecdsa(&msg, &sig, &pk), Err(Error::IncorrectSignature));
let recovered_key = s.recover(&msg, &sigr).unwrap(); let recovered_key = s.recover_ecdsa(&msg, &sigr).unwrap();
assert!(recovered_key != pk); assert!(recovered_key != pk);
} }
@ -299,9 +299,9 @@ mod tests {
let (sk, pk) = s.generate_keypair(&mut thread_rng()); let (sk, pk) = s.generate_keypair(&mut thread_rng());
let sig = s.sign_recoverable(&msg, &sk); let sig = s.sign_ecdsa_recoverable(&msg, &sk);
assert_eq!(s.recover(&msg, &sig), Ok(pk)); assert_eq!(s.recover_ecdsa(&msg, &sig), Ok(pk));
} }
#[test] #[test]
@ -313,10 +313,10 @@ mod tests {
// Zero is not a valid sig // Zero is not a valid sig
let sig = RecoverableSignature::from_compact(&[0; 64], RecoveryId(0)).unwrap(); let sig = RecoverableSignature::from_compact(&[0; 64], RecoveryId(0)).unwrap();
assert_eq!(s.recover(&msg, &sig), Err(Error::InvalidSignature)); assert_eq!(s.recover_ecdsa(&msg, &sig), Err(Error::InvalidSignature));
// ...but 111..111 is // ...but 111..111 is
let sig = RecoverableSignature::from_compact(&[1; 64], RecoveryId(0)).unwrap(); let sig = RecoverableSignature::from_compact(&[1; 64], RecoveryId(0)).unwrap();
assert!(s.recover(&msg, &sig).is_ok()); assert!(s.recover_ecdsa(&msg, &sig).is_ok());
} }
#[test] #[test]
@ -384,7 +384,7 @@ mod benches {
thread_rng().fill_bytes(&mut msg); thread_rng().fill_bytes(&mut msg);
let msg = Message::from_slice(&msg).unwrap(); let msg = Message::from_slice(&msg).unwrap();
let (sk, _) = s.generate_keypair(&mut thread_rng()); let (sk, _) = s.generate_keypair(&mut thread_rng());
let sig = s.sign_recoverable(&msg, &sk); let sig = s.sign_ecdsa_recoverable(&msg, &sk);
bh.iter(|| { bh.iter(|| {
let res = s.recover(&msg, &sig).unwrap(); let res = s.recover(&msg, &sig).unwrap();