Skip to content

Commit b04d1b8

Browse files
committed
Split KeysInterface::get_channel_signer into two
`get_channel_signer` previously had two different responsibilites: generating unique `channel_keys_id` and using said ID to derive channel keys. We decide to split it into two methods `generate_channel_keys_id` and `derive_channel_signer`, such that we can use the latter to fulfill our goal of re-deriving signers instead of persisting them. There's no point in storing data that can be easily re-derived.
1 parent 52edb35 commit b04d1b8

9 files changed

+91
-45
lines changed

fuzz/src/chanmon_consistency.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,14 @@ impl KeysInterface for KeyProvider {
193193
ShutdownScript::new_p2wpkh(&pubkey_hash)
194194
}
195195

196-
fn get_channel_signer(&self, _inbound: bool, channel_value_satoshis: u64) -> EnforcingSigner {
196+
fn generate_channel_keys_id(&self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] {
197+
let id = self.rand_bytes_id.fetch_add(1, atomic::Ordering::Relaxed) as u8;
198+
[id; 32]
199+
}
200+
201+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer {
197202
let secp_ctx = Secp256k1::signing_only();
198-
let id = self.rand_bytes_id.fetch_add(1, atomic::Ordering::Relaxed);
203+
let id = channel_keys_id[0];
199204
let keys = InMemorySigner::new(
200205
&secp_ctx,
201206
self.get_node_secret(Recipient::Node).unwrap(),
@@ -204,9 +209,9 @@ impl KeysInterface for KeyProvider {
204209
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, self.node_id]).unwrap(),
205210
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, self.node_id]).unwrap(),
206211
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, self.node_id]).unwrap(),
207-
[id as u8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, self.node_id],
212+
[id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, self.node_id],
208213
channel_value_satoshis,
209-
[0; 32],
214+
channel_keys_id,
210215
);
211216
let revoked_commitment = self.make_enforcement_state_cell(keys.commitment_seed);
212217
EnforcingSigner::new_with_revoked(keys, revoked_commitment, false)

fuzz/src/full_stack.rs

+19-6
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ struct KeyProvider {
263263
node_secret: SecretKey,
264264
inbound_payment_key: KeyMaterial,
265265
counter: AtomicU64,
266+
signer_state: RefCell<HashMap<u8, (bool, Arc<Mutex<EnforcementState>>)>>
266267
}
267268
impl KeysInterface for KeyProvider {
268269
type Signer = EnforcingSigner;
@@ -297,10 +298,17 @@ impl KeysInterface for KeyProvider {
297298
ShutdownScript::new_p2wpkh(&pubkey_hash)
298299
}
299300

300-
fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> EnforcingSigner {
301+
fn generate_channel_keys_id(&self, inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] {
301302
let ctr = self.counter.fetch_add(1, Ordering::Relaxed) as u8;
303+
self.signer_state.borrow_mut().insert(ctr, (inbound, Arc::new(Mutex::new(EnforcementState::new()))));
304+
[ctr; 32]
305+
}
306+
307+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer {
302308
let secp_ctx = Secp256k1::signing_only();
303-
EnforcingSigner::new(if inbound {
309+
let ctr = channel_keys_id[0];
310+
let (inbound, state) = self.signer_state.borrow().get(&ctr).unwrap().clone();
311+
EnforcingSigner::new_with_revoked(if inbound {
304312
InMemorySigner::new(
305313
&secp_ctx,
306314
self.node_secret.clone(),
@@ -311,7 +319,7 @@ impl KeysInterface for KeyProvider {
311319
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, ctr]).unwrap(),
312320
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, ctr],
313321
channel_value_satoshis,
314-
[0; 32],
322+
channel_keys_id,
315323
)
316324
} else {
317325
InMemorySigner::new(
@@ -324,9 +332,9 @@ impl KeysInterface for KeyProvider {
324332
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, ctr]).unwrap(),
325333
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, ctr],
326334
channel_value_satoshis,
327-
[0; 32],
335+
channel_keys_id,
328336
)
329-
})
337+
}, state, false)
330338
}
331339

