From 93820aa0f87475e4e87cc52041e53a2a99d8119b Mon Sep 17 00:00:00 2001 From: eNDdy Date: Wed, 2 Oct 2024 12:07:47 -0500 Subject: [PATCH] passkey --- pallets/passkey/src/lib.rs | 15 ++++++--------- pallets/passkey/src/tests.rs | 1 + 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pallets/passkey/src/lib.rs b/pallets/passkey/src/lib.rs index a2f04ca261..ee4a4a6796 100644 --- a/pallets/passkey/src/lib.rs +++ b/pallets/passkey/src/lib.rs @@ -16,8 +16,7 @@ rustdoc::invalid_codeblock_attributes, missing_docs )] -use common_primitives::utils::wrap_binary_data; -use common_runtime::extensions::check_nonce::CheckNonce; +use common_runtime::{extensions::check_nonce::CheckNonce, signature::check_signature}; use frame_support::{ dispatch::{DispatchInfo, GetDispatchInfo, PostDispatchInfo}, pallet_prelude::*, @@ -27,7 +26,7 @@ use frame_system::pallet_prelude::*; use pallet_transaction_payment::OnChargeTransaction; use sp_runtime::{ generic::Era, - traits::{Convert, Dispatchable, SignedExtension, Verify, Zero}, + traits::{Convert, Dispatchable, SignedExtension, Zero}, transaction_validity::{TransactionValidity, TransactionValidityError}, AccountId32, MultiSignature, }; @@ -315,14 +314,12 @@ impl PasskeySignatureCheck { signature: &MultiSignature, ) -> DispatchResult { let key = T::ConvertIntoAccountId32::convert((*signer).clone()); - let signed_payload: Vec = wrap_binary_data(signed_data.clone().into()); - let verified = signature.verify(&signed_payload[..], &key); - if verified { - Ok(()) - } else { - Err(Error::::InvalidAccountSignature.into()) + if !check_signature(signature, key, signed_data.clone()) { + return Err(Error::::InvalidAccountSignature.into()); } + + Ok(()) } } diff --git a/pallets/passkey/src/tests.rs b/pallets/passkey/src/tests.rs index 5cf0fa0077..79edcb2e32 100644 --- a/pallets/passkey/src/tests.rs +++ b/pallets/passkey/src/tests.rs @@ -1,6 +1,7 @@ //! Unit tests for the passkey module. use super::*; use crate::mock::Passkey; +use common_primitives::utils::wrap_binary_data; use frame_support::{assert_err, assert_noop, assert_ok, dispatch::RawOrigin}; use frame_system::{limits::BlockLength, Call as SystemCall}; use mock::*;