From 06c23368f2522f1f3f4ba93734ffd365c8d059d2 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Wed, 6 Mar 2024 21:37:40 -0500 Subject: [PATCH] Mitigate https://github.com/serai-dex/serai/issues/539 by making keystore deterministic --- substrate/node/src/keystore.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/substrate/node/src/keystore.rs b/substrate/node/src/keystore.rs index 333cd9c3..ca00e79b 100644 --- a/substrate/node/src/keystore.rs +++ b/substrate/node/src/keystore.rs @@ -1,5 +1,4 @@ use zeroize::Zeroize; -use rand_core::RngCore; use sp_core::{crypto::*, ed25519, sr25519}; use sp_keystore::*; @@ -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();