@@ -270,11 +270,14 @@ pub enum SpendableOutputDescriptor {
270270 /// it is an output from an old state which we broadcast (which should never happen).
271271 ///
272272 /// To derive the delayed payment key which is used to sign this input, you must pass the
273- /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the
274- /// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided
275- /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The DelayedPaymentKey can be
276- /// generated without the secret key using [`DelayedPaymentKey::from_basepoint`] and only the
277- /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`].
273+ /// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which
274+ /// corresponds to the [`ChannelPublicKeys::delayed_payment_basepoint`] in
275+ /// [`ChannelSigner::new_pubkeys`]) and the provided
276+ /// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to
277+ /// [`chan_utils::derive_private_key`]. The DelayedPaymentKey can be generated without the
278+ /// secret key using [`DelayedPaymentKey::from_basepoint`] and only the
279+ /// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in
280+ /// [`ChannelSigner::new_pubkeys`].
278281 ///
279282 /// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is
280283 /// used in the witness script generation), you must pass the counterparty
@@ -289,7 +292,7 @@ pub enum SpendableOutputDescriptor {
289292 /// [`chan_utils::get_revokeable_redeemscript`].
290293 DelayedPaymentOutput ( DelayedPaymentOutputDescriptor ) ,
291294 /// An output spendable exclusively by our payment key (i.e., the private key that corresponds
292- /// to the `payment_point` in [`ChannelSigner::pubkeys `]). The output type depends on the
295+ /// to the `payment_point` in [`ChannelSigner::new_pubkeys `]). The output type depends on the
293296 /// channel type negotiated.
294297 ///
295298 /// On an anchor outputs channel, the witness in the spending input is:
@@ -789,14 +792,17 @@ pub trait ChannelSigner {
789792 /// and pause future signing operations until this validation completes.
790793 fn validate_counterparty_revocation ( & self , idx : u64 , secret : & SecretKey ) -> Result < ( ) , ( ) > ;
791794
792- /// Returns the holder's channel public keys and basepoints.
795+ /// Returns a *new* set of holder channel public keys and basepoints. They may be the same as a
796+ /// previous value, but are also allowed to change arbitrarily. Signing methods must still
797+ /// support signing for any keys which have ever been returned. This should only be called
798+ /// either for new channels or new splices.
793799 ///
794800 /// `splice_parent_funding_txid` can be used to compute a tweak to rotate the funding key in the
795801 /// 2-of-2 multisig script during a splice. See [`compute_funding_key_tweak`] for an example
796802 /// tweak and more details.
797803 ///
798804 /// This method is *not* asynchronous. Instead, the value must be cached locally.
799- fn pubkeys (
805+ fn new_pubkeys (
800806 & self , splice_parent_funding_txid : Option < Txid > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
801807 ) -> ChannelPublicKeys ;
802808
@@ -1095,7 +1101,7 @@ mod sealed {
10951101 use bitcoin:: secp256k1:: { Scalar , SecretKey } ;
10961102
10971103 #[ derive( Clone , PartialEq ) ]
1098- pub struct MaybeTweakedSecretKey ( SecretKey ) ;
1104+ pub struct MaybeTweakedSecretKey ( pub ( super ) SecretKey ) ;
10991105
11001106 impl From < SecretKey > for MaybeTweakedSecretKey {
11011107 fn from ( value : SecretKey ) -> Self {
@@ -1163,8 +1169,6 @@ pub struct InMemorySigner {
11631169 pub htlc_base_key : SecretKey ,
11641170 /// Commitment seed.
11651171 pub commitment_seed : [ u8 ; 32 ] ,
1166- /// Holder public keys and basepoints.
1167- pub ( crate ) holder_channel_pubkeys : ChannelPublicKeys ,
11681172 /// Key derivation parameters.
11691173 channel_keys_id : [ u8 ; 32 ] ,
11701174 /// A source of random bytes.
@@ -1180,7 +1184,6 @@ impl PartialEq for InMemorySigner {
11801184 && self . delayed_payment_base_key == other. delayed_payment_base_key
11811185 && self . htlc_base_key == other. htlc_base_key
11821186 && self . commitment_seed == other. commitment_seed
1183- && self . holder_channel_pubkeys == other. holder_channel_pubkeys
11841187 && self . channel_keys_id == other. channel_keys_id
11851188 }
11861189}
@@ -1195,7 +1198,6 @@ impl Clone for InMemorySigner {
11951198 delayed_payment_base_key : self . delayed_payment_base_key . clone ( ) ,
11961199 htlc_base_key : self . htlc_base_key . clone ( ) ,
11971200 commitment_seed : self . commitment_seed . clone ( ) ,
1198- holder_channel_pubkeys : self . holder_channel_pubkeys . clone ( ) ,
11991201 channel_keys_id : self . channel_keys_id ,
12001202 entropy_source : RandomBytes :: new ( self . get_secure_random_bytes ( ) ) ,
12011203 }
@@ -1204,21 +1206,11 @@ impl Clone for InMemorySigner {
12041206
12051207impl InMemorySigner {
12061208 #[ cfg( any( feature = "_test_utils" , test) ) ]
1207- pub fn new < C : Signing > (
1208- secp_ctx : & Secp256k1 < C > , funding_key : SecretKey , revocation_base_key : SecretKey ,
1209- payment_key_v1 : SecretKey , payment_key_v2 : SecretKey , delayed_payment_base_key : SecretKey ,
1210- htlc_base_key : SecretKey , commitment_seed : [ u8 ; 32 ] , channel_keys_id : [ u8 ; 32 ] ,
1211- rand_bytes_unique_start : [ u8 ; 32 ] ,
1209+ pub fn new (
1210+ funding_key : SecretKey , revocation_base_key : SecretKey , payment_key_v1 : SecretKey ,
1211+ payment_key_v2 : SecretKey , delayed_payment_base_key : SecretKey , htlc_base_key : SecretKey ,
1212+ commitment_seed : [ u8 ; 32 ] , channel_keys_id : [ u8 ; 32 ] , rand_bytes_unique_start : [ u8 ; 32 ] ,
12121213 ) -> InMemorySigner {
1213- // TODO: Make the key used dynamic
1214- let holder_channel_pubkeys = InMemorySigner :: make_holder_keys (
1215- secp_ctx,
1216- & funding_key,
1217- & revocation_base_key,
1218- & payment_key_v1,
1219- & delayed_payment_base_key,
1220- & htlc_base_key,
1221- ) ;
12221214 InMemorySigner {
12231215 funding_key : sealed:: MaybeTweakedSecretKey :: from ( funding_key) ,
12241216 revocation_base_key,
@@ -1227,28 +1219,17 @@ impl InMemorySigner {
12271219 delayed_payment_base_key,
12281220 htlc_base_key,
12291221 commitment_seed,
1230- holder_channel_pubkeys,
12311222 channel_keys_id,
12321223 entropy_source : RandomBytes :: new ( rand_bytes_unique_start) ,
12331224 }
12341225 }
12351226
12361227 #[ cfg( not( any( feature = "_test_utils" , test) ) ) ]
1237- fn new < C : Signing > (
1238- secp_ctx : & Secp256k1 < C > , funding_key : SecretKey , revocation_base_key : SecretKey ,
1239- payment_key_v1 : SecretKey , payment_key_v2 : SecretKey , delayed_payment_base_key : SecretKey ,
1240- htlc_base_key : SecretKey , commitment_seed : [ u8 ; 32 ] , channel_keys_id : [ u8 ; 32 ] ,
1241- rand_bytes_unique_start : [ u8 ; 32 ] ,
1228+ fn new (
1229+ funding_key : SecretKey , revocation_base_key : SecretKey , payment_key_v1 : SecretKey ,
1230+ payment_key_v2 : SecretKey , delayed_payment_base_key : SecretKey , htlc_base_key : SecretKey ,
1231+ commitment_seed : [ u8 ; 32 ] , channel_keys_id : [ u8 ; 32 ] , rand_bytes_unique_start : [ u8 ; 32 ] ,
12421232 ) -> InMemorySigner {
1243- // TODO: Make the key used dynamic
1244- let holder_channel_pubkeys = InMemorySigner :: make_holder_keys (
1245- secp_ctx,
1246- & funding_key,
1247- & revocation_base_key,
1248- & payment_key_v1,
1249- & delayed_payment_base_key,
1250- & htlc_base_key,
1251- ) ;
12521233 InMemorySigner {
12531234 funding_key : sealed:: MaybeTweakedSecretKey :: from ( funding_key) ,
12541235 revocation_base_key,
@@ -1257,7 +1238,6 @@ impl InMemorySigner {
12571238 delayed_payment_base_key,
12581239 htlc_base_key,
12591240 commitment_seed,
1260- holder_channel_pubkeys,
12611241 channel_keys_id,
12621242 entropy_source : RandomBytes :: new ( rand_bytes_unique_start) ,
12631243 }
@@ -1271,22 +1251,6 @@ impl InMemorySigner {
12711251 self . funding_key . with_tweak ( tweak)
12721252 }
12731253
1274- fn make_holder_keys < C : Signing > (
1275- secp_ctx : & Secp256k1 < C > , funding_key : & SecretKey , revocation_base_key : & SecretKey ,
1276- payment_key : & SecretKey , delayed_payment_base_key : & SecretKey , htlc_base_key : & SecretKey ,
1277- ) -> ChannelPublicKeys {
1278- let from_secret = |s : & SecretKey | PublicKey :: from_secret_key ( secp_ctx, s) ;
1279- ChannelPublicKeys {
1280- funding_pubkey : from_secret ( & funding_key) ,
1281- revocation_basepoint : RevocationBasepoint :: from ( from_secret ( & revocation_base_key) ) ,
1282- payment_point : from_secret ( & payment_key) ,
1283- delayed_payment_basepoint : DelayedPaymentBasepoint :: from ( from_secret (
1284- & delayed_payment_base_key,
1285- ) ) ,
1286- htlc_basepoint : HtlcBasepoint :: from ( from_secret ( & htlc_base_key) ) ,
1287- }
1288- }
1289-
12901254 /// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
12911255 /// by `descriptor`, returning the witness stack for the input.
12921256 ///
@@ -1476,10 +1440,21 @@ impl ChannelSigner for InMemorySigner {
14761440 Ok ( ( ) )
14771441 }
14781442
1479- fn pubkeys (
1443+ fn new_pubkeys (
14801444 & self , splice_parent_funding_txid : Option < Txid > , secp_ctx : & Secp256k1 < secp256k1:: All > ,
14811445 ) -> ChannelPublicKeys {
1482- let mut pubkeys = self . holder_channel_pubkeys . clone ( ) ;
1446+ let from_secret = |s : & SecretKey | PublicKey :: from_secret_key ( secp_ctx, s) ;
1447+ let mut pubkeys = ChannelPublicKeys {
1448+ funding_pubkey : from_secret ( & self . funding_key . 0 ) ,
1449+ revocation_basepoint : RevocationBasepoint :: from ( from_secret ( & self . revocation_base_key ) ) ,
1450+ // TODO: Make the payment_key used dynamic
1451+ payment_point : from_secret ( & self . payment_key_v1 ) ,
1452+ delayed_payment_basepoint : DelayedPaymentBasepoint :: from ( from_secret (
1453+ & self . delayed_payment_base_key ,
1454+ ) ) ,
1455+ htlc_basepoint : HtlcBasepoint :: from ( from_secret ( & self . htlc_base_key ) ) ,
1456+ } ;
1457+
14831458 if splice_parent_funding_txid. is_some ( ) {
14841459 pubkeys. funding_pubkey =
14851460 self . funding_key ( splice_parent_funding_txid) . public_key ( secp_ctx) ;
@@ -2135,7 +2110,6 @@ impl KeysManager {
21352110 u64:: from_le_bytes ( commitment_seed[ ..8 ] . try_into ( ) . expect ( "8 bytes" ) ) ;
21362111
21372112 InMemorySigner :: new (
2138- & self . secp_ctx ,
21392113 funding_key,
21402114 revocation_base_key,
21412115 payment_key_v1,
0 commit comments