From c1495effaeb6729ed333eea2cc2ebab51341ccaf Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Wed, 18 Sep 2024 09:40:27 +0200 Subject: [PATCH] `rustfmt`: Run on `util/message_signing.rs` --- lightning/src/util/message_signing.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lightning/src/util/message_signing.rs b/lightning/src/util/message_signing.rs index 0a45af26f..d16fc73df 100644 --- a/lightning/src/util/message_signing.rs +++ b/lightning/src/util/message_signing.rs @@ -47,7 +47,7 @@ fn sigrec_decode(sig_rec: Vec) -> Result { match RecoveryId::from_i32(rid) { Ok(x) => RecoverableSignature::from_compact(rsig, x), - Err(e) => Err(e) + Err(e) => Err(e), } } @@ -63,18 +63,18 @@ pub fn sign(msg: &[u8], sk: &SecretKey) -> String { } /// Recovers the PublicKey of the signer of the message given the message and the signature. -pub fn recover_pk(msg: &[u8], sig: &str) -> Result { +pub fn recover_pk(msg: &[u8], sig: &str) -> Result { let secp_ctx = Secp256k1::verification_only(); let msg_hash = sha256d::Hash::hash(&[LN_MESSAGE_PREFIX, msg].concat()); match base32::Alphabet::ZBase32.decode(&sig) { - Ok(sig_rec) => { - match sigrec_decode(sig_rec) { - Ok(sig) => secp_ctx.recover_ecdsa(&Message::from_digest(msg_hash.to_byte_array()), &sig), - Err(e) => Err(e) - } + Ok(sig_rec) => match sigrec_decode(sig_rec) { + Ok(sig) => { + secp_ctx.recover_ecdsa(&Message::from_digest(msg_hash.to_byte_array()), &sig) + }, + Err(e) => Err(e), }, - Err(_) => Err(Error::InvalidSignature) + Err(_) => Err(Error::InvalidSignature), } } @@ -83,16 +83,16 @@ pub fn recover_pk(msg: &[u8], sig: &str) -> Result { pub fn verify(msg: &[u8], sig: &str, pk: &PublicKey) -> bool { match recover_pk(msg, sig) { Ok(x) => x == *pk, - Err(_) => false + Err(_) => false, } } #[cfg(test)] mod test { - use core::str::FromStr; - use crate::util::message_signing::{sign, recover_pk, verify}; + use crate::util::message_signing::{recover_pk, sign, verify}; use bitcoin::secp256k1::constants::ONE; - use bitcoin::secp256k1::{PublicKey, SecretKey, Secp256k1}; + use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey}; + use core::str::FromStr; #[test] fn test_sign() { @@ -148,4 +148,3 @@ mod test { } } } - -- 2.39.5