From 66c0e960aa1384f28e56aa6169ddfb7a0ee5a4ad Mon Sep 17 00:00:00 2001 From: yahortsaryk Date: Tue, 7 Nov 2023 22:06:10 +0100 Subject: [PATCH] chore: clarification comments are added for sig verification --- pallets/ddc-clusters/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index 62931d12b..150e2d347 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -242,6 +242,7 @@ pub mod pallet { let caller_id = ensure_signed(origin)?; let cluster = Clusters::::try_get(&cluster_id).map_err(|_| Error::::ClusterDoesNotExist)?; + let is_cluster_manager = Self::validate_signature(&cluster.manager_id, &signature, &data)?; ensure!(is_cluster_manager, Error::::SignatureMismatch); @@ -260,6 +261,9 @@ pub mod pallet { signature: &T::Signature, data: &Vec, ) -> Result> { + // In the Runtime configuration, we have the AccountId type set to <::Signer as IdentifyAccount>::AccountId; The Signer type is set to MultiSigner + // were AccountId type is AccountId32 that is always 32 bytes in length let pub_key: [u8; 32] = match signer_id.encode().as_slice()[..].try_into() { Ok(pub_key) => pub_key, Err(_) => return Err(Error::::SignatureValidationFailed),