From 4803ec83c032b87417c8dbce317df766d66c8dcb Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Wed, 31 Jul 2019 17:23:09 +0200 Subject: [PATCH 1/7] Schnorrkel 0.8.1 (builds on bkchr upgrade branch) --- Cargo.lock | 14 +++++++------- core/consensus/babe/Cargo.toml | 2 +- core/primitives/src/sr25519.rs | 24 +++++++++++++++++++----- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e39cec4ea58ad..81434ae5e5e68 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3261,7 +3261,7 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4136,7 +4136,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "srml-balances 2.0.0", "srml-system 2.0.0", @@ -4179,7 +4179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4332,7 +4332,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -4358,7 +4358,7 @@ name = "substrate-consensus-babe-primitives" version = "2.0.0" dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-client 2.0.0", @@ -4661,7 +4661,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", @@ -6239,7 +6239,7 @@ dependencies = [ "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" -"checksum schnorrkel 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf8bb3d2b309218262456dd161b24456e977120f572e5ec5c6686dddad467e2" +"checksum schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cd67bd20c59764fa16413abe3bc7278659d2877c8ec007e58e8fd35ebda44730" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index e7f578d0233d2..cf24df6311875 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -28,7 +28,7 @@ futures01 = { package = "futures", version = "0.1" } futures-timer = "0.2.1" parking_lot = "0.8.0" log = "0.4.6" -schnorrkel = "0.8.0" +schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"] } rand = "0.6.5" merlin = "1.0.3" diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index c1c039ecad72a..5ae87bfabaf3f 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -481,8 +481,9 @@ impl TraitPair for Pair { Err(_) => return false }; match PublicKey::from_bytes(pubkey.as_ref().as_slice()) { - Ok(pk) => pk.verify( - signing_context(SIGNING_CTX).bytes(message.as_ref()), + Ok(pk) => pk.verify_simple( + SIGNING_CTX, + message.as_ref(), &signature, ).is_ok(), Err(_) => false, @@ -496,8 +497,9 @@ impl TraitPair for Pair { Err(_) => return false }; match PublicKey::from_bytes(pubkey.as_ref()) { - Ok(pk) => pk.verify( - signing_context(SIGNING_CTX).bytes(message.as_ref()), + Ok(pk) => pk.verify_simple( + SIGNING_CTX, + message.as_ref(), &signature, ).is_ok(), Err(_) => false, @@ -637,6 +639,19 @@ mod test { assert!(Pair::verify(&signature, &message[..], &public)); } + #[test] + fn verify_known_message_should_work() { + let public = Public::from_raw(hex!( + "b4bfa1f7a5166695eb75299fd1c4c03ea212871c342f2c5dfea0902b2c246918" + )); + let signature = Signature::from_raw(hex!( + "5a9755f069939f45d96aaf125cf5ce7ba1db998686f87f2fb3cbdea922078741a73891ba265f70c31436e18a9acd14d189d73c12317ab6c313285cd938453202" + )); + let message = b"Verifying that I am the owner of 5G9hQLdsKQswNPgB499DeA5PkFBbgkLPJWkkS6FAM6xGQ8xD. Hash: 221455a3\n"; + + assert!(Pair::verify(&signature, &message[..], &public)); + } + #[test] fn generated_pair_should_work() { let (pair, _) = Pair::generate(); @@ -648,7 +663,6 @@ mod test { #[test] fn seeded_pair_should_work() { - let pair = Pair::from_seed(b"12345678901234567890123456789012"); let public = pair.public(); assert_eq!( From acd56d9e5f9faef4d37b7a6aecd89abacb58ab36 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 06:53:37 +0200 Subject: [PATCH 2/7] Add tests for known hard/soft derivation values --- core/primitives/src/sr25519.rs | 60 ++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 5ae87bfabaf3f..2fe7c31ccf874 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -476,15 +476,12 @@ impl TraitPair for Pair { /// Verify a signature on a message. Returns true if the signature is good. fn verify, M: AsRef<[u8]>>(sig: &Self::Signature, message: M, pubkey: P) -> bool { - let signature: schnorrkel::Signature = match schnorrkel::Signature::from_bytes(&sig.as_ref()) { - Ok(some_signature) => some_signature, - Err(_) => return false - }; + // Match both schnorrkel 0.1.1 and 0.8.0+ signatures, supporting both wallets + // that have not been upgraded and those that have. To swap to 0.8.0 only, + // create `schnorrkel::Signature` and pass that into `verify_simple` match PublicKey::from_bytes(pubkey.as_ref().as_slice()) { - Ok(pk) => pk.verify_simple( - SIGNING_CTX, - message.as_ref(), - &signature, + Ok(pk) => pk.verify_simple_preaudit_deprecated( + SIGNING_CTX, message.as_ref(), &sig.as_ref(), ).is_ok(), Err(_) => false, } @@ -492,15 +489,9 @@ impl TraitPair for Pair { /// Verify a signature on a message. Returns true if the signature is good. fn verify_weak, M: AsRef<[u8]>>(sig: &[u8], message: M, pubkey: P) -> bool { - let signature: schnorrkel::Signature = match schnorrkel::Signature::from_bytes(sig) { - Ok(some_signature) => some_signature, - Err(_) => return false - }; match PublicKey::from_bytes(pubkey.as_ref()) { - Ok(pk) => pk.verify_simple( - SIGNING_CTX, - message.as_ref(), - &signature, + Ok(pk) => pk.verify_simple_preaudit_deprecated( + SIGNING_CTX, message.as_ref(), &signature, ).is_ok(), Err(_) => false, } @@ -622,6 +613,42 @@ mod test { assert!(pair.public().derive(path.into_iter()).is_none()); } + #[test] + fn derive_soft_known_pair_should_work() { + let path = Some(DeriveJunction::soft(hex!( + "0c666f6f00000000000000000000000000000000000000000000000000000000" + ))); + let pair = Pair::from_seed(&hex!( + "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" + )); + let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a"); + assert_eq!(pair.derive(path.into_iter()).unwrap().public().to_raw_vec(), expected); + } + + #[test] + fn derive_soft_known_public_should_work() { + let path = Some(DeriveJunction::hard(hex!( + "0c666f6f00000000000000000000000000000000000000000000000000000000" + ))); + let public = Public::from_raw(hex!( + "46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a" + )); + let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a"); + assert_eq!(public.derive(path.into_iter()).unwrap().to_raw_vec(), expected); + } + + #[test] + fn derive_hard_known_pair_should_work() { + let path = Some(DeriveJunction::hard(hex!( + "14416c6963650000000000000000000000000000000000000000000000000000" + ))); + let pair = Pair::from_seed(&hex!( + "fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e" + )); + let expected = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"); + assert_eq!(pair.derive(path.into_iter()).unwrap().public().to_raw_vec(), expected); + } + #[test] fn sr_test_vector_should_work() { let pair = Pair::from_seed(&hex!( @@ -648,7 +675,6 @@ mod test { "5a9755f069939f45d96aaf125cf5ce7ba1db998686f87f2fb3cbdea922078741a73891ba265f70c31436e18a9acd14d189d73c12317ab6c313285cd938453202" )); let message = b"Verifying that I am the owner of 5G9hQLdsKQswNPgB499DeA5PkFBbgkLPJWkkS6FAM6xGQ8xD. Hash: 221455a3\n"; - assert!(Pair::verify(&signature, &message[..], &public)); } From 8ab78b5ccd14d90cd9c7139b98a17110cf4d0b16 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 09:40:32 +0200 Subject: [PATCH 3/7] Bump all schnorrkel versions --- core/consensus/babe/primitives/Cargo.toml | 2 +- core/primitives/Cargo.toml | 2 +- subkey/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index a9f9c69ff1c6e..1587c71db87e0 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } parity-codec = { version = "4.1.1", default-features = false } -schnorrkel = { version = "0.8.0", optional = true } +schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"], optional = true } [features] default = ["std"] diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index add62cb9a8dad..f31d307c2a229 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -19,7 +19,7 @@ hash256-std-hasher = { version = "0.14.0", default-features = false } ed25519-dalek = { version = "1.0.0-pre.1", optional = true } base58 = { version = "0.1", optional = true } blake2-rfc = { version = "0.2.18", optional = true } -schnorrkel = { version = "0.8.0", optional = true } +schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"], optional = true } rand = { version = "0.6", optional = true } sha2 = { version = "0.8", optional = true } substrate-bip39 = { version = "0.3.1", optional = true } diff --git a/subkey/Cargo.toml b/subkey/Cargo.toml index d5dbc166f6e52..ab03ed2bfa8fe 100644 --- a/subkey/Cargo.toml +++ b/subkey/Cargo.toml @@ -14,7 +14,7 @@ clap = { version = "~2.32", features = ["yaml"] } tiny-bip39 = "0.6.0" rustc-hex = "2.0" substrate-bip39 = "0.3.1" -schnorrkel = "0.8.0" +schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"] } hex = "0.3" hex-literal = "0.2" parity-codec = "4.1.1" From e882f4f89ad7d71476a5f9a9d291d537ef1bf22f Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 12:43:51 +0200 Subject: [PATCH 4/7] Flatten for easier inspection --- core/primitives/src/sr25519.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 2fe7c31ccf874..51e370dc70075 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -22,7 +22,7 @@ // end::description[] #[cfg(feature = "std")] -use schnorrkel::{signing_context, Keypair, SecretKey, MiniSecretKey, PublicKey, +use schnorrkel::{signing_context, ExpansionMode, Keypair, SecretKey, MiniSecretKey, PublicKey, derive::{Derivation, ChainCode, CHAIN_CODE_LENGTH} }; #[cfg(feature = "std")] @@ -341,7 +341,7 @@ impl AsRef for Pair { #[cfg(feature = "std")] impl From for Pair { fn from(sec: MiniSecretKey) -> Pair { - Pair(sec.expand_ed25519_to_keypair()) + Pair(sec.expand_to_keypair(ExpansionMode::Ed25519)) } } @@ -376,7 +376,7 @@ impl AsRef for Pair { /// Derive a single hard junction. #[cfg(feature = "std")] fn derive_hard_junction(secret: &SecretKey, cc: &[u8; CHAIN_CODE_LENGTH]) -> SecretKey { - secret.hard_derive_mini_secret_key(Some(ChainCode(cc.clone())), b"").0.expand_ed25519() + secret.hard_derive_mini_secret_key(Some(ChainCode(cc.clone())), b"").0.expand(ExpansionMode::Ed25519) } /// The raw secret seed, which can be used to recreate the `Pair`. @@ -417,7 +417,7 @@ impl TraitPair for Pair { Ok(Pair( MiniSecretKey::from_bytes(seed) .map_err(|_| SecretStringError::InvalidSeed)? - .expand_ed25519_to_keypair() + .expand_to_keypair(ExpansionMode::ExpansionMode) )) } SECRET_KEY_LENGTH => { @@ -491,7 +491,7 @@ impl TraitPair for Pair { fn verify_weak, M: AsRef<[u8]>>(sig: &[u8], message: M, pubkey: P) -> bool { match PublicKey::from_bytes(pubkey.as_ref()) { Ok(pk) => pk.verify_simple_preaudit_deprecated( - SIGNING_CTX, message.as_ref(), &signature, + SIGNING_CTX, message.as_ref(), &sig, ).is_ok(), Err(_) => false, } @@ -639,14 +639,12 @@ mod test { #[test] fn derive_hard_known_pair_should_work() { - let path = Some(DeriveJunction::hard(hex!( - "14416c6963650000000000000000000000000000000000000000000000000000" - ))); - let pair = Pair::from_seed(&hex!( - "fac7959dbfe72f052e5a0c3c8d6530f202b02fd8f9f5ca3580ec8deb7797479e" - )); + // let path = Some(DeriveJunction::hard(hex!( + // "14416c6963650000000000000000000000000000000000000000000000000000" + // ))); + let pair = Pair::from_string(&format!("{}//Alice", DEV_PHRASE), None).unwrap(); let expected = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"); - assert_eq!(pair.derive(path.into_iter()).unwrap().public().to_raw_vec(), expected); + assert_eq!(pair.public().to_raw_vec(), expected); } #[test] @@ -721,9 +719,9 @@ mod test { &hex!("0000000000000000000000000000000000000000000000000000000000000000") ); let public = pk.public(); - let js_signature = Signature::from_raw( - hex!("3a6caf0e96c51a8182241fe94ad4828f84a5aa69f9da33adf10afd7a97591d5a352bc745ba68f69060e14e5cbaa23c568523ec4bfb8c8a908a5703b62c89cf85") - ); + let js_signature = Signature::from_raw(hex!( + "28a854d54903e056f89581c691c1f7d2ff39f8f896c9e9c22475e60902cc2b3547199e0e91fa32902028f2ca2355e8cdd16cfe19ba5e8b658c94aa80f3b81a00" + )); assert!(Pair::verify(&js_signature, b"SUBSTRATE", public)); } } From 9d56ec2fa784ae2b41ce5cf001df2d8fad3adf41 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 13:01:57 +0200 Subject: [PATCH 5/7] 0.8.2 --- Cargo.lock | 14 +++++++------- core/consensus/babe/Cargo.toml | 2 +- core/consensus/babe/primitives/Cargo.toml | 2 +- core/primitives/Cargo.toml | 2 +- core/primitives/src/sr25519.rs | 4 ++-- subkey/Cargo.toml | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81434ae5e5e68..a44d0050187ac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3261,7 +3261,7 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4136,7 +4136,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "srml-balances 2.0.0", "srml-system 2.0.0", @@ -4179,7 +4179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4332,7 +4332,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -4358,7 +4358,7 @@ name = "substrate-consensus-babe-primitives" version = "2.0.0" dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-client 2.0.0", @@ -4661,7 +4661,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", @@ -6239,7 +6239,7 @@ dependencies = [ "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" -"checksum schnorrkel 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cd67bd20c59764fa16413abe3bc7278659d2877c8ec007e58e8fd35ebda44730" +"checksum schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dbbd10b71915a60017e5bb3accdbe4664ca1c52f5ff37fa94ea44f26819d72e" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index cf24df6311875..7225dc3b6d147 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -28,7 +28,7 @@ futures01 = { package = "futures", version = "0.1" } futures-timer = "0.2.1" parking_lot = "0.8.0" log = "0.4.6" -schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"] } +schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"] } rand = "0.6.5" merlin = "1.0.3" diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 1587c71db87e0..9ba7b2c35e422 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } parity-codec = { version = "4.1.1", default-features = false } -schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"], optional = true } +schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"], optional = true } [features] default = ["std"] diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index f31d307c2a229..fdda4b512982b 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -19,7 +19,7 @@ hash256-std-hasher = { version = "0.14.0", default-features = false } ed25519-dalek = { version = "1.0.0-pre.1", optional = true } base58 = { version = "0.1", optional = true } blake2-rfc = { version = "0.2.18", optional = true } -schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"], optional = true } +schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"], optional = true } rand = { version = "0.6", optional = true } sha2 = { version = "0.8", optional = true } substrate-bip39 = { version = "0.3.1", optional = true } diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 51e370dc70075..7f24f433a6d7f 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -417,7 +417,7 @@ impl TraitPair for Pair { Ok(Pair( MiniSecretKey::from_bytes(seed) .map_err(|_| SecretStringError::InvalidSeed)? - .expand_to_keypair(ExpansionMode::ExpansionMode) + .expand_to_keypair(ExpansionMode::Ed25519) )) } SECRET_KEY_LENGTH => { @@ -513,7 +513,7 @@ impl Pair { let mini_key: MiniSecretKey = mini_secret_from_entropy(entropy, password.unwrap_or("")) .expect("32 bytes can always build a key; qed"); - let kp = mini_key.expand_ed25519_to_keypair(); + let kp = mini_key.expand_to_keypair(ExpansionMode::Ed25519); (Pair(kp), mini_key.to_bytes()) } } diff --git a/subkey/Cargo.toml b/subkey/Cargo.toml index ab03ed2bfa8fe..088e4a70ddd5d 100644 --- a/subkey/Cargo.toml +++ b/subkey/Cargo.toml @@ -14,7 +14,7 @@ clap = { version = "~2.32", features = ["yaml"] } tiny-bip39 = "0.6.0" rustc-hex = "2.0" substrate-bip39 = "0.3.1" -schnorrkel = { version = "0.8.1", features = ["preaudit_deprecated"] } +schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"] } hex = "0.3" hex-literal = "0.2" parity-codec = "4.1.1" From cb56afd8790a692b81b55b91d1e9e27e5f4ead4f Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 14:02:15 +0200 Subject: [PATCH 6/7] 0.8.3 --- Cargo.lock | 14 ++++++------ core/consensus/babe/Cargo.toml | 2 +- core/consensus/babe/primitives/Cargo.toml | 2 +- core/primitives/Cargo.toml | 2 +- core/primitives/src/sr25519.rs | 26 +++-------------------- subkey/Cargo.toml | 2 +- 6 files changed, 14 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a44d0050187ac..2228eccbc69e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3261,7 +3261,7 @@ dependencies = [ [[package]] name = "schnorrkel" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "curve25519-dalek 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4136,7 +4136,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "srml-balances 2.0.0", "srml-system 2.0.0", @@ -4179,7 +4179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4332,7 +4332,7 @@ dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-io 2.0.0", "sr-primitives 2.0.0", "sr-version 2.0.0", @@ -4358,7 +4358,7 @@ name = "substrate-consensus-babe-primitives" version = "2.0.0" dependencies = [ "parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "sr-primitives 2.0.0", "sr-std 2.0.0", "substrate-client 2.0.0", @@ -4661,7 +4661,7 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 2.0.0", @@ -6239,7 +6239,7 @@ dependencies = [ "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339" -"checksum schnorrkel 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8dbbd10b71915a60017e5bb3accdbe4664ca1c52f5ff37fa94ea44f26819d72e" +"checksum schnorrkel 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "547d3603273bf9e4086966bbf431a2335bafcc6c6ddff9755889c08b38c1c951" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" "checksum sct 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f5adf8fbd58e1b1b52699dc8bed2630faecb6d8c7bee77d009d6bbe4af569b9" diff --git a/core/consensus/babe/Cargo.toml b/core/consensus/babe/Cargo.toml index 7225dc3b6d147..9ed7ecbf1c0d8 100644 --- a/core/consensus/babe/Cargo.toml +++ b/core/consensus/babe/Cargo.toml @@ -28,7 +28,7 @@ futures01 = { package = "futures", version = "0.1" } futures-timer = "0.2.1" parking_lot = "0.8.0" log = "0.4.6" -schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"] } +schnorrkel = { version = "0.8.3", features = ["preaudit_deprecated"] } rand = "0.6.5" merlin = "1.0.3" diff --git a/core/consensus/babe/primitives/Cargo.toml b/core/consensus/babe/primitives/Cargo.toml index 9ba7b2c35e422..c201b054ff779 100644 --- a/core/consensus/babe/primitives/Cargo.toml +++ b/core/consensus/babe/primitives/Cargo.toml @@ -12,7 +12,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false } primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false } slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true } parity-codec = { version = "4.1.1", default-features = false } -schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"], optional = true } +schnorrkel = { version = "0.8.3", features = ["preaudit_deprecated"], optional = true } [features] default = ["std"] diff --git a/core/primitives/Cargo.toml b/core/primitives/Cargo.toml index fdda4b512982b..5ade826560d24 100644 --- a/core/primitives/Cargo.toml +++ b/core/primitives/Cargo.toml @@ -19,7 +19,7 @@ hash256-std-hasher = { version = "0.14.0", default-features = false } ed25519-dalek = { version = "1.0.0-pre.1", optional = true } base58 = { version = "0.1", optional = true } blake2-rfc = { version = "0.2.18", optional = true } -schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"], optional = true } +schnorrkel = { version = "0.8.3", features = ["preaudit_deprecated"], optional = true } rand = { version = "0.6", optional = true } sha2 = { version = "0.8", optional = true } substrate-bip39 = { version = "0.3.1", optional = true } diff --git a/core/primitives/src/sr25519.rs b/core/primitives/src/sr25519.rs index 7f24f433a6d7f..89ae5a88bc579 100644 --- a/core/primitives/src/sr25519.rs +++ b/core/primitives/src/sr25519.rs @@ -615,33 +615,13 @@ mod test { #[test] fn derive_soft_known_pair_should_work() { - let path = Some(DeriveJunction::soft(hex!( - "0c666f6f00000000000000000000000000000000000000000000000000000000" - ))); - let pair = Pair::from_seed(&hex!( - "9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60" - )); - let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a"); - assert_eq!(pair.derive(path.into_iter()).unwrap().public().to_raw_vec(), expected); - } - - #[test] - fn derive_soft_known_public_should_work() { - let path = Some(DeriveJunction::hard(hex!( - "0c666f6f00000000000000000000000000000000000000000000000000000000" - ))); - let public = Public::from_raw(hex!( - "46ebddef8cd9bb167dc30878d7113b7e168e6f0646beffd77d69d39bad76b47a" - )); - let expected = hex!("40b9675df90efa6069ff623b0fdfcf706cd47ca7452a5056c7ad58194d23440a"); - assert_eq!(public.derive(path.into_iter()).unwrap().to_raw_vec(), expected); + let pair = Pair::from_string(&format!("{}/Alice", DEV_PHRASE), None).unwrap(); + let expected = hex!("d6c71059dbbe9ad2b0ed3f289738b800836eb425544ce694825285b958ca755e"); + assert_eq!(pair.public().to_raw_vec(), expected); } #[test] fn derive_hard_known_pair_should_work() { - // let path = Some(DeriveJunction::hard(hex!( - // "14416c6963650000000000000000000000000000000000000000000000000000" - // ))); let pair = Pair::from_string(&format!("{}//Alice", DEV_PHRASE), None).unwrap(); let expected = hex!("d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"); assert_eq!(pair.public().to_raw_vec(), expected); diff --git a/subkey/Cargo.toml b/subkey/Cargo.toml index 088e4a70ddd5d..550c208373d2d 100644 --- a/subkey/Cargo.toml +++ b/subkey/Cargo.toml @@ -14,7 +14,7 @@ clap = { version = "~2.32", features = ["yaml"] } tiny-bip39 = "0.6.0" rustc-hex = "2.0" substrate-bip39 = "0.3.1" -schnorrkel = { version = "0.8.2", features = ["preaudit_deprecated"] } +schnorrkel = { version = "0.8.3", features = ["preaudit_deprecated"] } hex = "0.3" hex-literal = "0.2" parity-codec = "4.1.1" From 31838847c8dd6e44a7124f97c7cc9e72aa28f2fc Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 1 Aug 2019 14:17:31 +0200 Subject: [PATCH 7/7] Update subkey/Cargo.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Bastian Köcher --- subkey/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/subkey/Cargo.toml b/subkey/Cargo.toml index 550c208373d2d..73f2134367062 100644 --- a/subkey/Cargo.toml +++ b/subkey/Cargo.toml @@ -14,7 +14,6 @@ clap = { version = "~2.32", features = ["yaml"] } tiny-bip39 = "0.6.0" rustc-hex = "2.0" substrate-bip39 = "0.3.1" -schnorrkel = { version = "0.8.3", features = ["preaudit_deprecated"] } hex = "0.3" hex-literal = "0.2" parity-codec = "4.1.1"