Skip to content

Commit

Permalink
Mitigate #539 by making keystore deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Mar 7, 2024
1 parent 5629c94 commit 06c2336
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions substrate/node/src/keystore.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use zeroize::Zeroize;
use rand_core::RngCore;

use sp_core::{crypto::*, ed25519, sr25519};
use sp_keystore::*;
Expand All @@ -13,8 +12,7 @@ impl Keystore {
key_hex.zeroize();

assert_eq!(key.len(), 32, "KEY from environment wasn't 32 bytes");
key.extend([0; 32]);
rand_core::OsRng.fill_bytes(&mut key[32 ..]);
key.extend(sp_core::blake2_256(&key));

let res = Self(sr25519::Pair::from(schnorrkel::SecretKey::from_bytes(&key).unwrap()));
key.zeroize();
Expand Down

0 comments on commit 06c2336

Please sign in to comment.