mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 02:31:03 +00:00
*: Refactor authority discovery (key mngmt, runtime API) (#3955)
* {core,srml}/authority-discovery: Move generic to specific session keys
* {srml,core}/authority-discovery: Verify signature outside of runtime
Given that the `core/authority-discovery` uses concrete authority
identifiers and signatures, one can verify a signature with the
authority discovery within `core`. Given the above, the `verify` runtime
api is obsolete and thus removed.
* *: Add authority discovery to the set of session keys
* *: Sign authority discovery DHT payload with keystore instead of runtime
Instead of calling a runtime function to sign a dht payload, which then
invokes the keystore, pass the keystore to the authority discovery
module and use it directly.
* core/authority-discovery: Give libp2p Kademlia time to start up
* core/authority-discovery: Move authorities priority group name to const
* node/runtime/src/lib.rs: Bump runtime spec version
* *: Fix lints and node/testing test failures
* *: Fix formatting
* core/authority-discovery: Box dht event channel in unit tests
* node/cli/src/service.rs: Fix future import
* node/cli/src/service.rs: Replace unwrap by expect with proof
* node/cli/src/chain_spec: Remove TODO for testnet key generation
* core/authority-discovery/src/lib: Remove scale encoding TODOs
* srml/authority-discovery: Make comment a doc comment
* core/authority-discovery: Remove unused StreamExt import
* node/runtime: Bump impl version to debug CI
* Test ci.
* Change the line width to 100.
* Revert "Change the line width to 100."
This reverts commit edff1f855bc71e0418bf3a967f81a35591d882e3.
* Fix a check for polkadot to work on forked repos.
* Revert "node/runtime: Bump impl version to debug CI"
This reverts commit 1a90903b4c929bc55a9e0a538af34b50b7f65139.
* Revert "Test ci."
This reverts commit a2c9df574e645158f77cd2b3d4d9355bcae33aab.
* Cargo.lock: Fix wrong lock file merge
* srml/authority-discovery: Keep track of new validator set not upcoming
* core/authority-discovery: Document key retrieval functions
This commit is contained in:
committed by
Bastian Köcher
parent
64f7ed04dc
commit
becc3b0a4f
@@ -6,14 +6,16 @@ description = "Authority discovery primitives"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "substrate-application-crypto", path = "../../application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
|
||||
rstd = { package = "sr-std", path = "../../sr-std", default-features = false }
|
||||
sr-api = { path = "../../sr-api", default-features = false }
|
||||
sr-primitives = { path = "../../sr-primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../../sr-std", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"rstd/std",
|
||||
"sr-api/std",
|
||||
"codec/std",
|
||||
|
||||
@@ -19,31 +19,28 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use rstd::vec::Vec;
|
||||
use sr_primitives::RuntimeDebug;
|
||||
|
||||
#[derive(codec::Encode, codec::Decode, Eq, PartialEq, Clone, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub struct Signature(pub Vec<u8>);
|
||||
#[derive(codec::Encode, codec::Decode, Eq, PartialEq, Clone, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub struct AuthorityId(pub Vec<u8>);
|
||||
mod app {
|
||||
use app_crypto::{app_crypto, key_types::AUTHORITY_DISCOVERY, sr25519};
|
||||
app_crypto!(sr25519, AUTHORITY_DISCOVERY);
|
||||
}
|
||||
|
||||
/// An authority discovery authority keypair.
|
||||
#[cfg(feature = "std")]
|
||||
pub type AuthorityPair = app::Pair;
|
||||
|
||||
/// An authority discovery authority identifier.
|
||||
pub type AuthorityId = app::Public;
|
||||
|
||||
/// An authority discovery authority signature.
|
||||
pub type AuthoritySignature = app::Signature;
|
||||
|
||||
sr_api::decl_runtime_apis! {
|
||||
/// The authority discovery api.
|
||||
///
|
||||
/// This api is used by the `core/authority-discovery` module to retrieve our
|
||||
/// own authority identifier, to retrieve identifiers of the current authority
|
||||
/// set, as well as sign and verify Kademlia Dht external address payloads
|
||||
/// from and to other authorities.
|
||||
/// This api is used by the `core/authority-discovery` module to retrieve identifiers of the current authority set.
|
||||
pub trait AuthorityDiscoveryApi {
|
||||
/// Retrieve authority identifiers of the current authority set.
|
||||
fn authorities() -> Vec<AuthorityId>;
|
||||
|
||||
/// Sign the given payload with the private key corresponding to the given authority id.
|
||||
fn sign(payload: &Vec<u8>) -> Option<(Signature, AuthorityId)>;
|
||||
|
||||
/// Verify the given signature for the given payload with the given
|
||||
/// authority identifier.
|
||||
fn verify(payload: &Vec<u8>, signature: &Signature, authority_id: &AuthorityId) -> bool;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user