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
+5 -4
View File
@@ -51,7 +51,7 @@ macro_rules! impl_session_change {
for_each_tuple!(impl_session_change);
pub trait Trait: timestamp::Trait + consensus::Trait {
type ConvertAccountIdToSessionKey: Convert<Self::AccountId, Self::SessionKey>;
type ConvertAccountIdToSessionKey: Convert<Self::AccountId, Option<Self::SessionKey>>;
type OnSessionChange: OnSessionChange<Self::Moment>;
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
}
@@ -184,16 +184,17 @@ impl<T: Trait> Module<T> {
<LastLengthChange<T>>::put(block_number);
}
T::OnSessionChange::on_session_change(time_elapsed, apply_rewards);
// Update any changes in session keys.
for (i, v) in Self::validators().into_iter().enumerate() {
<consensus::Module<T>>::set_authority(
i as u32,
&<NextKeyFor<T>>::get(&v)
.unwrap_or_else(|| T::ConvertAccountIdToSessionKey::convert(v))
.or_else(|| T::ConvertAccountIdToSessionKey::convert(v))
.unwrap_or_default()
);
};
T::OnSessionChange::on_session_change(time_elapsed, apply_rewards);
}
/// Get the time that should have elapsed over a session if everything was working perfectly.