Skip to content
Snippets Groups Projects
Commit 54a89f80 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

merge new owner key and revocation signature

parent f3bab166
No related branches found
No related tags found
No related merge requests found
...@@ -679,7 +679,7 @@ validate the owned identity (must meet the main wot requirements) ...@@ -679,7 +679,7 @@ validate the owned identity (must meet the main wot requirements)
```rust ```rust
new_key: T::AccountId new_key: T::AccountId
new_key_sig: T::NewOwnerKeySignature new_key_sig: T::Signature
``` ```
</details> </details>
...@@ -699,7 +699,7 @@ The origin should be the old identity owner key. ...@@ -699,7 +699,7 @@ The origin should be the old identity owner key.
```rust ```rust
idty_index: T::IdtyIndex idty_index: T::IdtyIndex
revocation_key: T::AccountId revocation_key: T::AccountId
revocation_sig: T::RevocationSignature revocation_sig: T::Signature
``` ```
</details> </details>
...@@ -732,7 +732,7 @@ change sufficient ref count for given key ...@@ -732,7 +732,7 @@ change sufficient ref count for given key
```rust ```rust
account_id: T::AccountId account_id: T::AccountId
payload_sig: T::NewOwnerKeySignature payload_sig: T::Signature
``` ```
</details> </details>
......
...@@ -129,12 +129,10 @@ impl pallet_identity::Config for Test { ...@@ -129,12 +129,10 @@ impl pallet_identity::Config for Test {
type IdtyIndex = IdtyIndex; type IdtyIndex = IdtyIndex;
type AccountLinker = (); type AccountLinker = ();
type IdtyRemovalOtherReason = IdtyRemovalWotReason; type IdtyRemovalOtherReason = IdtyRemovalWotReason;
type NewOwnerKeySigner = UintAuthorityId; type Signer = UintAuthorityId;
type NewOwnerKeySignature = TestSignature; type Signature = TestSignature;
type OnIdtyChange = DuniterWot; type OnIdtyChange = DuniterWot;
type RemoveIdentityConsumers = (); type RemoveIdentityConsumers = ();
type RevocationSigner = UintAuthorityId;
type RevocationSignature = TestSignature;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
......
...@@ -107,8 +107,8 @@ fn create_identities<T: Config>(i: u32) -> Result<(), &'static str> { ...@@ -107,8 +107,8 @@ fn create_identities<T: Config>(i: u32) -> Result<(), &'static str> {
benchmarks! { benchmarks! {
where_clause { where_clause {
where where
T::NewOwnerKeySignature: From<sp_core::sr25519::Signature>, T::Signature: From<sp_core::sr25519::Signature>,
T::RevocationSignature: From<sp_core::sr25519::Signature>, T::Signature: From<sp_core::sr25519::Signature>,
T::AccountId: From<AccountId32>, T::AccountId: From<AccountId32>,
T::IdtyIndex: From<u32>, T::IdtyIndex: From<u32>,
} }
......
...@@ -105,17 +105,13 @@ pub mod pallet { ...@@ -105,17 +105,13 @@ pub mod pallet {
type IdtyRemovalOtherReason: Clone + Codec + Debug + Eq + TypeInfo; type IdtyRemovalOtherReason: Clone + Codec + Debug + Eq + TypeInfo;
/// On identity confirmed by its owner /// On identity confirmed by its owner
type OnIdtyChange: OnIdtyChange<Self>; type OnIdtyChange: OnIdtyChange<Self>;
/// Signing key of new owner key payload /// Signing key of a payload
type NewOwnerKeySigner: IdentifyAccount<AccountId = Self::AccountId>; type Signer: IdentifyAccount<AccountId = Self::AccountId>;
/// Signature of new owner key payload /// Signature of a payload
type NewOwnerKeySignature: Parameter + Verify<Signer = Self::NewOwnerKeySigner>; type Signature: Parameter + Verify<Signer = Self::Signer>;
/// Handle the logic that removes all identity consumers. /// Handle the logic that removes all identity consumers.
/// "identity consumers" meaning all things that rely on the existence of the identity. /// "identity consumers" meaning all things that rely on the existence of the identity.
type RemoveIdentityConsumers: RemoveIdentityConsumers<Self::IdtyIndex>; 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. /// 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 RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Type representing the weight of this pallet /// Type representing the weight of this pallet
...@@ -430,7 +426,7 @@ pub mod pallet { ...@@ -430,7 +426,7 @@ pub mod pallet {
pub fn change_owner_key( pub fn change_owner_key(
origin: OriginFor<T>, origin: OriginFor<T>,
new_key: T::AccountId, new_key: T::AccountId,
new_key_sig: T::NewOwnerKeySignature, new_key_sig: T::Signature,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
// verification phase // verification phase
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
...@@ -515,7 +511,7 @@ pub mod pallet { ...@@ -515,7 +511,7 @@ pub mod pallet {
origin: OriginFor<T>, origin: OriginFor<T>,
idty_index: T::IdtyIndex, idty_index: T::IdtyIndex,
revocation_key: T::AccountId, revocation_key: T::AccountId,
revocation_sig: T::RevocationSignature, revocation_sig: T::Signature,
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
let _ = ensure_signed(origin)?; let _ = ensure_signed(origin)?;
...@@ -619,7 +615,7 @@ pub mod pallet { ...@@ -619,7 +615,7 @@ pub mod pallet {
pub fn link_account( pub fn link_account(
origin: OriginFor<T>, // origin must have an identity index origin: OriginFor<T>, // origin must have an identity index
account_id: T::AccountId, // id of account to link (must sign the payload) account_id: T::AccountId, // id of account to link (must sign the payload)
payload_sig: T::NewOwnerKeySignature, // signature with linked identity payload_sig: T::Signature, // signature with linked identity
) -> DispatchResultWithPostInfo { ) -> DispatchResultWithPostInfo {
// verif // verif
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
......
...@@ -110,12 +110,10 @@ impl pallet_identity::Config for Test { ...@@ -110,12 +110,10 @@ impl pallet_identity::Config for Test {
type IdtyIndex = u64; type IdtyIndex = u64;
type AccountLinker = (); type AccountLinker = ();
type IdtyRemovalOtherReason = (); type IdtyRemovalOtherReason = ();
type NewOwnerKeySigner = AccountPublic; type Signer = AccountPublic;
type NewOwnerKeySignature = Signature; type Signature = Signature;
type OnIdtyChange = (); type OnIdtyChange = ();
type RemoveIdentityConsumers = (); type RemoveIdentityConsumers = ();
type RevocationSigner = AccountPublic;
type RevocationSignature = Signature;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
......
...@@ -156,12 +156,10 @@ impl pallet_identity::Config for Test { ...@@ -156,12 +156,10 @@ impl pallet_identity::Config for Test {
type IdtyIndex = u64; type IdtyIndex = u64;
type AccountLinker = (); type AccountLinker = ();
type IdtyRemovalOtherReason = (); type IdtyRemovalOtherReason = ();
type NewOwnerKeySigner = AccountPublic; type Signer = AccountPublic;
type NewOwnerKeySignature = Signature; type Signature = Signature;
type OnIdtyChange = (); type OnIdtyChange = ();
type RemoveIdentityConsumers = (); type RemoveIdentityConsumers = ();
type RevocationSigner = AccountPublic;
type RevocationSignature = Signature;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = (); type WeightInfo = ();
} }
......
...@@ -94,35 +94,6 @@ impl From<IdtyData> for pallet_universal_dividend::FirstEligibleUd { ...@@ -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))] #[cfg_attr(feature = "std", derive(Deserialize, Serialize))]
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct SmithMembershipMetaData<SessionKeysWrapper> { pub struct SmithMembershipMetaData<SessionKeysWrapper> {
......
...@@ -468,12 +468,10 @@ macro_rules! pallets_config { ...@@ -468,12 +468,10 @@ macro_rules! pallets_config {
type AccountLinker = Account; type AccountLinker = Account;
type IdtyNameValidator = IdtyNameValidatorImpl; type IdtyNameValidator = IdtyNameValidatorImpl;
type IdtyRemovalOtherReason = pallet_duniter_wot::IdtyRemovalWotReason; type IdtyRemovalOtherReason = pallet_duniter_wot::IdtyRemovalWotReason;
type NewOwnerKeySigner = <NewOwnerKeySignature as sp_runtime::traits::Verify>::Signer; type Signer = <Signature as sp_runtime::traits::Verify>::Signer;
type NewOwnerKeySignature = NewOwnerKeySignature; type Signature = Signature;
type OnIdtyChange = (common_runtime::handlers::OnIdtyChangeHandler<Runtime>, Wot, Quota, Account); type OnIdtyChange = (common_runtime::handlers::OnIdtyChangeHandler<Runtime>, Wot, Quota, Account);
type RemoveIdentityConsumers = RemoveIdentityConsumersImpl<Self>; type RemoveIdentityConsumers = RemoveIdentityConsumersImpl<Self>;
type RevocationSigner = <Signature as sp_runtime::traits::Verify>::Signer;
type RevocationSignature = Signature;
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>; type WeightInfo = common_runtime::weights::pallet_identity::WeightInfo<Runtime>;
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment