pub trait KeyCodec {
type Pair: PairTrait;
type PrivateKey: Clone;
type PublicKey: Clone;
type Address;
const KEY_TYPE: &'static str;
// Required methods
fn derive_public(private_key: &Self::PrivateKey) -> Self::PublicKey;
fn derive_address(public_key: &Self::PublicKey) -> Result<Self::Address>;
fn encode_private(private_key: &Self::PrivateKey) -> Result<String>;
fn decode_private(encoded: &str) -> Result<Self::PrivateKey>;
fn encode_public(public_key: &Self::PublicKey) -> Result<String>;
fn decode_public(encoded: &str) -> Result<Self::PublicKey>;
fn encode_address(address: &Self::Address) -> Result<String>;
fn decode_address(encoded: &str) -> Result<Self::Address>;
fn random_private() -> Result<Self::PrivateKey>;
fn import_suri(
suri: &str,
password: Option<&str>,
) -> Result<Self::PrivateKey>;
}Expand description
Trait describing how to convert to and from string representations for key material, and how to generate/import keys for keyring operations.
Required Associated Constants§
Required Associated Types§
Sourcetype PrivateKey: Clone
type PrivateKey: Clone
Private key wrapper type.
Required Methods§
Sourcefn derive_public(private_key: &Self::PrivateKey) -> Self::PublicKey
fn derive_public(private_key: &Self::PrivateKey) -> Self::PublicKey
Derive the public key from the provided private key.
Sourcefn derive_address(public_key: &Self::PublicKey) -> Result<Self::Address>
fn derive_address(public_key: &Self::PublicKey) -> Result<Self::Address>
Derive the address from the provided public key.
Sourcefn encode_private(private_key: &Self::PrivateKey) -> Result<String>
fn encode_private(private_key: &Self::PrivateKey) -> Result<String>
Encode private key for storage.
Sourcefn decode_private(encoded: &str) -> Result<Self::PrivateKey>
fn decode_private(encoded: &str) -> Result<Self::PrivateKey>
Decode private key from storage.
Sourcefn encode_public(public_key: &Self::PublicKey) -> Result<String>
fn encode_public(public_key: &Self::PublicKey) -> Result<String>
Encode public key for storage.
Sourcefn decode_public(encoded: &str) -> Result<Self::PublicKey>
fn decode_public(encoded: &str) -> Result<Self::PublicKey>
Decode public key from storage.
Sourcefn encode_address(address: &Self::Address) -> Result<String>
fn encode_address(address: &Self::Address) -> Result<String>
Encode address for storage.
Sourcefn decode_address(encoded: &str) -> Result<Self::Address>
fn decode_address(encoded: &str) -> Result<Self::Address>
Decode address from storage.
Sourcefn random_private() -> Result<Self::PrivateKey>
fn random_private() -> Result<Self::PrivateKey>
Generate a new random private key.
Sourcefn import_suri(suri: &str, password: Option<&str>) -> Result<Self::PrivateKey>
fn import_suri(suri: &str, password: Option<&str>) -> Result<Self::PrivateKey>
Import a private key from a SURI (mnemonic/derivation path).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".