Trait sp_application_crypto::RuntimePublic

source ·
pub trait RuntimePublic: Sized {
    type Signature: Debug + Eq + PartialEq + Clone;

    // Required methods
    fn all(key_type: KeyTypeId) -> Vec<Self>;
    fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self;
    fn sign<M: AsRef<[u8]>>(
        &self,
        key_type: KeyTypeId,
        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

Runtime interface for a public key.

Required Associated Types§

source

type Signature: Debug + Eq + PartialEq + Clone

The signature that will be generated when signing with the corresponding private key.

Required Methods§

source

fn all(key_type: KeyTypeId) -> Vec<Self>

Returns all public keys for the given key type in the keystore.

source

fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self

Generate a public/private pair for the given key type with an optional seed and store it in the keystore.

The seed needs to be valid utf8.

Returns the generated public key.

source

fn sign<M: AsRef<[u8]>>( &self, key_type: KeyTypeId, 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 using the given key type.

Returns the signature or None if the private key could not be found or some other error occurred.

source

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.

source

fn to_raw_vec(&self) -> Vec<u8>

Returns Self as raw vec.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl RuntimePublic for sp_application_crypto::ecdsa::Public

§

type Signature = CryptoBytes<sp_core::::ecdsa::Signature::{constant#0}, (SignatureTag, EcdsaTag)>

source§

impl RuntimePublic for sp_application_crypto::ed25519::Public

§

type Signature = CryptoBytes<sp_core::::ed25519::Signature::{constant#0}, (SignatureTag, Ed25519Tag)>

source§

impl RuntimePublic for sp_application_crypto::sr25519::Public

§

type Signature = CryptoBytes<sp_core::::sr25519::Signature::{constant#0}, (SignatureTag, Sr25519Tag)>