diff --git a/src/constants.rs b/src/constants.rs index 57cc441..f456327 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -44,6 +44,7 @@ pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32; pub const KEY_PAIR_SIZE: usize = 96; /// The Prime for the secp256k1 field element. +#[rustfmt::skip] pub const FIELD_SIZE: [u8; 32] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -52,6 +53,7 @@ pub const FIELD_SIZE: [u8; 32] = [ ]; /// The order of the secp256k1 curve. +#[rustfmt::skip] pub const CURVE_ORDER: [u8; 32] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, @@ -60,6 +62,7 @@ pub const CURVE_ORDER: [u8; 32] = [ ]; /// The X coordinate of the generator. +#[rustfmt::skip] pub const GENERATOR_X: [u8; 32] = [ 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, @@ -68,6 +71,7 @@ pub const GENERATOR_X: [u8; 32] = [ ]; /// The Y coordinate of the generator. +#[rustfmt::skip] pub const GENERATOR_Y: [u8; 32] = [ 0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8, diff --git a/src/ecdh.rs b/src/ecdh.rs index b2c5032..a999b82 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -266,6 +266,7 @@ mod tests { #[cfg(all(feature = "serde", any(feature = "alloc", feature = "std")))] fn serde() { use serde_test::{Configure, Token, assert_tokens}; + #[rustfmt::skip] static BYTES: [u8; 32] = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, diff --git a/src/ecdsa/mod.rs b/src/ecdsa/mod.rs index a63fc5a..d8b3535 100644 --- a/src/ecdsa/mod.rs +++ b/src/ecdsa/mod.rs @@ -1,23 +1,21 @@ //! Structs and functionality related to the ECDSA signature algorithm. -use core::{fmt, str, ptr}; - -use crate::{Signing, Verification, Message, PublicKey, Secp256k1, SecretKey, from_hex, Error, ffi}; -use crate::ffi::CPtr; - -pub mod serialized_signature; - #[cfg(feature = "recovery")] mod recovery; +pub mod serialized_signature; + +use core::{fmt, str, ptr}; #[cfg(feature = "recovery")] #[cfg_attr(docsrs, doc(cfg(feature = "recovery")))] -pub use self::recovery::{RecoveryId, RecoverableSignature}; - -pub use serialized_signature::SerializedSignature; - +pub use self::recovery::{RecoverableSignature, RecoveryId}; +pub use self::serialized_signature::SerializedSignature; +use crate::ffi::CPtr; #[cfg(feature = "global-context")] use crate::SECP256K1; +use crate::{ + ffi, from_hex, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification, +}; /// An ECDSA signature #[derive(Copy, Clone, PartialEq, Eq, Hash)] diff --git a/src/ecdsa/recovery.rs b/src/ecdsa/recovery.rs index 9c835cb..23ede65 100644 --- a/src/ecdsa/recovery.rs +++ b/src/ecdsa/recovery.rs @@ -266,6 +266,7 @@ mod tests { #[test] #[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs #[cfg(all(feature="std", feature = "rand-std"))] + #[rustfmt::skip] fn sign() { let mut s = Secp256k1::new(); s.randomize(&mut thread_rng()); @@ -290,6 +291,7 @@ mod tests { #[test] #[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs #[cfg(all(feature="std", feature = "rand-std"))] + #[rustfmt::skip] fn sign_with_noncedata() { let mut s = Secp256k1::new(); s.randomize(&mut thread_rng()); @@ -390,6 +392,7 @@ mod tests { #[test] fn test_debug_output() { + #[rustfmt::skip] let sig = RecoverableSignature::from_compact(&[ 0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f, 0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6, @@ -406,6 +409,7 @@ mod tests { #[test] fn test_recov_sig_serialize_compact() { let recid_in = RecoveryId(1); + #[rustfmt::skip] let bytes_in = &[ 0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f, 0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6, diff --git a/src/key.rs b/src/key.rs index 836dcec..1c30ff3 100644 --- a/src/key.rs +++ b/src/key.rs @@ -713,7 +713,8 @@ impl serde::Serialize for PublicKey { s.collect_str(self) } else { let mut tuple = s.serialize_tuple(constants::PUBLIC_KEY_SIZE)?; - for byte in self.serialize().iter() { // Serialize in compressed form. + // Serialize in compressed form. + for byte in self.serialize().iter() { tuple.serialize_element(&byte)?; } tuple.end() @@ -1689,6 +1690,7 @@ mod test { #[test] #[cfg(any(feature = "alloc", feature = "std"))] + #[rustfmt::skip] fn invalid_secret_key() { // Zero assert_eq!(SecretKey::from_slice(&[0; 32]), Err(InvalidSecretKey)); @@ -1725,6 +1727,7 @@ mod test { // group order, then decrement with repeated calls // until it returns a valid key fn fill_bytes(&mut self, data: &mut [u8]) { + #[rustfmt::skip] let group_order: [u8; 32] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, @@ -1824,6 +1827,7 @@ mod test { #[test] #[cfg(any(feature = "alloc", feature = "std"))] fn test_display_output() { + #[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -2105,6 +2109,7 @@ mod test { #[cfg(all(feature = "serde", any(feature = "alloc", feature = "std")))] fn test_serde() { use serde_test::{Configure, Token, assert_tokens}; + #[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, @@ -2114,6 +2119,7 @@ mod test { static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363"; #[cfg(fuzzing)] + #[rustfmt::skip] static PK_BYTES: [u8; 33] = [ 0x02, 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, @@ -2134,6 +2140,7 @@ mod test { #[cfg(fuzzing)] let pk = PublicKey::from_slice(&PK_BYTES).expect("pk"); + #[rustfmt::skip] assert_tokens(&sk.compact(), &[ Token::Tuple{ len: 32 }, Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), @@ -2147,6 +2154,7 @@ mod test { assert_tokens(&sk.readable(), &[Token::Str(SK_STR)]); assert_tokens(&sk.readable(), &[Token::String(SK_STR)]); + #[rustfmt::skip] assert_tokens(&pk.compact(), &[ Token::Tuple{ len: 33 }, Token::U8(0x02), @@ -2230,6 +2238,7 @@ mod test { } } + #[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, @@ -2239,6 +2248,7 @@ mod test { static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363"; let sk = KeyPairWrapper(KeyPair::from_seckey_slice(&crate::SECP256K1, &SK_BYTES).unwrap()); + #[rustfmt::skip] assert_tokens(&sk.compact(), &[ Token::Tuple{ len: 32 }, Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), Token::U8(1), @@ -2257,6 +2267,7 @@ mod test { fn keys() -> (SecretKey, PublicKey, KeyPair, XOnlyPublicKey) { let secp = Secp256k1::new(); + #[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, @@ -2264,6 +2275,7 @@ mod test { 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, ]; + #[rustfmt::skip] static PK_BYTES: [u8; 32] = [ 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d, @@ -2405,6 +2417,7 @@ mod test { fn test_serde_x_only_pubkey() { use serde_test::{Configure, Token, assert_tokens}; + #[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, @@ -2419,6 +2432,7 @@ mod test { let kp = KeyPair::from_seckey_slice(&crate::SECP256K1, &SK_BYTES).unwrap(); let (pk, _parity) = XOnlyPublicKey::from_keypair(&kp); + #[rustfmt::skip] assert_tokens(&pk.compact(), &[ Token::Tuple{ len: 32 }, Token::U8(0x18), Token::U8(0x84), Token::U8(0x57), Token::U8(0x81), Token::U8(0xf6), Token::U8(0x31), Token::U8(0xc4), Token::U8(0x8f), diff --git a/src/schnorr.rs b/src/schnorr.rs index 54aa5de..39cded6 100644 --- a/src/schnorr.rs +++ b/src/schnorr.rs @@ -493,6 +493,7 @@ mod tests { assert_tokens(&sig.readable(), &[Token::Str(SIG_STR)]); assert_tokens(&sig.readable(), &[Token::String(SIG_STR)]); + #[rustfmt::skip] assert_tokens(&pk.compact(), &[ Token::Tuple{ len: 32 }, Token::U8(24), Token::U8(132), Token::U8(87), Token::U8(129), Token::U8(246), Token::U8(49), Token::U8(196), Token::U8(143), diff --git a/tests/serde.rs b/tests/serde.rs index f0938f8..ef7992d 100644 --- a/tests/serde.rs +++ b/tests/serde.rs @@ -11,6 +11,7 @@ use secp256k1::{Secp256k1, KeyPair}; // Arbitrary key data. +#[rustfmt::skip] static SK_BYTES: [u8; 32] = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, @@ -18,6 +19,7 @@ static SK_BYTES: [u8; 32] = [ 0x0f, 0x10, 0x1f, 0xa0, 0xa9, 0xaa, 0xaf, 0xff, ]; +#[rustfmt::skip] static PK_BYTES: [u8; 33] = [ 0x02, 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, @@ -26,6 +28,7 @@ static PK_BYTES: [u8; 33] = [ 0x4a, 0xc8, 0x87, 0xfe, 0x91, 0xdd, 0xd1, 0x66, ]; +#[rustfmt::skip] static XONLY_PK_BYTES: [u8; 32] = [ 0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f, 0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d,