+
+ fn get_session_key(&self) -> SecretKey {
+ let mut sha = Sha256::new();
+ let mut res = [0u8; 32];
+
+ let now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards");
+ sha.input(&byte_utils::be32_to_array(now.subsec_nanos()));
+ sha.input(&byte_utils::be64_to_array(now.as_secs()));
+
+ let child_ix = self.session_child_index.fetch_add(1, Ordering::AcqRel);
+ let child_privkey = self.session_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32)).expect("Your RNG is busted");
+ sha.input(&child_privkey.secret_key[..]);
+ sha.result(&mut res);
+ SecretKey::from_slice(&self.secp_ctx, &res).expect("Your RNG is busted")
+ }