Skip to content

Commit a7e6bfd

Browse files
authored
Backport for polkadot-sdk#1446 (#2546)
* Backport for polkadot-sdk#1446 * Cargo.toml
1 parent d9f8050 commit a7e6bfd

3 files changed

Lines changed: 12 additions & 49 deletions

File tree

Cargo.lock

Lines changed: 6 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

primitives/test-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bp-parachains = { path = "../parachains", default-features = false }
1212
bp-polkadot-core = { path = "../polkadot-core", default-features = false }
1313
bp-runtime = { path = "../runtime", default-features = false }
1414
codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false }
15-
ed25519-dalek = { version = "1.0", default-features = false, features = ["u64_backend"] }
15+
ed25519-dalek = { version = "2.0", default-features = false }
1616
finality-grandpa = { version = "0.16.2", default-features = false }
1717
sp-application-crypto = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }
1818
sp-consensus-grandpa = { git = "https://github.com/paritytech/polkadot-sdk", branch = "master", default-features = false }

primitives/test-utils/src/keyring.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
1919
use bp_header_chain::{justification::JustificationVerificationContext, AuthoritySet};
2020
use codec::Encode;
21-
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
21+
use ed25519_dalek::{Signature, SigningKey, VerifyingKey};
2222
use finality_grandpa::voter_set::VoterSet;
2323
use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight, SetId};
2424
use sp_runtime::RuntimeDebug;
@@ -37,29 +37,15 @@ pub const FERDIE: Account = Account(5);
3737
pub struct Account(pub u16);
3838

3939
impl Account {
40-
pub fn public(&self) -> PublicKey {
41-
(&self.secret()).into()
40+
pub fn public(&self) -> VerifyingKey {
41+
self.pair().verifying_key()
4242
}
4343

44-
pub fn secret(&self) -> SecretKey {
44+
pub fn pair(&self) -> SigningKey {
4545
let data = self.0.encode();
4646
let mut bytes = [0_u8; 32];
4747
bytes[0..data.len()].copy_from_slice(&data);
48-
SecretKey::from_bytes(&bytes)
49-
.expect("A static array of the correct length is a known good.")
50-
}
51-
52-
pub fn pair(&self) -> Keypair {
53-
let mut pair: [u8; 64] = [0; 64];
54-
55-
let secret = self.secret();
56-
pair[..32].copy_from_slice(&secret.to_bytes());
57-
58-
let public = self.public();
59-
pair[32..].copy_from_slice(&public.to_bytes());
60-
61-
Keypair::from_bytes(&pair)
62-
.expect("We expect the SecretKey to be good, so this must also be good.")
48+
SigningKey::from_bytes(&bytes)
6349
}
6450

6551
pub fn sign(&self, msg: &[u8]) -> Signature {

0 commit comments

Comments
 (0)