Skip to content

Commit 28cf9bf

Browse files
author
Yuko Roodt
committed
issue
1 parent c71956b commit 28cf9bf

File tree

4 files changed

+2
-42
lines changed

4 files changed

+2
-42
lines changed

fuzz/fuzz_targets/full_stack_target.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,6 @@ impl KeysInterface for KeyProvider {
281281
fill_bytes(&mut session_key);
282282
SecretKey::from_slice(&session_key).unwrap()
283283
}
284-
285-
fn get_channel_id(&self) -> [u8; 32] {
286-
let mut channel_id = [0; 32];
287-
fill_bytes(&mut channel_id);
288-
channel_id
289-
}
290284
}
291285

292286
#[inline]

src/chain/keysinterface.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ pub trait KeysInterface: Send + Sync {
8080
fn get_channel_keys(&self, inbound: bool) -> ChannelKeys;
8181
/// Get a secret for construting an onion packet
8282
fn get_session_key(&self) -> SecretKey;
83-
/// Get a unique channel id
84-
fn get_channel_id(&self) -> [u8; 32];
8583
}
8684

8785
/// Set of lightning keys needed to operate a channel as described in BOLT 3
@@ -126,8 +124,6 @@ pub struct KeysManager {
126124
channel_child_index: AtomicUsize,
127125
session_master_key: ExtendedPrivKey,
128126
session_child_index: AtomicUsize,
129-
channel_id_master_key: ExtendedPrivKey,
130-
channel_id_child_index: AtomicUsize,
131127

132128
logger: Arc<Logger>,
133129
}
@@ -155,7 +151,6 @@ impl KeysManager {
155151
};
156152
let channel_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(3)).expect("Your RNG is busted");
157153
let session_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(4)).expect("Your RNG is busted");
158-
let channel_id_master_key = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(5)).expect("Your RNG is busted");
159154
KeysManager {
160155
secp_ctx,
161156
node_secret,
@@ -165,8 +160,6 @@ impl KeysManager {
165160
channel_child_index: AtomicUsize::new(0),
166161
session_master_key,
167162
session_child_index: AtomicUsize::new(0),
168-
channel_id_master_key,
169-
channel_id_child_index: AtomicUsize::new(0),
170163

171164
logger,
172165
}
@@ -253,18 +246,4 @@ impl KeysInterface for KeysManager {
253246
sha.input(&child_privkey.secret_key[..]);
254247
SecretKey::from_slice(&Sha256::from_engine(sha).into_inner()).expect("Your RNG is busted")
255248
}
256-
257-
fn get_channel_id(&self) -> [u8; 32] {
258-
let mut sha = Sha256::engine();
259-
260-
let now = SystemTime::now().duration_since(UNIX_EPOCH).expect("Time went backwards");
261-
sha.input(&byte_utils::be32_to_array(now.subsec_nanos()));
262-
sha.input(&byte_utils::be64_to_array(now.as_secs()));
263-
264-
let child_ix = self.channel_id_child_index.fetch_add(1, Ordering::AcqRel);
265-
let child_privkey = self.channel_id_master_key.ckd_priv(&self.secp_ctx, ChildNumber::from_hardened_idx(child_ix as u32)).expect("Your RNG is busted");
266-
sha.input(&child_privkey.secret_key[..]);
267-
268-
(Sha256::from_engine(sha).into_inner())
269-
}
270249
}

src/ln/channel.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ln::chan_utils;
2323
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
2424
use chain::transaction::OutPoint;
2525
use chain::keysinterface::{ChannelKeys, KeysInterface};
26-
use util::transaction_utils;
26+
use util::{transaction_utils,rng};
2727
use util::ser::{Readable, ReadableArgs, Writeable, Writer, WriterWriteAdaptor};
2828
use util::logger::Logger;
2929
use util::errors::APIError;
@@ -350,10 +350,7 @@ pub const OUR_MAX_HTLCS: u16 = 50; //TODO
350350
const UNCONF_THRESHOLD: u32 = 6;
351351
/// The amount of time we require our counterparty wait to claim their money (ie time between when
352352
/// we, or our watchtower, must check for them having broadcast a theft transaction).
353-
#[cfg(not(test))]
354353
const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO?
355-
#[cfg(test)]
356-
pub const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO?
357354
/// The amount of time we're willing to wait to claim money back to us
358355
const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 14;
359356
/// Exposing these two constants for use in test in ChannelMonitor
@@ -447,7 +444,7 @@ impl Channel {
447444
user_id: user_id,
448445
config: config.channel_options.clone(),
449446

450-
channel_id: keys_provider.get_channel_id(),
447+
channel_id: rng::rand_u832(),
451448
channel_state: ChannelState::OurInitSent as u32,
452449
channel_outbound: true,
453450
secp_ctx: secp_ctx,
@@ -3961,7 +3958,6 @@ mod tests {
39613958

39623959
fn get_channel_keys(&self, _inbound: bool) -> ChannelKeys { self.chan_keys.clone() }
39633960
fn get_session_key(&self) -> SecretKey { panic!(); }
3964-
fn get_channel_id(&self) -> [u8; 32] { [0; 32] }
39653961
}
39663962

39673963
#[test]

src/util/test_utils.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ impl Logger for TestLogger {
215215
pub struct TestKeysInterface {
216216
backing: keysinterface::KeysManager,
217217
pub override_session_priv: Mutex<Option<SecretKey>>,
218-
pub override_channel_id_priv: Mutex<Option<[u8; 32]>>,
219218
}
220219

221220
impl keysinterface::KeysInterface for TestKeysInterface {
@@ -230,21 +229,13 @@ impl keysinterface::KeysInterface for TestKeysInterface {
230229
None => self.backing.get_session_key()
231230
}
232231
}
233-
234-
fn get_channel_id(&self) -> [u8; 32] {
235-
match *self.override_channel_id_priv.lock().unwrap() {
236-
Some(key) => key.clone(),
237-
None => self.backing.get_channel_id()
238-
}
239-
}
240232
}
241233

242234
impl TestKeysInterface {
243235
pub fn new(seed: &[u8; 32], network: Network, logger: Arc<Logger>) -> Self {
244236
Self {
245237
backing: keysinterface::KeysManager::new(seed, network, logger),
246238
override_session_priv: Mutex::new(None),
247-
override_channel_id_priv: Mutex::new(None),
248239
}
249240
}
250241
}

0 commit comments

Comments
 (0)