Refactor crypto-related traits implementations in term of Public/Signature Bytes (#3806)

Another simple refactory to prune some duplicate code

Follow up of: https://github.com/paritytech/polkadot-sdk/pull/3684
This commit is contained in:
Davide Galassi
2024-03-25 15:26:38 +00:00
committed by GitHub
parent ce7613a49f
commit 9d122401f1
11 changed files with 254 additions and 658 deletions
@@ -26,7 +26,7 @@ pub use sp_core::crypto::{DeriveError, Pair, SecretStringError};
#[doc(hidden)]
pub use sp_core::{
self,
crypto::{ByteArray, CryptoType, Derive, IsWrappedBy, Public, UncheckedFrom, Wraps},
crypto::{ByteArray, CryptoType, Derive, IsWrappedBy, Public, Signature, UncheckedFrom, Wraps},
RuntimeDebug,
};
@@ -505,6 +505,12 @@ macro_rules! app_crypto_signature_common {
}
}
impl AsMut<[u8]> for Signature {
fn as_mut(&mut self) -> &mut [u8] {
self.0.as_mut()
}
}
impl $crate::AppSignature for Signature {
type Generic = $sig;
}
@@ -525,6 +531,12 @@ macro_rules! app_crypto_signature_common {
}
}
impl $crate::Signature for Signature {}
impl $crate::ByteArray for Signature {
const LEN: usize = <$sig>::LEN;
}
impl Signature {
/// Convert into wrapped generic signature type.
pub fn into_inner(self) -> $sig {