Skip to content

Commit e01e794

Browse files
committed
[fmt] Format everything
Also get rid of the nightly flags to simplify development.
1 parent 29c39eb commit e01e794

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+239
-222
lines changed

arithmetic_macros/src/optree.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![allow(unused)]
22
use super::Input;
3-
use proc_macro2::{token_stream, Delimiter, Punct, Span, TokenStream, TokenTree};
4-
use quote::{quote_spanned, ToTokens};
3+
use proc_macro2::{Delimiter, Punct, Span, TokenStream, TokenTree, token_stream};
4+
use quote::{ToTokens, quote_spanned};
55
use std::{fmt::Display, iter::Peekable};
66

77
#[derive(Clone)]
@@ -39,7 +39,7 @@ impl core::fmt::Debug for OpTree {
3939
.debug_tuple(&unary.kind.to_string())
4040
.field(&unary.subj)
4141
.finish(),
42-
Self::LitInt(arg0) => write!(f, "{}", arg0),
42+
Self::LitInt(arg0) => write!(f, "{arg0}"),
4343
}
4444
}
4545
}
@@ -80,13 +80,17 @@ impl InfixKind {
8080

8181
impl core::fmt::Display for InfixKind {
8282
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83-
write!(f, "{}", match self {
84-
InfixKind::Add => "+",
85-
InfixKind::Mul => "*",
86-
InfixKind::Sub => "-",
87-
InfixKind::LinComb => ".*",
88-
InfixKind::Div => "/",
89-
})
83+
write!(
84+
f,
85+
"{}",
86+
match self {
87+
InfixKind::Add => "+",
88+
InfixKind::Mul => "*",
89+
InfixKind::Sub => "-",
90+
InfixKind::LinComb => ".*",
91+
InfixKind::Div => "/",
92+
}
93+
)
9094
}
9195
}
9296

@@ -105,10 +109,14 @@ pub enum UnaryKind {
105109

106110
impl core::fmt::Display for UnaryKind {
107111
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108-
write!(f, "{}", match self {
109-
UnaryKind::Neg => "-",
110-
UnaryKind::Ref => "&",
111-
})
112+
write!(
113+
f,
114+
"{}",
115+
match self {
116+
UnaryKind::Neg => "-",
117+
UnaryKind::Ref => "&",
118+
}
119+
)
112120
}
113121
}
114122

@@ -155,7 +163,7 @@ fn rule_term(input: &mut Input) -> Result<Node, Error> {
155163
return Err(Error {
156164
span: group.span(),
157165
problem: "can only use '(..)' or '{..}'".into(),
158-
})
166+
});
159167
}
160168
}
161169
}
@@ -171,7 +179,7 @@ fn rule_term(input: &mut Input) -> Result<Node, Error> {
171179
return Err(Error {
172180
span: tt.span(),
173181
problem: "this is an invalid term".into(),
174-
})
182+
});
175183
}
176184
};
177185

ecdsa_fun/benches/bench_ecdsa.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use criterion::{criterion_group, criterion_main, Criterion};
2-
use secp256kfun::{nonce::Deterministic, secp256k1, Scalar};
1+
use criterion::{Criterion, criterion_group, criterion_main};
2+
use secp256kfun::{Scalar, nonce::Deterministic, secp256k1};
33
use sha2::Sha256;
44

55
const MESSAGE: &[u8; 32] = b"hello world you are beautiful!!!";
@@ -49,7 +49,7 @@ fn verify_ecdsa(c: &mut Criterion) {
4949
}
5050

5151
{
52-
use secp256k1::{ecdsa::Signature, Message, PublicKey, Secp256k1, SecretKey};
52+
use secp256k1::{Message, PublicKey, Secp256k1, SecretKey, ecdsa::Signature};
5353
let secp = Secp256k1::new();
5454
let sig = Signature::from_compact(signature.to_bytes().as_ref()).unwrap();
5555
let secret_key = SecretKey::from_slice(&SK.to_bytes()[..]).unwrap();

ecdsa_fun/src/adaptor/encrypted_signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::DLEQ;
2-
use crate::fun::{marker::*, Point, Scalar};
2+
use crate::fun::{Point, Scalar, marker::*};
33
use sigma_fun::CompactProof;
44

55
/// `PointNonce` is a [`NonZero`] Point that also has an x-coordinate that is NonZero

ecdsa_fun/src/adaptor/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
//! use ecdsa_fun::{
1515
//! adaptor::{Adaptor, EncryptedSignature, HashTranscript},
1616
//! fun::{
17+
//! G, Scalar,
1718
//! digest::{Digest, Update},
1819
//! g,
1920
//! marker::*,
20-
//! nonce, Scalar, G,
21+
//! nonce,
2122
//! },
2223
//! };
2324
//! use rand::rngs::ThreadRng;
@@ -63,17 +64,17 @@
6364
//! None => panic!("signature is not the decryption of our original encrypted signature"),
6465
//! }
6566
//! ```
66-
use crate::{Signature, ECDSA};
67+
use crate::{ECDSA, Signature};
6768
use secp256kfun::{
68-
derive_nonce_rng,
69+
G, Point, Scalar, Tag, derive_nonce_rng,
6970
digest::generic_array::typenum::U32,
7071
g,
7172
marker::*,
7273
nonce::{NoNonces, NonceGen},
73-
s, Point, Scalar, Tag, G,
74+
s,
7475
};
7576
pub use sigma_fun::HashTranscript;
76-
use sigma_fun::{secp256k1, Eq, FiatShamir, ProverTranscript, Transcript};
77+
use sigma_fun::{Eq, FiatShamir, ProverTranscript, Transcript, secp256k1};
7778

7879
mod encrypted_signature;
7980
pub use encrypted_signature::*;
@@ -326,9 +327,11 @@ mod test {
326327
));
327328

328329
let signature = ecdsa_adaptor.decrypt_signature(&decryption_key, ciphertext.clone());
329-
assert!(ecdsa_adaptor
330-
.ecdsa
331-
.verify(&verification_key, msg, &signature));
330+
assert!(
331+
ecdsa_adaptor
332+
.ecdsa
333+
.verify(&verification_key, msg, &signature)
334+
);
332335

333336
let recoverd_decryption_sk = ecdsa_adaptor
334337
.recover_decryption_key(&encryption_key, &signature, &ciphertext)

ecdsa_fun/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mod libsecp_compat;
1414

1515
use fun::Tag;
1616

17-
use fun::{derive_nonce, g, marker::*, nonce::NonceGen, s, Point, Scalar, G};
17+
use fun::{G, Point, Scalar, derive_nonce, g, marker::*, nonce::NonceGen, s};
1818
pub use secp256kfun as fun;
1919
pub use secp256kfun::nonce;
2020
mod signature;
@@ -54,7 +54,7 @@ impl<NG> ECDSA<NG> {
5454
///
5555
/// # Example
5656
/// ```
57-
/// use ecdsa_fun::{nonce, ECDSA};
57+
/// use ecdsa_fun::{ECDSA, nonce};
5858
/// use rand::rngs::ThreadRng;
5959
/// use sha2::Sha256;
6060
/// let nonce_gen = nonce::Synthetic::<Sha256, nonce::GlobalRng<ThreadRng>>::default();
@@ -94,7 +94,7 @@ impl<NG> ECDSA<NG> {
9494
///
9595
/// # Example
9696
/// ```
97-
/// use ecdsa_fun::{fun::Scalar, ECDSA};
97+
/// use ecdsa_fun::{ECDSA, fun::Scalar};
9898
/// let ecdsa = ECDSA::verify_only();
9999
/// let secret_key = Scalar::random(&mut rand::thread_rng());
100100
/// let verification_key = ecdsa.verification_key_for(&secret_key);
@@ -121,7 +121,7 @@ impl<NG> ECDSA<NG> {
121121

122122
g!((s_inv * m) * G + (s_inv * R_x) * verification_key)
123123
.non_zero()
124-
.map_or(false, |implied_R| implied_R.x_eq_scalar(R_x))
124+
.is_some_and(|implied_R| implied_R.x_eq_scalar(R_x))
125125
}
126126
}
127127

@@ -132,8 +132,9 @@ impl<NG: NonceGen> ECDSA<NG> {
132132
///
133133
/// ```
134134
/// use ecdsa_fun::{
135+
/// ECDSA,
135136
/// fun::{digest::Digest, prelude::*},
136-
/// nonce, ECDSA,
137+
/// nonce,
137138
/// };
138139
/// use rand::rngs::ThreadRng;
139140
/// use sha2::Sha256;

ecdsa_fun/src/libsecp_compat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(feature = "libsecp_compat_0_27")]
22
mod v0_27 {
3-
use crate::{fun::secp256k1_0_27::ecdsa, Signature};
3+
use crate::{Signature, fun::secp256k1_0_27::ecdsa};
44

55
impl From<Signature> for ecdsa::Signature {
66
fn from(sig: Signature) -> Self {
@@ -17,7 +17,7 @@ mod v0_27 {
1717

1818
#[cfg(feature = "libsecp_compat_0_28")]
1919
mod v0_28 {
20-
use crate::{fun::secp256k1_0_28::ecdsa, Signature};
20+
use crate::{Signature, fun::secp256k1_0_28::ecdsa};
2121

2222
impl From<Signature> for ecdsa::Signature {
2323
fn from(sig: Signature) -> Self {
@@ -34,7 +34,7 @@ mod v0_28 {
3434

3535
#[cfg(feature = "libsecp_compat_0_29")]
3636
mod v0_29 {
37-
use crate::{fun::secp256k1_0_29::ecdsa, Signature};
37+
use crate::{Signature, fun::secp256k1_0_29::ecdsa};
3838

3939
impl From<Signature> for ecdsa::Signature {
4040
fn from(sig: Signature) -> Self {
@@ -51,7 +51,7 @@ mod v0_29 {
5151

5252
#[cfg(feature = "libsecp_compat_0_30")]
5353
mod v0_30 {
54-
use crate::{fun::secp256k1_0_30::ecdsa, Signature};
54+
use crate::{Signature, fun::secp256k1_0_30::ecdsa};
5555

5656
impl From<Signature> for ecdsa::Signature {
5757
fn from(sig: Signature) -> Self {

ecdsa_fun/src/signature.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use secp256kfun::{marker::*, Scalar};
1+
use secp256kfun::{Scalar, marker::*};
22
/// An ECDSA signature
33
#[derive(Clone, PartialEq)]
44
pub struct Signature {

ecdsa_fun/tests/adaptor_test_vectors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
static DLC_SPEC_JSON: &str = include_str!("./test_vectors.json");
44
use ecdsa_fun::{
5+
Signature,
56
adaptor::{Adaptor, EncryptedSignature, HashTranscript},
6-
fun::{serde, Point, Scalar},
7+
fun::{Point, Scalar, serde},
78
nonce::NoNonces,
8-
Signature,
99
};
1010
use sha2::Sha256;
1111

ecdsa_fun/tests/against_c_lib.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#![cfg(feature = "libsecp_compat")]
22
use ecdsa_fun::fun::{
3-
hex,
4-
secp256k1::{self, ecdsa, Message, PublicKey, SecretKey},
5-
Point, Scalar,
3+
Point, Scalar, hex,
4+
secp256k1::{self, Message, PublicKey, SecretKey, ecdsa},
65
};
76

87
const TEST_SOUNDNESS: usize = 20;
@@ -27,9 +26,10 @@ fn ecdsa_sign() {
2726
let signature = ecdsa.sign(&secret_key, &message);
2827
let c_message = Message::from_digest_slice(&message[..]).unwrap();
2928
let c_siganture = ecdsa::Signature::from_compact(&signature.to_bytes()).unwrap();
30-
assert!(secp
31-
.verify_ecdsa(&c_message, &c_siganture, &c_public_key)
32-
.is_ok());
29+
assert!(
30+
secp.verify_ecdsa(&c_message, &c_siganture, &c_public_key)
31+
.is_ok()
32+
);
3333
}
3434
}
3535

@@ -85,7 +85,8 @@ fn ecdsa_sign_high_message() {
8585
let signature = ecdsa.sign(&secret_key, &message);
8686
let c_message = Message::from_digest_slice(&message[..]).unwrap();
8787
let c_siganture = ecdsa::Signature::from_compact(&signature.to_bytes()).unwrap();
88-
assert!(secp
89-
.verify_ecdsa(&c_message, &c_siganture, &c_public_key)
90-
.is_ok());
88+
assert!(
89+
secp.verify_ecdsa(&c_message, &c_siganture, &c_public_key)
90+
.is_ok()
91+
);
9192
}

rustfmt.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
edition = "2024"
2-
condense_wildcard_suffixes = true
3-
format_macro_matchers = true
4-
imports_granularity="Crate"
52
use_field_init_shorthand = true
63
format_code_in_doc_comments = true
7-
overflow_delimited_expr = true

0 commit comments

Comments
 (0)