Adds support for inspecting a hex encoded public key (#7344)

* Adds support for inspecting a hex encoded public key

This adds support for inspecting hex encoded public keys to subkey. The
command looks like:

`subkey inspect --public 0xPUBLICHEX`

* Update client/cli/src/commands/utils.rs

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
Bastian Köcher
2020-10-17 09:43:46 +02:00
committed by GitHub
parent da8ce4f258
commit 158fdecc0b
7 changed files with 139 additions and 26 deletions
+26 -1
View File
@@ -583,7 +583,17 @@ impl<T: Sized + AsMut<[u8]> + AsRef<[u8]> + Default + Derive> Ss58Codec for T {
/// Trait suitable for typical cryptographic PKI key public type.
pub trait Public:
AsRef<[u8]> + AsMut<[u8]> + Default + Derive + CryptoType + PartialEq + Eq + Clone + Send + Sync
AsRef<[u8]>
+ AsMut<[u8]>
+ Default
+ Derive
+ CryptoType
+ PartialEq
+ Eq
+ Clone
+ Send
+ Sync
+ for<'a> TryFrom<&'a [u8]>
{
/// A new instance from the given slice.
///
@@ -751,6 +761,14 @@ mod dummy {
}
}
impl<'a> TryFrom<&'a [u8]> for Dummy {
type Error = ();
fn try_from(_: &'a [u8]) -> Result<Self, ()> {
Ok(Self)
}
}
impl CryptoType for Dummy {
type Pair = Dummy;
}
@@ -1108,6 +1126,13 @@ mod tests {
&mut []
}
}
impl<'a> TryFrom<&'a [u8]> for TestPublic {
type Error = ();
fn try_from(_: &'a [u8]) -> Result<Self, ()> {
Ok(Self)
}
}
impl CryptoType for TestPublic {
type Pair = TestPair;
}