From 6dc639c7e3f46b22f094e124df22e18c031a70ea Mon Sep 17 00:00:00 2001 From: Hugo Trentesaux <hugo@trentesaux.fr> Date: Fri, 10 Nov 2023 16:31:49 +0100 Subject: [PATCH] merge signature error types --- pallets/identity/src/lib.rs | 14 +++++--------- pallets/identity/src/tests.rs | 10 +++++----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index b636f3c7e..e5b5623f6 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -469,7 +469,7 @@ pub mod pallet { ensure!( (NEW_OWNER_KEY_PAYLOAD_PREFIX, new_key_payload) .using_encoded(|bytes| new_key_sig.verify(bytes, &new_key)), - Error::<T>::InvalidNewOwnerKeySig + Error::<T>::InvalidSignature ); // Apply phase @@ -543,7 +543,7 @@ pub mod pallet { ensure!( (REVOCATION_PAYLOAD_PREFIX, revocation_payload) .using_encoded(|bytes| revocation_sig.verify(bytes, &revocation_key)), - Error::<T>::InvalidRevocationSig + Error::<T>::InvalidSignature ); // finally if all checks pass, remove identity @@ -630,7 +630,7 @@ pub mod pallet { ensure!( (LINK_IDTY_PAYLOAD_PREFIX, payload) .using_encoded(|bytes| payload_sig.verify(bytes, &account_id)), - Error::<T>::InvalidLinkAccountSig + Error::<T>::InvalidSignature ); // apply Self::do_link_account(account_id, idty_index); @@ -667,14 +667,10 @@ pub mod pallet { IdtyNotValidated, /// Identity not yet renewable IdtyNotYetRenewable, - /// New owner key payload signature is invalid - InvalidNewOwnerKeySig, - /// Link account payload signature is invalid - InvalidLinkAccountSig, + /// payload signature is invalid + InvalidSignature, /// Revocation key is invalid InvalidRevocationKey, - /// Revocation payload signature is invalid - InvalidRevocationSig, /// Identity creation period is not respected NotRespectIdtyCreationPeriod, /// Not the same identity name diff --git a/pallets/identity/src/tests.rs b/pallets/identity/src/tests.rs index 0ab95d51e..01e24905b 100644 --- a/pallets/identity/src/tests.rs +++ b/pallets/identity/src/tests.rs @@ -245,7 +245,7 @@ fn test_change_owner_key() { (NEW_OWNER_KEY_PAYLOAD_PREFIX, new_key_payload.clone()).encode() ) ), - Error::<Test>::InvalidNewOwnerKeySig + Error::<Test>::InvalidSignature ); // Payload must be prefixed @@ -255,7 +255,7 @@ fn test_change_owner_key() { account(10).id, test_signature(account(10).signer, new_key_payload.clone().encode()) ), - Error::<Test>::InvalidNewOwnerKeySig + Error::<Test>::InvalidSignature ); // New owner key should not be used by another identity @@ -393,7 +393,7 @@ fn test_link_account() { (LINK_IDTY_PAYLOAD_PREFIX, payload.clone()).encode() ) ), - Error::<Test>::InvalidLinkAccountSig + Error::<Test>::InvalidSignature ); // Payload must be prefixed @@ -403,7 +403,7 @@ fn test_link_account() { account(10).id, test_signature(account(10).signer, payload.clone().encode()) ), - Error::<Test>::InvalidLinkAccountSig + Error::<Test>::InvalidSignature ); // Alice can change her owner key @@ -555,7 +555,7 @@ fn test_idty_revocation() { account(1).id, test_signature(account(1).signer, revocation_payload.encode()) ), - Err(Error::<Test>::InvalidRevocationSig.into()) + Err(Error::<Test>::InvalidSignature.into()) ); // Anyone can submit a revocation payload -- GitLab