You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Used as initial key material, to be expanded into multiple secret keys (but not to be used
@@ -967,9 +968,7 @@ pub struct KeysManager {
967
968
channel_master_key:ExtendedPrivKey,
968
969
channel_child_index:AtomicUsize,
969
970
970
-
rand_bytes_master_key:ExtendedPrivKey,
971
-
rand_bytes_child_index:AtomicUsize,
972
-
rand_bytes_unique_start:Sha256State,
971
+
chacha:Mutex<ChaCha20>,
973
972
974
973
seed:[u8;32],
975
974
starting_time_secs:u64,
@@ -1015,15 +1014,14 @@ impl KeysManager {
1015
1014
Err(_) => panic!("Your RNG is busted"),
1016
1015
};
1017
1016
let channel_master_key = master_key.ckd_priv(&secp_ctx,ChildNumber::from_hardened_idx(3).unwrap()).expect("Your RNG is busted");
1018
-
let rand_bytes_master_key = master_key.ckd_priv(&secp_ctx,ChildNumber::from_hardened_idx(4).unwrap()).expect("Your RNG is busted");
1019
1017
let inbound_payment_key:SecretKey = master_key.ckd_priv(&secp_ctx,ChildNumber::from_hardened_idx(5).unwrap()).expect("Your RNG is busted").private_key;
let chacha = Mutex::new(ChaCha20::new(seed,&nonce));
1027
1025
1028
1026
letmut res = KeysManager{
1029
1027
secp_ctx,
@@ -1037,9 +1035,7 @@ impl KeysManager {
1037
1035
channel_master_key,
1038
1036
channel_child_index:AtomicUsize::new(0),
1039
1037
1040
-
rand_bytes_master_key,
1041
-
rand_bytes_child_index:AtomicUsize::new(0),
1042
-
rand_bytes_unique_start,
1038
+
chacha,
1043
1039
1044
1040
seed:*seed,
1045
1041
starting_time_secs,
@@ -1236,14 +1232,11 @@ impl KeysManager {
1236
1232
1237
1233
implEntropySourceforKeysManager{
1238
1234
fnget_secure_random_bytes(&self) -> [u8;32]{
1239
-
letmutsha = self.rand_bytes_unique_start.clone();
1235
+
letmutchacha = self.chacha.lock().unwrap();
1240
1236
1241
-
let child_ix = self.rand_bytes_child_index.fetch_add(1,Ordering::AcqRel);
1242
-
let child_privkey = self.rand_bytes_master_key.ckd_priv(&self.secp_ctx,ChildNumber::from_hardened_idx(child_ix asu32).expect("key space exhausted")).expect("Your RNG is busted");
0 commit comments