pub trait RuntimeAppPublic: Sized {
type Signature: Codec + Debug + MaybeHash + Eq + PartialEq + Clone + TypeInfo;
const ID: KeyTypeId;
const CRYPTO_ID: CryptoTypeId;
// Required methods
fn all() -> Vec<Self> ⓘ;
fn generate_pair(seed: Option<Vec<u8>>) -> Self;
fn sign<M: AsRef<[u8]>>(&self, msg: &M) -> Option<Self::Signature>;
fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool;
fn to_raw_vec(&self) -> Vec<u8> ⓘ;
}
Expand description
A runtime interface for an application’s public key.
Required Associated Types§
Required Associated Constants§
sourceconst CRYPTO_ID: CryptoTypeId
const CRYPTO_ID: CryptoTypeId
The identifier of the crypto type of this application-specific key type.
Required Methods§
sourcefn generate_pair(seed: Option<Vec<u8>>) -> Self
fn generate_pair(seed: Option<Vec<u8>>) -> Self
Generate a public/private pair with an optional seed
and store it in the keystore.
The seed
needs to be valid utf8.
Returns the generated public key.
sourcefn sign<M: AsRef<[u8]>>(&self, msg: &M) -> Option<Self::Signature>
fn sign<M: AsRef<[u8]>>(&self, msg: &M) -> Option<Self::Signature>
Sign the given message with the corresponding private key of this public key.
The private key will be requested from the keystore.
Returns the signature or None
if the private key could not be found or some other error
occurred.
sourcefn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool
fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool
Verify that the given signature matches the given message using this public key.
sourcefn to_raw_vec(&self) -> Vec<u8> ⓘ
fn to_raw_vec(&self) -> Vec<u8> ⓘ
Returns Self
as raw vec.