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
@@ -979,9 +980,7 @@ pub struct KeysManager {
979
980
channel_master_key:ExtendedPrivKey,
980
981
channel_child_index:AtomicUsize,
981
982
982
-
rand_bytes_master_key:ExtendedPrivKey,
983
-
rand_bytes_child_index:AtomicUsize,
984
-
rand_bytes_unique_start:Sha256State,
983
+
chacha:Mutex<ChaCha20>,
985
984
986
985
seed:[u8;32],
987
986
starting_time_secs:u64,
@@ -1027,15 +1026,14 @@ impl KeysManager {
1027
1026
Err(_) => panic!("Your RNG is busted"),
1028
1027
};
1029
1028
let channel_master_key = master_key.ckd_priv(&secp_ctx,ChildNumber::from_hardened_idx(3).unwrap()).expect("Your RNG is busted");
1030
-
let rand_bytes_master_key = master_key.ckd_priv(&secp_ctx,ChildNumber::from_hardened_idx(4).unwrap()).expect("Your RNG is busted");
1031
1029
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));
1039
1037
1040
1038
letmut res = KeysManager{
1041
1039
secp_ctx,
@@ -1049,9 +1047,7 @@ impl KeysManager {
1049
1047
channel_master_key,
1050
1048
channel_child_index:AtomicUsize::new(0),
1051
1049
1052
-
rand_bytes_master_key,
1053
-
rand_bytes_child_index:AtomicUsize::new(0),
1054
-
rand_bytes_unique_start,
1050
+
chacha,
1055
1051
1056
1052
seed:*seed,
1057
1053
starting_time_secs,
@@ -1248,14 +1244,11 @@ impl KeysManager {
1248
1244
1249
1245
implEntropySourceforKeysManager{
1250
1246
fnget_secure_random_bytes(&self) -> [u8;32]{
1251
-
letmutsha = self.rand_bytes_unique_start.clone();
1247
+
letmutchacha = self.chacha.lock().unwrap();
1252
1248
1253
-
let child_ix = self.rand_bytes_child_index.fetch_add(1,Ordering::AcqRel);
1254
-
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