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
+14 -8
View File
@@ -29,7 +29,7 @@ use substrate_client::{
impl_runtime_apis,
};
use runtime_primitives::{
ApplyResult, Ed25519Signature, transaction_validity::TransactionValidity,
ApplyResult, transaction_validity::TransactionValidity,
create_runtime_str,
traits::{
BlindCheckable, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT,
@@ -38,7 +38,7 @@ use runtime_primitives::{
};
use runtime_version::RuntimeVersion;
pub use primitives::hash::H256;
use primitives::{Ed25519AuthorityId, OpaqueMetadata};
use primitives::{ed25519, sr25519, OpaqueMetadata};
#[cfg(any(feature = "std", test))]
use runtime_version::NativeVersion;
use inherents::{CheckInherentsResult, InherentData};
@@ -81,8 +81,8 @@ pub struct Transfer {
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Extrinsic {
AuthoritiesChange(Vec<Ed25519AuthorityId>),
Transfer(Transfer, Ed25519Signature),
AuthoritiesChange(Vec<AuthorityId>),
Transfer(Transfer, AccountSignature),
}
#[cfg(feature = "std")]
@@ -125,8 +125,14 @@ impl Extrinsic {
}
}
// The identity type used by authorities.
pub type AuthorityId = ed25519::Public;
// The signature type used by authorities.
pub type AuthoritySignature = ed25519::Signature;
/// An identifier for an account on this system.
pub type AccountId = H256;
pub type AccountId = sr25519::Public;
// The signature type used by accounts/transactions.
pub type AccountSignature = sr25519::Signature;
/// A simple hash type for all our hashing.
pub type Hash = H256;
/// The block number type used in this runtime.
@@ -134,7 +140,7 @@ pub type BlockNumber = u64;
/// Index of a transaction.
pub type Index = u64;
/// The item of a block digest.
pub type DigestItem = runtime_primitives::generic::DigestItem<H256, Ed25519AuthorityId>;
pub type DigestItem = runtime_primitives::generic::DigestItem<H256, AuthorityId, AuthoritySignature>;
/// The digest of a block.
pub type Digest = runtime_primitives::generic::Digest<DigestItem>;
/// A test block.
@@ -256,7 +262,7 @@ cfg_if! {
version()
}
fn authorities() -> Vec<Ed25519AuthorityId> {
fn authorities() -> Vec<AuthorityId> {
system::authorities()
}
@@ -347,7 +353,7 @@ cfg_if! {
version()
}
fn authorities() -> Vec<Ed25519AuthorityId> {
fn authorities() -> Vec<AuthorityId> {
system::authorities()
}