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)
```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>
......
......@@ -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")]
......
......@@ -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>,
}
......
......@@ -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)?;
......@@ -619,7 +615,7 @@ pub mod pallet {
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
payload_sig: T::Signature, // signature with linked identity
) -> DispatchResultWithPostInfo {
// verif
let who = ensure_signed(origin)?;
......
......@@ -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")]
......
......@@ -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 = ();
}
......
......@@ -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> {
......
......@@ -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")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment