diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index 7ef780bfdf411858b576e7a291c63d75f843100e..e7b44b9c3a06abe12d11223189de02f641bf7fe2 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -679,7 +679,7 @@ validate the owned identity (must meet the main wot requirements) ```rust new_key: T::AccountId -new_key_sig: T::NewOwnerKeySignature +new_key_sig: T::Signature ``` </details> @@ -699,7 +699,7 @@ The origin should be the old identity owner key. ```rust idty_index: T::IdtyIndex revocation_key: T::AccountId -revocation_sig: T::RevocationSignature +revocation_sig: T::Signature ``` </details> @@ -732,7 +732,7 @@ change sufficient ref count for given key ```rust account_id: T::AccountId -payload_sig: T::NewOwnerKeySignature +payload_sig: T::Signature ``` </details> diff --git a/pallets/duniter-wot/src/mock.rs b/pallets/duniter-wot/src/mock.rs index 2eef61ea1027cc872dd7e7567cb3bd06579edd69..6d65720d3e48f15b4098779b1588682a9410928f 100644 --- a/pallets/duniter-wot/src/mock.rs +++ b/pallets/duniter-wot/src/mock.rs @@ -129,12 +129,10 @@ impl pallet_identity::Config for Test { type IdtyIndex = IdtyIndex; type AccountLinker = (); type IdtyRemovalOtherReason = IdtyRemovalWotReason; - type NewOwnerKeySigner = UintAuthorityId; - type NewOwnerKeySignature = TestSignature; + type Signer = UintAuthorityId; + type Signature = TestSignature; type OnIdtyChange = DuniterWot; type RemoveIdentityConsumers = (); - type RevocationSigner = UintAuthorityId; - type RevocationSignature = TestSignature; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/identity/src/benchmarking.rs b/pallets/identity/src/benchmarking.rs index a579b917b3261b8e4bc23b77ee9d2e3fff93673b..0f72bf76abf0c4d84764e97f3978544fdf19e54a 100644 --- a/pallets/identity/src/benchmarking.rs +++ b/pallets/identity/src/benchmarking.rs @@ -107,8 +107,8 @@ fn create_identities<T: Config>(i: u32) -> Result<(), &'static str> { benchmarks! { where_clause { where - T::NewOwnerKeySignature: From<sp_core::sr25519::Signature>, - T::RevocationSignature: From<sp_core::sr25519::Signature>, + T::Signature: From<sp_core::sr25519::Signature>, + T::Signature: From<sp_core::sr25519::Signature>, T::AccountId: From<AccountId32>, T::IdtyIndex: From<u32>, } diff --git a/pallets/identity/src/lib.rs b/pallets/identity/src/lib.rs index 810cd100ed3ee1247bd32c95310870aaf2f2b9dd..b636f3c7e4324faab63e94563425704db359a788 100644 --- a/pallets/identity/src/lib.rs +++ b/pallets/identity/src/lib.rs @@ -105,17 +105,13 @@ pub mod pallet { type IdtyRemovalOtherReason: Clone + Codec + Debug + Eq + TypeInfo; /// On identity confirmed by its owner type OnIdtyChange: OnIdtyChange<Self>; - /// Signing key of new owner key payload - type NewOwnerKeySigner: IdentifyAccount<AccountId = Self::AccountId>; - /// Signature of new owner key payload - type NewOwnerKeySignature: Parameter + Verify<Signer = Self::NewOwnerKeySigner>; + /// Signing key of a payload + type Signer: IdentifyAccount<AccountId = Self::AccountId>; + /// Signature of a payload + type Signature: Parameter + Verify<Signer = Self::Signer>; /// Handle the logic that removes all identity consumers. /// "identity consumers" meaning all things that rely on the existence of the identity. type RemoveIdentityConsumers: RemoveIdentityConsumers<Self::IdtyIndex>; - /// Signing key of revocation payload - type RevocationSigner: IdentifyAccount<AccountId = Self::AccountId>; - /// Signature of revocation payload - type RevocationSignature: Parameter + Verify<Signer = Self::RevocationSigner>; /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; /// Type representing the weight of this pallet @@ -430,7 +426,7 @@ pub mod pallet { pub fn change_owner_key( origin: OriginFor<T>, new_key: T::AccountId, - new_key_sig: T::NewOwnerKeySignature, + new_key_sig: T::Signature, ) -> DispatchResultWithPostInfo { // verification phase let who = ensure_signed(origin)?; @@ -515,7 +511,7 @@ pub mod pallet { origin: OriginFor<T>, idty_index: T::IdtyIndex, revocation_key: T::AccountId, - revocation_sig: T::RevocationSignature, + revocation_sig: T::Signature, ) -> DispatchResultWithPostInfo { let _ = ensure_signed(origin)?; @@ -617,9 +613,9 @@ pub mod pallet { #[pallet::call_index(8)] #[pallet::weight(T::WeightInfo::link_account())] pub fn link_account( - origin: OriginFor<T>, // origin must have an identity index - account_id: T::AccountId, // id of account to link (must sign the payload) - payload_sig: T::NewOwnerKeySignature, // signature with linked identity + origin: OriginFor<T>, // origin must have an identity index + account_id: T::AccountId, // id of account to link (must sign the payload) + payload_sig: T::Signature, // signature with linked identity ) -> DispatchResultWithPostInfo { // verif let who = ensure_signed(origin)?; diff --git a/pallets/identity/src/mock.rs b/pallets/identity/src/mock.rs index 24416a85dc9790a66f7cb0d67deceaa2244e5e7c..40038b7ed7186a0a7d11a4096ac9f6b6fc1bb87e 100644 --- a/pallets/identity/src/mock.rs +++ b/pallets/identity/src/mock.rs @@ -110,12 +110,10 @@ impl pallet_identity::Config for Test { type IdtyIndex = u64; type AccountLinker = (); type IdtyRemovalOtherReason = (); - type NewOwnerKeySigner = AccountPublic; - type NewOwnerKeySignature = Signature; + type Signer = AccountPublic; + type Signature = Signature; type OnIdtyChange = (); type RemoveIdentityConsumers = (); - type RevocationSigner = AccountPublic; - type RevocationSignature = Signature; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/quota/src/mock.rs b/pallets/quota/src/mock.rs index 39431616bc73b797c8fa1c41f080064018f9ff04..17b825fc4e12e0a2a707c69577a0d1f922d81ed0 100644 --- a/pallets/quota/src/mock.rs +++ b/pallets/quota/src/mock.rs @@ -156,12 +156,10 @@ impl pallet_identity::Config for Test { type IdtyIndex = u64; type AccountLinker = (); type IdtyRemovalOtherReason = (); - type NewOwnerKeySigner = AccountPublic; - type NewOwnerKeySignature = Signature; + type Signer = AccountPublic; + type Signature = Signature; type OnIdtyChange = (); type RemoveIdentityConsumers = (); - type RevocationSigner = AccountPublic; - type RevocationSignature = Signature; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/runtime/common/src/entities.rs b/runtime/common/src/entities.rs index 5df05770f0c22eb5694bbb813803f190467f0fd4..823ae2a71c74fe098e3334998c2065c39f4d7770 100644 --- a/runtime/common/src/entities.rs +++ b/runtime/common/src/entities.rs @@ -94,35 +94,6 @@ impl From<IdtyData> for pallet_universal_dividend::FirstEligibleUd { } } -pub struct NewOwnerKeySigner(sp_core::sr25519::Public); - -impl sp_runtime::traits::IdentifyAccount for NewOwnerKeySigner { - type AccountId = crate::AccountId; - fn into_account(self) -> crate::AccountId { - <[u8; 32]>::from(self.0).into() - } -} - -#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct NewOwnerKeySignature(sp_core::sr25519::Signature); - -impl sp_runtime::traits::Verify for NewOwnerKeySignature { - type Signer = NewOwnerKeySigner; - fn verify<L: sp_runtime::traits::Lazy<[u8]>>(&self, msg: L, signer: &crate::AccountId) -> bool { - use sp_core::crypto::ByteArray as _; - match sp_core::sr25519::Public::from_slice(signer.as_ref()) { - Ok(signer) => self.0.verify(msg, &signer), - Err(()) => false, - } - } -} - -impl From<sp_core::sr25519::Signature> for NewOwnerKeySignature { - fn from(a: sp_core::sr25519::Signature) -> Self { - NewOwnerKeySignature(a) - } -} - #[cfg_attr(feature = "std", derive(Deserialize, Serialize))] #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct SmithMembershipMetaData<SessionKeysWrapper> { diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 9d0eb6a3cd3ba10a19fe8b7a83bac8a4cf5349a6..df8cb7a91e7e813fe23831e79785e1646e688dd4 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -468,12 +468,10 @@ macro_rules! pallets_config { type AccountLinker = Account; type IdtyNameValidator = IdtyNameValidatorImpl; type IdtyRemovalOtherReason = pallet_duniter_wot::IdtyRemovalWotReason; - type NewOwnerKeySigner = <NewOwnerKeySignature as sp_runtime::traits::Verify>::Signer; - type NewOwnerKeySignature = NewOwnerKeySignature; + type Signer = <Signature as sp_runtime::traits::Verify>::Signer; + type Signature = Signature; type OnIdtyChange = (common_runtime::handlers::OnIdtyChangeHandler<Runtime>, Wot, Quota, Account); type RemoveIdentityConsumers = RemoveIdentityConsumersImpl<Self>; - type RevocationSigner = <Signature as sp_runtime::traits::Verify>::Signer; - type RevocationSignature = Signature; type RuntimeEvent = RuntimeEvent; type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>; #[cfg(feature = "runtime-benchmarks")]