mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
im-online: use generic crypto (#3500)
* im-online: support using ed25519 and sr25519 crypto * app-crypto: add trait bounds to RuntimePublic::Signature * im-online: add missing type annotations * authority-discovery: depend on im-online module and use its crypto * node: set i'm online crypto to sr25519 * node: bump spec_version * rpc: don't generate i'm online pubkey in insert_key method * im-online: fix docs * im-online: move app crypto packages * aura: move app crypto packages
This commit is contained in:
committed by
Bastian Köcher
parent
b5c6cc3996
commit
574f68fd7e
@@ -17,6 +17,7 @@
|
||||
use primitives::crypto::{KeyTypeId, CryptoType, IsWrappedBy, Public};
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::crypto::Pair;
|
||||
use codec::Codec;
|
||||
|
||||
/// An application-specific key.
|
||||
pub trait AppKey: 'static + Send + Sync + Sized + CryptoType + Clone {
|
||||
@@ -72,7 +73,7 @@ pub trait AppSignature: AppKey + Eq + PartialEq + MaybeDebugHash {
|
||||
/// A runtime interface for a public key.
|
||||
pub trait RuntimePublic: Sized {
|
||||
/// The signature that will be generated when signing with the corresponding private key.
|
||||
type Signature;
|
||||
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;
|
||||
|
||||
/// Returns all public keys for the given key type in the keystore.
|
||||
fn all(key_type: KeyTypeId) -> crate::Vec<Self>;
|
||||
@@ -97,7 +98,7 @@ pub trait RuntimePublic: Sized {
|
||||
/// A runtime interface for an application's public key.
|
||||
pub trait RuntimeAppPublic: Sized {
|
||||
/// The signature that will be generated when signing with the corresponding private key.
|
||||
type Signature;
|
||||
type Signature: Codec + MaybeDebugHash + Eq + PartialEq + Clone;
|
||||
|
||||
/// Returns all public keys for this application in the keystore.
|
||||
fn all() -> crate::Vec<Self>;
|
||||
|
||||
@@ -23,38 +23,38 @@ use substrate_client::decl_runtime_apis;
|
||||
use rstd::vec::Vec;
|
||||
use sr_primitives::ConsensusEngineId;
|
||||
|
||||
mod app_sr25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, sr25519};
|
||||
app_crypto!(sr25519, AURA);
|
||||
}
|
||||
|
||||
pub mod sr25519 {
|
||||
mod app_sr25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, sr25519};
|
||||
app_crypto!(sr25519, AURA);
|
||||
}
|
||||
|
||||
/// An Aura authority keypair using S/R 25519 as its crypto.
|
||||
#[cfg(feature = "std")]
|
||||
pub type AuthorityPair = super::app_sr25519::Pair;
|
||||
pub type AuthorityPair = app_sr25519::Pair;
|
||||
|
||||
/// An Aura authority signature using S/R 25519 as its crypto.
|
||||
pub type AuthoritySignature = super::app_sr25519::Signature;
|
||||
pub type AuthoritySignature = app_sr25519::Signature;
|
||||
|
||||
/// An Aura authority identifier using S/R 25519 as its crypto.
|
||||
pub type AuthorityId = super::app_sr25519::Public;
|
||||
}
|
||||
|
||||
mod app_ed25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, ed25519};
|
||||
app_crypto!(ed25519, AURA);
|
||||
pub type AuthorityId = app_sr25519::Public;
|
||||
}
|
||||
|
||||
pub mod ed25519 {
|
||||
mod app_ed25519 {
|
||||
use app_crypto::{app_crypto, key_types::AURA, ed25519};
|
||||
app_crypto!(ed25519, AURA);
|
||||
}
|
||||
|
||||
/// An Aura authority keypair using Ed25519 as its crypto.
|
||||
#[cfg(feature = "std")]
|
||||
pub type AuthorityPair = super::app_ed25519::Pair;
|
||||
pub type AuthorityPair = app_ed25519::Pair;
|
||||
|
||||
/// An Aura authority signature using Ed25519 as its crypto.
|
||||
pub type AuthoritySignature = super::app_ed25519::Signature;
|
||||
pub type AuthoritySignature = app_ed25519::Signature;
|
||||
|
||||
/// An Aura authority identifier using Ed25519 as its crypto.
|
||||
pub type AuthorityId = super::app_ed25519::Public;
|
||||
pub type AuthorityId = app_ed25519::Public;
|
||||
}
|
||||
|
||||
/// The `ConsensusEngineId` of AuRa.
|
||||
|
||||
@@ -162,7 +162,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
|
||||
Some(public) => public.0,
|
||||
None => {
|
||||
let maybe_public = match key_type {
|
||||
key_types::BABE | key_types::IM_ONLINE | key_types::SR25519 =>
|
||||
key_types::BABE | key_types::SR25519 =>
|
||||
sr25519::Pair::from_string(&suri, maybe_password)
|
||||
.map(|pair| pair.public().to_raw_vec()),
|
||||
key_types::GRANDPA | key_types::ED25519 =>
|
||||
|
||||
Reference in New Issue
Block a user