Overhaul crypto (Schnorr/Ristretto, HDKD, BIP39) (#1795)

* Rijig to Ristretto

* Rebuild wasm

* adds compatibility test with the wasm module

* Add Ed25519-BIP39 support

* Bump subkey version

* Update CLI output

* New keys.

* Standard phrase/password/path keys.

* Subkey uses S-URI for secrets

* Move everything to use new HDKD crypto.

* Test fixes

* Ignore old test vector.

* fix the ^^ old test vector.

* Fix tests

* Test fixes

* Cleanups

* Fix broken key conversion logic in grandpa

CC @rphmeier

* Remove legacy Keyring usage

* Traitify `Pair`

* Replace Ed25519AuthorityId with ed25519::Public

* Expunge Ed25519AuthorityId type!

* Replace Sr25519AuthorityId with sr25519::Public

* Remove dodgy crypto type-punning conversions

* Fix some tests

* Avoid trait

* Deduplicate DeriveJunction string decode

* Remove cruft code

* Fix test

* Minor removals

* Build fix

* Subkey supports sign and verify

* Inspect works for public key URIs

* Remove more crypto type-punning

* Fix typo

* Fix tests
This commit is contained in:
Gav Wood
2019-03-13 14:08:31 +01:00
committed by GitHub
parent 17f093da13
commit d7fcf5dc9d
83 changed files with 2636 additions and 1687 deletions
+20 -11
View File
@@ -11,10 +11,10 @@ use parity_codec::{Encode, Decode};
use rstd::prelude::*;
#[cfg(feature = "std")]
use primitives::bytes;
use primitives::{Ed25519AuthorityId, OpaqueMetadata};
use primitives::{ed25519, OpaqueMetadata};
use runtime_primitives::{
ApplyResult, transaction_validity::TransactionValidity, Ed25519Signature, generic,
traits::{self, BlakeTwo256, Block as BlockT, StaticLookup}, create_runtime_str
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
traits::{self, BlakeTwo256, Block as BlockT, StaticLookup, Verify}
};
use client::{
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
@@ -34,8 +34,17 @@ pub use runtime_primitives::{Permill, Perbill};
pub use timestamp::BlockPeriod;
pub use support::{StorageValue, construct_runtime};
/// Alias to Ed25519 pubkey that identifies an account on the chain.
pub type AccountId = primitives::H256;
/// The type that is used for identifying authorities.
pub type AuthorityId = <AuthoritySignature as Verify>::Signer;
/// The type used by authorities to prove their ID.
pub type AuthoritySignature = ed25519::Signature;
/// Alias to pubkey that identifies an account on the chain.
pub type AccountId = <AccountSignature as Verify>::Signer;
/// The type used by authorities to prove their ID.
pub type AccountSignature = ed25519::Signature;
/// A hash of some data used by the chain.
pub type Hash = primitives::H256;
@@ -66,13 +75,13 @@ pub mod opaque {
}
}
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, Ed25519AuthorityId>>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, AuthorityId, AuthoritySignature>>;
/// Opaque block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Opaque block identifier type.
pub type BlockId = generic::BlockId<Block>;
/// Opaque session key type.
pub type SessionKey = Ed25519AuthorityId;
pub type SessionKey = AuthorityId;
}
/// This runtime version.
@@ -125,7 +134,7 @@ impl aura::Trait for Runtime {
impl consensus::Trait for Runtime {
/// The identifier we use to refer to authorities.
type SessionKey = Ed25519AuthorityId;
type SessionKey = AuthorityId;
// The aura module handles offline-reports internally
// rather than using an explicit report system.
type InherentOfflineReport = ();
@@ -179,7 +188,7 @@ impl template::Trait for Runtime {
}
construct_runtime!(
pub enum Runtime with Log(InternalLog: DigestItem<Hash, Ed25519AuthorityId>) where
pub enum Runtime with Log(InternalLog: DigestItem<Hash, AuthorityId, AuthoritySignature>) where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
@@ -208,7 +217,7 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedMortalCompactExtrinsic<Address, Nonce, Call, Ed25519Signature>;
pub type UncheckedExtrinsic = generic::UncheckedMortalCompactExtrinsic<Address, Nonce, Call, AccountSignature>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>;
/// Executive: handles dispatch to the various modules.
@@ -221,7 +230,7 @@ impl_runtime_apis! {
VERSION
}
fn authorities() -> Vec<Ed25519AuthorityId> {
fn authorities() -> Vec<AuthorityId> {
Consensus::authorities()
}