Skip to content

Commit

Permalink
refactor: Refactor variable names for improved clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
code0xff committed Oct 29, 2024
1 parent dd58109 commit eb0b8c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions frame/cosmos/x/auth/src/sigverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ use ripemd::Digest;
use sp_core::{ecdsa, sha2_256, ByteArray, Get, H160};
use sp_runtime::SaturatedConversion;

const ECDSA_SIGNATURE_LEN: usize = 65;

pub struct SigVerificationDecorator<T>(PhantomData<T>);
impl<T> AnteDecorator for SigVerificationDecorator<T>
where
Expand Down Expand Up @@ -144,11 +146,11 @@ pub fn ecdsa_verify_prehashed(
};

match signature.len() {
64 => (0..=3).any(|rec_id| {
let mut rec_sig = [0u8; 65];
rec_sig[..64].copy_from_slice(signature);
rec_sig[64] = rec_id;
let sig = ecdsa::Signature::from(rec_sig);
64 => (0..=3).any(|recovery_id| {
let mut signature_inner = [0u8; ECDSA_SIGNATURE_LEN];
signature_inner[..ECDSA_SIGNATURE_LEN - 1].copy_from_slice(signature);
signature_inner[ECDSA_SIGNATURE_LEN - 1] = recovery_id;
let sig = ecdsa::Signature::from(signature_inner);
sp_io::crypto::ecdsa_verify_prehashed(&sig, message_hash, &pub_key)
}),
65 => ecdsa::Signature::try_from(signature).map_or(false, |sig| {
Expand Down
10 changes: 5 additions & 5 deletions vendor/composable/cosmwasm/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ impl<T: Config> Pallet<T> {
Err(_) => return false,
};

(0..=3).any(|rec_id| {
let mut rec_sig = [0_u8; SUBSTRATE_ECDSA_SIGNATURE_LEN];
rec_sig[..SUBSTRATE_ECDSA_SIGNATURE_LEN - 1].copy_from_slice(signature);
rec_sig[SUBSTRATE_ECDSA_SIGNATURE_LEN - 1] = rec_id;
let sig = ecdsa::Signature::from(rec_sig);
(0..=3).any(|recovery_id| {
let mut signature_inner = [0_u8; SUBSTRATE_ECDSA_SIGNATURE_LEN];
signature_inner[..SUBSTRATE_ECDSA_SIGNATURE_LEN - 1].copy_from_slice(signature);
signature_inner[SUBSTRATE_ECDSA_SIGNATURE_LEN - 1] = recovery_id;
let sig = ecdsa::Signature::from(signature_inner);
sp_io::crypto::ecdsa_verify_prehashed(&sig, message_hash, &public_key)
})
}
Expand Down

0 comments on commit eb0b8c8

Please sign in to comment.