referrerpolicy=no-referrer-when-downgrade

Trait RuntimeAppPublic

pub trait RuntimeAppPublic: Sized {
    type Signature: Debug + Eq + PartialEq + Clone + TypeInfo + Codec;

    const ID: KeyTypeId;

    // Required methods
    fn all() -> Vec<Self>;
    fn generate_pair(seed: Option<Vec<u8>>) -> Self;
    fn sign<M>(&self, msg: &M) -> Option<Self::Signature>
       where M: AsRef<[u8]>;
    fn verify<M>(&self, msg: &M, signature: &Self::Signature) -> bool
       where M: AsRef<[u8]>;
    fn generate_proof_of_possession(&mut self) -> Option<Self::Signature>;
    fn verify_proof_of_possession(&self, pop: &Self::Signature) -> bool;
    fn to_raw_vec(&self) -> Vec<u8> ;
}
Expand description

Runtime interface for an application’s public key.

Required Associated Constants§

const ID: KeyTypeId

An identifier for this application-specific key type.

Required Associated Types§

type Signature: Debug + Eq + PartialEq + Clone + TypeInfo + Codec

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

Required Methods§

fn all() -> Vec<Self>

Returns all public keys for this application in the keystore.

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.

fn sign<M>(&self, msg: &M) -> Option<Self::Signature>
where M: AsRef<[u8]>,

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.

fn verify<M>(&self, msg: &M, signature: &Self::Signature) -> bool
where M: AsRef<[u8]>,

Verify that the given signature matches the given message using this public key.

fn generate_proof_of_possession(&mut self) -> Option<Self::Signature>

Generate proof of possession of the corresponding public key

The private key will be requested from the keystore using the given key type.

Returns the proof of possession as a signature or None if it failed or is not able to do so.

fn verify_proof_of_possession(&self, pop: &Self::Signature) -> bool

Verify that the given proof of possession is valid for the corresponding public key.

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

Returns Self as raw vec.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl RuntimeAppPublic for UintAuthorityId

Source§

const ID: KeyTypeId = key_types::DUMMY

Source§

type Signature = TestSignature

§

impl<T> RuntimeAppPublic for T
where T: AppPublic + AsRef<<T as AppPublic>::Generic> + AsMut<<T as AppPublic>::Generic>, <T as AppPublic>::Generic: RuntimePublic, <T as AppCrypto>::Signature: TypeInfo + Codec + From<<<T as AppPublic>::Generic as RuntimePublic>::Signature> + AsRef<<<T as AppPublic>::Generic as RuntimePublic>::Signature>,

§

const ID: KeyTypeId = <T as AppCrypto>::ID

§

type Signature = <T as AppCrypto>::Signature