Skip to content

Commit

Permalink
chore: clarification comments are added for sig verification
Browse files Browse the repository at this point in the history
  • Loading branch information
yahortsaryk committed Nov 7, 2023
1 parent 14b52fc commit 66c0e96
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pallets/ddc-clusters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ pub mod pallet {
let caller_id = ensure_signed(origin)?;
let cluster =
Clusters::<T>::try_get(&cluster_id).map_err(|_| Error::<T>::ClusterDoesNotExist)?;

let is_cluster_manager =
Self::validate_signature(&cluster.manager_id, &signature, &data)?;
ensure!(is_cluster_manager, Error::<T>::SignatureMismatch);
Expand All @@ -260,6 +261,9 @@ pub mod pallet {
signature: &T::Signature,
data: &Vec<u8>,
) -> Result<bool, Error<T>> {
// In the Runtime configuration, we have the AccountId type set to <<MultiSignature as
// Verify>::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::<T>::SignatureValidationFailed),
Expand Down

0 comments on commit 66c0e96

Please sign in to comment.