Skip to content

Commit 41449e4

Browse files
committed
Prepare codebase for formatting
In preparation for running the formatter do minor refactorings and add a bunch of `rustfmt::skip` directives.
1 parent 7e3c893 commit 41449e4

File tree

7 files changed

+37
-12
lines changed

7 files changed

+37
-12
lines changed

src/constants.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub const SCHNORR_PUBLIC_KEY_SIZE: usize = 32;
4444
pub const KEY_PAIR_SIZE: usize = 96;
4545

4646
/// The Prime for the secp256k1 field element.
47+
#[rustfmt::skip]
4748
pub const FIELD_SIZE: [u8; 32] = [
4849
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
4950
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -52,6 +53,7 @@ pub const FIELD_SIZE: [u8; 32] = [
5253
];
5354

5455
/// The order of the secp256k1 curve.
56+
#[rustfmt::skip]
5557
pub const CURVE_ORDER: [u8; 32] = [
5658
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
5759
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
@@ -60,6 +62,7 @@ pub const CURVE_ORDER: [u8; 32] = [
6062
];
6163

6264
/// The X coordinate of the generator.
65+
#[rustfmt::skip]
6366
pub const GENERATOR_X: [u8; 32] = [
6467
0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac,
6568
0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07,
@@ -68,6 +71,7 @@ pub const GENERATOR_X: [u8; 32] = [
6871
];
6972

7073
/// The Y coordinate of the generator.
74+
#[rustfmt::skip]
7175
pub const GENERATOR_Y: [u8; 32] = [
7276
0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65,
7377
0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8,

src/ecdh.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ mod tests {
266266
#[cfg(all(feature = "serde", any(feature = "alloc", feature = "std")))]
267267
fn serde() {
268268
use serde_test::{Configure, Token, assert_tokens};
269+
#[rustfmt::skip]
269270
static BYTES: [u8; 32] = [
270271
1, 1, 1, 1, 1, 1, 1, 1,
271272
0, 1, 2, 3, 4, 5, 6, 7,

src/ecdsa/mod.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
//! Structs and functionality related to the ECDSA signature algorithm.
22
3-
use core::{fmt, str, ptr};
4-
5-
use crate::{Signing, Verification, Message, PublicKey, Secp256k1, SecretKey, from_hex, Error, ffi};
6-
use crate::ffi::CPtr;
7-
8-
pub mod serialized_signature;
9-
103
#[cfg(feature = "recovery")]
114
mod recovery;
5+
pub mod serialized_signature;
6+
7+
use core::{fmt, str, ptr};
128

139
#[cfg(feature = "recovery")]
1410
#[cfg_attr(docsrs, doc(cfg(feature = "recovery")))]
15-
pub use self::recovery::{RecoveryId, RecoverableSignature};
16-
17-
pub use serialized_signature::SerializedSignature;
18-
11+
pub use self::recovery::{RecoverableSignature, RecoveryId};
12+
pub use self::serialized_signature::SerializedSignature;
13+
use crate::ffi::CPtr;
1914
#[cfg(feature = "global-context")]
2015
use crate::SECP256K1;
16+
use crate::{
17+
ffi, from_hex, Error, Message, PublicKey, Secp256k1, SecretKey, Signing, Verification,
18+
};
2119

2220
/// An ECDSA signature
2321
#[derive(Copy, Clone, PartialEq, Eq, Hash)]

src/ecdsa/recovery.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ mod tests {
266266
#[test]
267267
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
268268
#[cfg(all(feature="std", feature = "rand-std"))]
269+
#[rustfmt::skip]
269270
fn sign() {
270271
let mut s = Secp256k1::new();
271272
s.randomize(&mut thread_rng());
@@ -290,6 +291,7 @@ mod tests {
290291
#[test]
291292
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
292293
#[cfg(all(feature="std", feature = "rand-std"))]
294+
#[rustfmt::skip]
293295
fn sign_with_noncedata() {
294296
let mut s = Secp256k1::new();
295297
s.randomize(&mut thread_rng());
@@ -390,6 +392,7 @@ mod tests {
390392

391393
#[test]
392394
fn test_debug_output() {
395+
#[rustfmt::skip]
393396
let sig = RecoverableSignature::from_compact(&[
394397
0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f,
395398
0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6,
@@ -406,6 +409,7 @@ mod tests {
406409
#[test]
407410
fn test_recov_sig_serialize_compact() {
408411
let recid_in = RecoveryId(1);
412+
#[rustfmt::skip]
409413
let bytes_in = &[
410414
0x66, 0x73, 0xff, 0xad, 0x21, 0x47, 0x74, 0x1f,
411415
0x04, 0x77, 0x2b, 0x6f, 0x92, 0x1f, 0x0b, 0xa6,

src/key.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,8 @@ impl serde::Serialize for PublicKey {
713713
s.collect_str(self)
714714
} else {
715715
let mut tuple = s.serialize_tuple(constants::PUBLIC_KEY_SIZE)?;
716-
for byte in self.serialize().iter() { // Serialize in compressed form.
716+
// Serialize in compressed form.
717+
for byte in self.serialize().iter() {
717718
tuple.serialize_element(&byte)?;
718719
}
719720
tuple.end()
@@ -1689,6 +1690,7 @@ mod test {
16891690

16901691
#[test]
16911692
#[cfg(any(feature = "alloc", feature = "std"))]
1693+
#[rustfmt::skip]
16921694
fn invalid_secret_key() {
16931695
// Zero
16941696
assert_eq!(SecretKey::from_slice(&[0; 32]), Err(InvalidSecretKey));
@@ -1725,6 +1727,7 @@ mod test {
17251727
// group order, then decrement with repeated calls
17261728
// until it returns a valid key
17271729
fn fill_bytes(&mut self, data: &mut [u8]) {
1730+
#[rustfmt::skip]
17281731
let group_order: [u8; 32] = [
17291732
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
17301733
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
@@ -1824,6 +1827,7 @@ mod test {
18241827
#[test]
18251828
#[cfg(any(feature = "alloc", feature = "std"))]
18261829
fn test_display_output() {
1830+
#[rustfmt::skip]
18271831
static SK_BYTES: [u8; 32] = [
18281832
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
18291833
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -2105,6 +2109,7 @@ mod test {
21052109
#[cfg(all(feature = "serde", any(feature = "alloc", feature = "std")))]
21062110
fn test_serde() {
21072111
use serde_test::{Configure, Token, assert_tokens};
2112+
#[rustfmt::skip]
21082113
static SK_BYTES: [u8; 32] = [
21092114
1, 1, 1, 1, 1, 1, 1, 1,
21102115
0, 1, 2, 3, 4, 5, 6, 7,
@@ -2114,6 +2119,7 @@ mod test {
21142119
static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363";
21152120

21162121
#[cfg(fuzzing)]
2122+
#[rustfmt::skip]
21172123
static PK_BYTES: [u8; 33] = [
21182124
0x02,
21192125
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f,
@@ -2134,6 +2140,7 @@ mod test {
21342140
#[cfg(fuzzing)]
21352141
let pk = PublicKey::from_slice(&PK_BYTES).expect("pk");
21362142

2143+
#[rustfmt::skip]
21372144
assert_tokens(&sk.compact(), &[
21382145
Token::Tuple{ len: 32 },
21392146
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 {
21472154
assert_tokens(&sk.readable(), &[Token::Str(SK_STR)]);
21482155
assert_tokens(&sk.readable(), &[Token::String(SK_STR)]);
21492156

2157+
#[rustfmt::skip]
21502158
assert_tokens(&pk.compact(), &[
21512159
Token::Tuple{ len: 33 },
21522160
Token::U8(0x02),
@@ -2230,6 +2238,7 @@ mod test {
22302238
}
22312239
}
22322240

2241+
#[rustfmt::skip]
22332242
static SK_BYTES: [u8; 32] = [
22342243
1, 1, 1, 1, 1, 1, 1, 1,
22352244
0, 1, 2, 3, 4, 5, 6, 7,
@@ -2239,6 +2248,7 @@ mod test {
22392248
static SK_STR: &str = "01010101010101010001020304050607ffff0000ffff00006363636363636363";
22402249

22412250
let sk = KeyPairWrapper(KeyPair::from_seckey_slice(&crate::SECP256K1, &SK_BYTES).unwrap());
2251+
#[rustfmt::skip]
22422252
assert_tokens(&sk.compact(), &[
22432253
Token::Tuple{ len: 32 },
22442254
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,13 +2267,15 @@ mod test {
22572267
fn keys() -> (SecretKey, PublicKey, KeyPair, XOnlyPublicKey) {
22582268
let secp = Secp256k1::new();
22592269

2270+
#[rustfmt::skip]
22602271
static SK_BYTES: [u8; 32] = [
22612272
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
22622273
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
22632274
0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
22642275
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
22652276
];
22662277

2278+
#[rustfmt::skip]
22672279
static PK_BYTES: [u8; 32] = [
22682280
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f,
22692281
0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d,
@@ -2405,6 +2417,7 @@ mod test {
24052417
fn test_serde_x_only_pubkey() {
24062418
use serde_test::{Configure, Token, assert_tokens};
24072419

2420+
#[rustfmt::skip]
24082421
static SK_BYTES: [u8; 32] = [
24092422
1, 1, 1, 1, 1, 1, 1, 1,
24102423
0, 1, 2, 3, 4, 5, 6, 7,
@@ -2419,6 +2432,7 @@ mod test {
24192432
let kp = KeyPair::from_seckey_slice(&crate::SECP256K1, &SK_BYTES).unwrap();
24202433
let (pk, _parity) = XOnlyPublicKey::from_keypair(&kp);
24212434

2435+
#[rustfmt::skip]
24222436
assert_tokens(&pk.compact(), &[
24232437
Token::Tuple{ len: 32 },
24242438
Token::U8(0x18), Token::U8(0x84), Token::U8(0x57), Token::U8(0x81), Token::U8(0xf6), Token::U8(0x31), Token::U8(0xc4), Token::U8(0x8f),

src/schnorr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ mod tests {
493493
assert_tokens(&sig.readable(), &[Token::Str(SIG_STR)]);
494494
assert_tokens(&sig.readable(), &[Token::String(SIG_STR)]);
495495

496+
#[rustfmt::skip]
496497
assert_tokens(&pk.compact(), &[
497498
Token::Tuple{ len: 32 },
498499
Token::U8(24), Token::U8(132), Token::U8(87), Token::U8(129), Token::U8(246), Token::U8(49), Token::U8(196), Token::U8(143),

tests/serde.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ use secp256k1::{Secp256k1, KeyPair};
1111

1212
// Arbitrary key data.
1313

14+
#[rustfmt::skip]
1415
static SK_BYTES: [u8; 32] = [
1516
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1617
0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23,
1718
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x30, 0x31,
1819
0x0f, 0x10, 0x1f, 0xa0, 0xa9, 0xaa, 0xaf, 0xff,
1920
];
2021

22+
#[rustfmt::skip]
2123
static PK_BYTES: [u8; 33] = [
2224
0x02,
2325
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f,
@@ -26,6 +28,7 @@ static PK_BYTES: [u8; 33] = [
2628
0x4a, 0xc8, 0x87, 0xfe, 0x91, 0xdd, 0xd1, 0x66,
2729
];
2830

31+
#[rustfmt::skip]
2932
static XONLY_PK_BYTES: [u8; 32] = [
3033
0x18, 0x84, 0x57, 0x81, 0xf6, 0x31, 0xc4, 0x8f,
3134
0x1c, 0x97, 0x09, 0xe2, 0x30, 0x92, 0x06, 0x7d,

0 commit comments

Comments
 (0)