This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Refactor key management #3296
Merged
Merged
Refactor key management #3296
Changes from all commits
Commits
Show all changes
96 commits
Select commit
Hold shift + click to select a range
aadeb9c
Add Call type to extensible transactions.
gavofyork ad9af9e
Merge Resource and BlockExhausted into just Exhausted
gavofyork 8024922
Merge remote-tracking branch 'origin/master' into gav-ext-tx-call
gavofyork 38a488f
Fix
gavofyork 8206086
Another fix
gavofyork 10a9447
Call
gavofyork e3cc2fe
Some fixes
gavofyork 19c1840
Fix srml tests.
kianenigma 539e481
Fix all tests.
kianenigma 7c09750
Refactor crypto so each application of it has its own type.
gavofyork 5aad05b
Introduce new AuthorityProvider API into Aura
gavofyork a1dc9e6
Merge branch 'gav-ext-tx-call' of github.com:paritytech/substrate int…
gavofyork c9bb7d4
Introduce authority determinator for Babe.
gavofyork b1eae50
Work in progress to introduce KeyTypeId and avoid polluting API
gavofyork 4715da3
Finish up drafting imonline
gavofyork ff5033b
Merge branch 'gav-ext-tx-call' into gav-in-progress2
tomusdrw ca53ad6
Rework offchain workers API.
tomusdrw ac419a4
Rework API implementation.
tomusdrw e140212
Make it compile for wasm, simplify app_crypto.
tomusdrw c4d58bf
Fix compilation of im-online.
tomusdrw 0d81c46
Fix compilation of im-online.
tomusdrw e1d2fbc
Fix more compilation errors.
tomusdrw 182c753
Make it compile.
tomusdrw f1ecdee
Fixing tests.
tomusdrw e172788
Merge branch 'master' into gav-in-progress
Demi-Marie 82cbe9e
Rewrite `keystore`
bkchr b270f24
Fix session tests
bkchr 1bd145a
Bring back `TryFrom`'s'
bkchr 0a93060
Fix `srml-grandpa`
bkchr c543989
Fix `srml-aura`
bkchr f7a2de3
Fix consensus babe
bkchr 5213c7f
More fixes
bkchr 9ce110a
Make service generate keys from dev_seed
bkchr 0610ef0
Build fixes
gavofyork 29a4df2
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 5d696be
Remove offchain tests
bkchr dfcd08a
More fixes and cleanups
bkchr 1bffafe
Fixes finality grandpa
bkchr d437907
Fix `consensus-aura`
bkchr 79d150c
Fix cli
bkchr e41608b
Fix `node-cli`
bkchr 77668e5
Fix chain_spec builder
bkchr 51677a8
Fix doc tests
bkchr a335620
Merge remote-tracking branch 'origin/master' into gav-in-progress
gavofyork 118fc93
Merge remote-tracking branch 'origin/master' into gav-in-progress
gavofyork 30fbafa
Merge remote-tracking branch 'origin/master' into gav-in-progress
gavofyork 3ca64cd
Add authority getter for grandpa.
gavofyork 2f7055f
Test fix
gavofyork 7638de2
Fixes
gavofyork f698f98
Make keystore accessible from the runtime
bkchr cf8e5f1
Move app crypto to its own crate
bkchr 569c8a3
Update `Cargo.lock`
bkchr 6820c8b
Make the crypto stuff usable from the runtime
bkchr 3ec27bd
Adds some runtime crypto tests
bkchr 1e3e1ee
Use last finalized block for grandpa authority
gavofyork 06106ec
Merge remote-tracking branch 'origin/gav-in-progress' into gav-in-pro…
gavofyork 649510f
Fix warning
bkchr a8538da
Adds `SessionKeys` runtime api
bkchr 497016a
Remove `FinalityPair` and `ConsensusPair`
bkchr 4e3d51d
Minor governance tweaks to get it inline with docs.
gavofyork 3248574
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 7d909d9
Make the governance be up to date with the docs.
gavofyork 63e93b5
Build fixes.
gavofyork fa1f28a
Generate the inital session keys
bkchr c2ad6e2
Failing keystore is a hard error
bkchr 86d2811
Make babe work again
bkchr 2de90fb
Fix grandpa
bkchr 67aa751
Fix tests
bkchr eb080c4
Disable `keystore` in consensus critical stuff
bkchr 30b62a7
Merge remote-tracking branch 'origin/master' into gav-in-progress
bkchr 20bddb9
Build fix.
gavofyork 259f591
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 296c16a
ImOnline supports multiple authorities at once.
gavofyork a27d58c
Update core/application-crypto/src/ed25519.rs
gavofyork 24a9693
Merge branch 'master' into gav-in-progress
folsen ef4c100
Remove unneeded code for now.
gavofyork a253132
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 9806232
Some `session` testing
bkchr 315caea
Support querying the public keys
bkchr 01fc842
Cleanup offchain
bkchr 1d2da8d
Remove warnings
bkchr 4745778
Merge remote-tracking branch 'origin/master' into gav-in-progress
bkchr 10ffc74
More cleanup
bkchr ac05779
Apply suggestions from code review
bkchr ecae834
More cleanups
bkchr 900d177
JSONRPC API for setting keys.
gavofyork ccc0c04
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 301d40b
Bad merge
gavofyork 4bf2c3f
Fix integration tests
bkchr e0e90dd
Fix test build
gavofyork a0659b9
Merge branch 'gav-in-progress' of github.com:paritytech/substrate int…
gavofyork 2ab31c8
Test fix
gavofyork 7bd33d0
Fixes
gavofyork 2afad01
Warnings
gavofyork f2e676c
Another warning
gavofyork c9c1b3b
Bump version.
gavofyork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| [package] | ||
| name = "substrate-application-crypto" | ||
| version = "2.0.0" | ||
| authors = ["Parity Technologies <[email protected]>"] | ||
| edition = "2018" | ||
| description = "Provides facilities for generating application specific crypto wrapper types." | ||
|
|
||
| [dependencies] | ||
| primitives = { package = "substrate-primitives", path = "../primitives", default-features = false } | ||
| codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] } | ||
| serde = { version = "1.0", optional = true, features = ["derive"] } | ||
| rstd = { package = "sr-std", path = "../sr-std", default-features = false } | ||
| rio = { package = "sr-io", path = "../sr-io", default-features = false } | ||
|
|
||
| [dev-dependencies] | ||
| test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client" } | ||
| sr-primitives = { path = "../sr-primitives" } | ||
|
|
||
| [features] | ||
| default = [ "std" ] | ||
| std = [ "primitives/std", "codec/std", "serde", "rstd/std", "rio/std" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // Copyright 2019 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Substrate is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Ed25519 crypto types. | ||
|
|
||
| use crate::{RuntimePublic, KeyTypeId}; | ||
|
|
||
| pub use primitives::ed25519::*; | ||
|
|
||
| mod app { | ||
| use crate::key_types::ED25519; | ||
| crate::app_crypto!(super, ED25519); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'l like to remove this entirely in the not too distant future. is anything using it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use it in some tests. But yeah, I could probably do this in the test itself. |
||
| } | ||
|
|
||
| pub use app::Public as AppPublic; | ||
| pub use app::Signature as AppSignature; | ||
| #[cfg(feature="std")] | ||
| pub use app::Pair as AppPair; | ||
|
|
||
| impl RuntimePublic for Public { | ||
| type Signature = Signature; | ||
|
|
||
| fn all(key_type: KeyTypeId) -> crate::Vec<Self> { | ||
| rio::ed25519_public_keys(key_type) | ||
| } | ||
|
|
||
| fn generate_pair(key_type: KeyTypeId, seed: Option<&str>) -> Self { | ||
| rio::ed25519_generate(key_type, seed) | ||
| } | ||
|
|
||
| fn sign<M: AsRef<[u8]>>(&self, key_type: KeyTypeId, msg: &M) -> Option<Self::Signature> { | ||
| rio::ed25519_sign(key_type, self, msg) | ||
| } | ||
|
|
||
| fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool { | ||
| rio::ed25519_verify(&signature, msg.as_ref(), self) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use sr_primitives::{generic::BlockId, traits::ProvideRuntimeApi}; | ||
| use primitives::{testing::KeyStore, crypto::Pair, traits::BareCryptoStore as _}; | ||
| use test_client::{ | ||
| TestClientBuilder, DefaultTestClientBuilderExt, TestClientBuilderExt, | ||
| runtime::{TestAPI, app_crypto::ed25519::{AppPair, AppPublic}}, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn ed25519_works_in_runtime() { | ||
| let keystore = KeyStore::new(); | ||
| let test_client = TestClientBuilder::new().set_keystore(keystore.clone()).build(); | ||
| let (signature, public) = test_client.runtime_api() | ||
| .test_ed25519_crypto(&BlockId::Number(0)) | ||
| .expect("Tests `ed25519` crypto."); | ||
|
|
||
| let key_pair = keystore.read().ed25519_key_pair(crate::key_types::ED25519, &public.as_ref()) | ||
| .expect("There should be at a `ed25519` key in the keystore for the given public key."); | ||
|
|
||
| assert!(AppPair::verify(&signature, "ed25519", &AppPublic::from(key_pair.public()))); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.