332340
fn get_secure_random_bytes(&self) -> [u8; 32] {
@@ -390,7 +398,12 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
390398
let monitor = Arc::new(chainmonitor::ChainMonitor::new(None, broadcast.clone(), Arc::clone(&logger), fee_est.clone(),
391399
Arc::new(TestPersister { update_ret: Mutex::new(ChannelMonitorUpdateStatus::Completed) })));
392400

393-
let keys_manager = Arc::new(KeyProvider { node_secret: our_network_key.clone(), inbound_payment_key: KeyMaterial(inbound_payment_key.try_into().unwrap()), counter: AtomicU64::new(0) });
401+
let keys_manager = Arc::new(KeyProvider {
402+
node_secret: our_network_key.clone(),
403+
inbound_payment_key: KeyMaterial(inbound_payment_key.try_into().unwrap()),
404+
counter: AtomicU64::new(0),
405+
signer_state: RefCell::new(HashMap::new())
406+
});
394407
let mut config = UserConfig::default();
395408
config.channel_config.forwarding_fee_proportional_millionths = slice_to_be32(get_slice!(4));
396409
config.channel_handshake_config.announced_channel = get_slice!(1)[0] != 0;

fuzz/src/onion_message.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ impl KeysInterface for KeyProvider {
111111

112112
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!() }
113113

114-
fn get_channel_signer(&self, _inbound: bool, _channel_value_satoshis: u64) -> EnforcingSigner {
114+
fn generate_channel_keys_id(&self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] { unreachable!() }
115+
116+
fn derive_channel_signer(&self, _channel_value_satoshis: u64, _channel_keys_id: [u8; 32]) -> Self::Signer {
115117
unreachable!()
116118
}
117119

lightning/src/chain/keysinterface.rs

+34-18
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub enum Recipient {
402402

403403
/// A trait to describe an object which can get user secrets and key material.
404404
pub trait KeysInterface {
405-
/// A type which implements Sign which will be returned by get_channel_signer.
405+
/// A type which implements Sign which will be returned by derive_channel_signer.
406406
type Signer : Sign;
407407

408408
/// Get node secret key based on the provided [`Recipient`].
@@ -445,11 +445,20 @@ pub trait KeysInterface {
445445
/// This method should return a different value each time it is called, to avoid linking
446446
/// on-chain funds across channels as controlled to the same user.
447447
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript;
448-
/// Get a new set of Sign for per-channel secrets. These MUST be unique even if you
449-
/// restarted with some stale data!
448+
/// Generates a unique `channel_keys_id` that can be used to obtain a `Signer` through
449+
/// [`KeysInterface::derive_channel_signer`]. The `user_channel_id` is provided to allow
450+
/// implementations of `KeysInterface` to maintain a mapping between it and the generated
451+
/// `channel_keys_id`.
450452
///
451453
/// This method must return a different value each time it is called.
452-
fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> Self::Signer;
454+
fn generate_channel_keys_id(&self, inbound: bool, channel_value_satoshis: u64, user_channel_id: u128) -> [u8; 32];
455+
/// Derives the private key material backing a `Signer`.
456+
///
457+
/// To derive a new `Signer`, a fresh `channel_keys_id` should be obtained through
458+
/// [`KeysInterface::generate_channel_keys_id`]. Otherwise, an existing `Signer` can be
459+
/// re-derived from its `channel_keys_id`, which can be obtained through its trait method
460+
/// [`BaseSign::channel_keys_id`].
461+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer;
453462
/// Gets a unique, cryptographically-secure, random 32 byte value. This is used for encrypting
454463
/// onion packets and for temporary channel IDs. There is no requirement that these be
455464
/// persisted anywhere, though they must be unique across restarts.
@@ -463,6 +472,9 @@ pub trait KeysInterface {
463472
/// The bytes are exactly those which `<Self::Signer as Writeable>::write()` writes, and
464473
/// contain no versioning scheme. You may wish to include your own version prefix and ensure
465474
/// you've read all of the provided bytes to ensure no corruption occurred.
475+
///
476+
/// This method is slowly being phased out -- it will only be called when reading objects
477+
/// written by LDK versions prior to 0.0.113.
466478
fn read_chan_signer(&self, reader: &[u8]) -> Result<Self::Signer, DecodeError>;
467479

468480
/// Sign an invoice.
@@ -987,13 +999,8 @@ impl KeysManager {
987999
}
9881000
}
9891001
/// Derive an old Sign containing per-channel secrets based on a key derivation parameters.
990-
///
991-
/// Key derivation parameters are accessible through a per-channel secrets
992-
/// Sign::channel_keys_id and is provided inside DynamicOuputP2WSH in case of
993-
/// onchain output detection for which a corresponding delayed_payment_key must be derived.
9941002
pub fn derive_channel_keys(&self, channel_value_satoshis: u64, params: &[u8; 32]) -> InMemorySigner {
9951003
let chan_id = byte_utils::slice_to_be64(&params[0..8]);
996-
assert!(chan_id <= core::u32::MAX as u64); // Otherwise the params field wasn't created by us
9971004
let mut unique_start = Sha256::engine();
9981005
unique_start.input(params);
9991006
unique_start.input(&self.seed);
@@ -1209,14 +1216,19 @@ impl KeysInterface for KeysManager {
12091216
ShutdownScript::new_p2wpkh_from_pubkey(self.shutdown_pubkey.clone())
12101217
}
12111218

1212-
fn get_channel_signer(&self, _inbound: bool, channel_value_satoshis: u64) -> Self::Signer {
1213-
let child_ix = self.channel_child_index.fetch_add(1, Ordering::AcqRel);
1214-
assert!(child_ix <= core::u32::MAX as usize);
1219+
fn generate_channel_keys_id(&self, _inbound: bool, _channel_value_satoshis: u64, user_channel_id: u128) -> [u8; 32] {
1220+
let child_idx = self.channel_child_index.fetch_add(1, Ordering::AcqRel);
1221+
assert!(child_idx <= core::u32::MAX as usize);
12151222
let mut id = [0; 32];
1216-
id[0..8].copy_from_slice(&byte_utils::be64_to_array(child_ix as u64));
1217-
id[8..16].copy_from_slice(&byte_utils::be64_to_array(self.starting_time_nanos as u64));
1218-
id[16..24].copy_from_slice(&byte_utils::be64_to_array(self.starting_time_secs));
1219-
self.derive_channel_keys(channel_value_satoshis, &id)
1223+
id[0..4].copy_from_slice(&(child_idx as u32).to_be_bytes());
1224+
id[4..8].copy_from_slice(&self.starting_time_nanos.to_be_bytes());
1225+
id[8..16].copy_from_slice(&self.starting_time_secs.to_be_bytes());
1226+
id[16..32].copy_from_slice(&user_channel_id.to_be_bytes());
1227+
id
1228+
}
1229+
1230+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer {
1231+
self.derive_channel_keys(channel_value_satoshis, &channel_keys_id)
12201232
}
12211233

12221234
fn get_secure_random_bytes(&self) -> [u8; 32] {
@@ -1309,8 +1321,12 @@ impl KeysInterface for PhantomKeysManager {
13091321
self.inner.get_shutdown_scriptpubkey()
13101322
}
13111323

1312-
fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> Self::Signer {
1313-
self.inner.get_channel_signer(inbound, channel_value_satoshis)
1324+
fn generate_channel_keys_id(&self, inbound: bool, channel_value_satoshis: u64, user_channel_id: u128) -> [u8; 32] {
1325+
self.inner.generate_channel_keys_id(inbound, channel_value_satoshis, user_channel_id)
1326+
}
1327+
1328+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> Self::Signer {
1329+
self.inner.derive_channel_signer(channel_value_satoshis, channel_keys_id)
13141330
}
13151331

13161332
fn get_secure_random_bytes(&self) -> [u8; 32] {

lightning/src/ln/chan_utils.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1627,8 +1627,8 @@ mod tests {
16271627
let seed = [42; 32];
16281628
let network = Network::Testnet;
16291629
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
1630-
let signer = keys_provider.get_channel_signer(false, 3000);
1631-
let counterparty_signer = keys_provider.get_channel_signer(false, 3000);
1630+
let signer = keys_provider.derive_channel_signer(3000, keys_provider.generate_channel_keys_id(false, 1_000_000, 0));
1631+
let counterparty_signer = keys_provider.derive_channel_signer(3000, keys_provider.generate_channel_keys_id(true, 1_000_000, 1));
16321632
let delayed_payment_base = &signer.pubkeys().delayed_payment_basepoint;
16331633
let per_commitment_secret = SecretKey::from_slice(&hex::decode("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100").unwrap()[..]).unwrap();
16341634
let per_commitment_point = PublicKey::from_secret_key(&secp_ctx, &per_commitment_secret);
@@ -1724,9 +1724,9 @@ mod tests {
17241724
assert_eq!(tx.built.transaction.output[0].script_pubkey, get_htlc_redeemscript(&received_htlc, false, &keys).to_v0_p2wsh());
17251725
assert_eq!(tx.built.transaction.output[1].script_pubkey, get_htlc_redeemscript(&offered_htlc, false, &keys).to_v0_p2wsh());
17261726
assert_eq!(get_htlc_redeemscript(&received_htlc, false, &keys).to_v0_p2wsh().to_hex(),
1727-
"002085cf52e41ba7c099a39df504e7b61f6de122971ceb53b06731876eaeb85e8dc5");
1727+
"0020e43a7c068553003fe68fcae424fb7b28ec5ce48cd8b6744b3945631389bad2fb");
17281728
assert_eq!(get_htlc_redeemscript(&offered_htlc, false, &keys).to_v0_p2wsh().to_hex(),
1729-
"002049f0736bb335c61a04d2623a24df878a7592a3c51fa7258d41b2c85318265e73");
1729+
"0020215d61bba56b19e9eadb6107f5a85d7f99c40f65992443f69229c290165bc00d");
17301730

17311731
// Generate broadcaster output and received and offered HTLC outputs, with anchors
17321732
channel_parameters.opt_anchors = Some(());
@@ -1743,9 +1743,9 @@ mod tests {
17431743
assert_eq!(tx.built.transaction.output[2].script_pubkey, get_htlc_redeemscript(&received_htlc, true, &keys).to_v0_p2wsh());
17441744
assert_eq!(tx.built.transaction.output[3].script_pubkey, get_htlc_redeemscript(&offered_htlc, true, &keys).to_v0_p2wsh());
17451745
assert_eq!(get_htlc_redeemscript(&received_htlc, true, &keys).to_v0_p2wsh().to_hex(),
1746-
"002067114123af3f95405bae4fd930fc95de03e3c86baaee8b2dd29b43dd26cf613c");
1746+
"0020b70d0649c72b38756885c7a30908d912a7898dd5d79457a7280b8e9a20f3f2bc");
17471747
assert_eq!(get_htlc_redeemscript(&offered_htlc, true, &keys).to_v0_p2wsh().to_hex(),
1748-
"0020a06e3b0d4fcf704f2b9c41e16a70099e39989466c3142b8573a1154542f28f57");
1748+
"002087a3faeb1950a469c0e2db4a79b093a41b9526e5a6fc6ef5cb949bde3be379c7");
17491749
}
17501750

17511751
#[test]

lightning/src/ln/channel.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,8 @@ impl<Signer: Sign> Channel<Signer> {
909909
let opt_anchors = false; // TODO - should be based on features
910910

911911
let holder_selected_contest_delay = config.channel_handshake_config.our_to_self_delay;
912-
let holder_signer = keys_provider.get_channel_signer(false, channel_value_satoshis);
912+
let channel_keys_id = keys_provider.generate_channel_keys_id(false, channel_value_satoshis, user_id);
913+
let holder_signer = keys_provider.derive_channel_signer(channel_value_satoshis, channel_keys_id);
913914
let pubkeys = holder_signer.pubkeys().clone();
914915

915916
if !their_features.supports_wumbo() && channel_value_satoshis > MAX_FUNDING_SATOSHIS_NO_WUMBO {
@@ -1153,7 +1154,8 @@ impl<Signer: Sign> Channel<Signer> {
11531154
return Err(ChannelError::Close("Channel Type was not understood - we require static remote key".to_owned()));
11541155
}
11551156

1156-
let holder_signer = keys_provider.get_channel_signer(true, msg.funding_satoshis);
1157+
let channel_keys_id = keys_provider.generate_channel_keys_id(true, msg.funding_satoshis, user_id);
1158+
let holder_signer = keys_provider.derive_channel_signer(msg.funding_satoshis, channel_keys_id);
11571159
let pubkeys = holder_signer.pubkeys().clone();
11581160
let counterparty_pubkeys = ChannelPublicKeys {
11591161
funding_pubkey: msg.funding_pubkey,
@@ -6735,7 +6737,7 @@ mod tests {
67356737
use crate::ln::chan_utils::{htlc_success_tx_weight, htlc_timeout_tx_weight};
67366738
use crate::chain::BestBlock;
67376739
use crate::chain::chaininterface::{FeeEstimator, LowerBoundedFeeEstimator, ConfirmationTarget};
6738-
use crate::chain::keysinterface::{InMemorySigner, Recipient, KeyMaterial, KeysInterface};
6740+
use crate::chain::keysinterface::{BaseSign, InMemorySigner, Recipient, KeyMaterial, KeysInterface};
67396741
use crate::chain::transaction::OutPoint;
67406742
use crate::util::config::UserConfig;
67416743
use crate::util::enforcing_trait_impls::EnforcingSigner;
@@ -6803,7 +6805,10 @@ mod tests {
68036805
ShutdownScript::new_p2wpkh_from_pubkey(PublicKey::from_secret_key(&secp_ctx, &channel_close_key))
68046806
}
68056807

6806-
fn get_channel_signer(&self, _inbound: bool, _channel_value_satoshis: u64) -> InMemorySigner {
6808+
fn generate_channel_keys_id(&self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] {
6809+
self.signer.channel_keys_id()
6810+
}
6811+
fn derive_channel_signer(&self, _channel_value_satoshis: u64, _channel_keys_id: [u8; 32]) -> Self::Signer {
68076812
self.signer.clone()
68086813
}
68096814
fn get_secure_random_bytes(&self) -> [u8; 32] { [0; 32] }

lightning/src/ln/functional_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4803,7 +4803,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
48034803
assert_eq!(htlc_success_txn[2], commitment_txn[0]);
48044804
assert_eq!(htlc_success_txn[3], htlc_success_txn[0]);
48054805
assert_eq!(htlc_success_txn[4], htlc_success_txn[1]);
4806-
assert_ne!(htlc_success_txn[0].input[0].previous_output, htlc_timeout_tx.input[0].previous_output);
4806+
assert_ne!(htlc_success_txn[1].input[0].previous_output, htlc_timeout_tx.input[0].previous_output);
48074807

48084808
mine_transaction(&nodes[1], &htlc_timeout_tx);
48094809
connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1);
@@ -4826,7 +4826,7 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
48264826
// Solve 2nd HTLC by broadcasting on B's chain HTLC-Success Tx from C
48274827
// Note that the fee paid is effectively double as the HTLC value (including the nodes[1] fee
48284828
// and nodes[2] fee) is rounded down and then claimed in full.
4829-
mine_transaction(&nodes[1], &htlc_success_txn[0]);
4829+
mine_transaction(&nodes[1], &htlc_success_txn[1]);
48304830
expect_payment_forwarded!(nodes[1], nodes[0], nodes[2], Some(196*2), true, true);
48314831
let updates = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id());
48324832
assert!(updates.update_add_htlcs.is_empty());

lightning/src/util/byte_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn be64_to_array(u: u64) -> [u8; 8] {
7373
#[cfg(test)]
7474
mod tests {
7575
use super::*;
76-
76+
7777
#[test]
7878
fn test_all() {
7979
assert_eq!(slice_to_be48(&[0xde, 0xad, 0xbe, 0xef, 0x1b, 0xad]), 0xdeadbeef1bad);

lightning/src/util/test_utils.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ impl keysinterface::KeysInterface for OnlyReadsKeysInterface {
8080
fn get_inbound_payment_key_material(&self) -> KeyMaterial { unreachable!(); }
8181
fn get_destination_script(&self) -> Script { unreachable!(); }
8282
fn get_shutdown_scriptpubkey(&self) -> ShutdownScript { unreachable!(); }
83-
fn get_channel_signer(&self, _inbound: bool, _channel_value_satoshis: u64) -> EnforcingSigner { unreachable!(); }
83+
fn generate_channel_keys_id(&self, _inbound: bool, _channel_value_satoshis: u64, _user_channel_id: u128) -> [u8; 32] { unreachable!(); }
84+
fn derive_channel_signer(&self, _channel_value_satoshis: u64, _channel_keys_id: [u8; 32]) -> Self::Signer { unreachable!(); }
8485
fn get_secure_random_bytes(&self) -> [u8; 32] { [0; 32] }
8586

8687
fn read_chan_signer(&self, mut reader: &[u8]) -> Result<Self::Signer, msgs::DecodeError> {
@@ -629,8 +630,12 @@ impl keysinterface::KeysInterface for TestKeysInterface {
629630
}
630631
}
631632

632-
fn get_channel_signer(&self, inbound: bool, channel_value_satoshis: u64) -> EnforcingSigner {
633-
let keys = self.backing.get_channel_signer(inbound, channel_value_satoshis);
633+
fn generate_channel_keys_id(&self, inbound: bool, channel_value_satoshis: u64, user_channel_id: u128) -> [u8; 32] {
634+
self.backing.generate_channel_keys_id(inbound, channel_value_satoshis, user_channel_id)
635+
}
636+
637+
fn derive_channel_signer(&self, channel_value_satoshis: u64, channel_keys_id: [u8; 32]) -> EnforcingSigner {
638+
let keys = self.backing.derive_channel_signer(channel_value_satoshis, channel_keys_id);
634639
let state = self.make_enforcement_state_cell(keys.commitment_seed);
635640
EnforcingSigner::new_with_revoked(keys, state, self.disable_revocation_policy_check)
636641
}

0 commit comments

Comments
 (0)