]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop requirement that all ChannelKeys expose revocaion_basepoint
authorMatt Corallo <git@bluematt.me>
Thu, 28 May 2020 20:06:28 +0000 (16:06 -0400)
committerMatt Corallo <git@bluematt.me>
Sat, 6 Jun 2020 19:59:27 +0000 (15:59 -0400)
lightning/src/chain/keysinterface.rs
lightning/src/ln/channel.rs
lightning/src/util/enforcing_trait_impls.rs

index 88040a04b7f6eece48ea717e6400647ff0d94aa3..10687b74c88174a3e66b7550eb38f8f15dd798e7 100644 (file)
@@ -195,8 +195,6 @@ impl Readable for SpendableOutputDescriptor {
 // TODO: We should remove Clone by instead requesting a new ChannelKeys copy when we create
 // ChannelMonitors instead of expecting to clone the one out of the Channel into the monitors.
 pub trait ChannelKeys : Send+Clone {
-       /// Gets the local secret key for blinded revocation pubkey
-       fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
        /// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
        fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
        /// Gets the local htlc secret key used in commitment tx htlc outputs
@@ -410,7 +408,6 @@ impl InMemoryChannelKeys {
 }
 
 impl ChannelKeys for InMemoryChannelKeys {
-       fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
        fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
        fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
        fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }
index 48d6e674d03a32928dc8cbdf4fb94d39adaa049a..f737e56a73d4e29238ffc502d3fcdda41daa2263 100644 (file)
@@ -1108,11 +1108,11 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
        fn build_remote_transaction_keys(&self) -> Result<TxCreationKeys, ChannelError> {
                //TODO: Ensure that the payment_key derived here ends up in the library users' wallet as we
                //may see payments to it!
-               let revocation_basepoint = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key());
+               let revocation_basepoint = &self.local_keys.pubkeys().revocation_basepoint;
                let htlc_basepoint = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key());
                let their_pubkeys = self.their_pubkeys.as_ref().unwrap();
 
-               Ok(secp_check!(TxCreationKeys::new(&self.secp_ctx, &self.their_cur_commitment_point.unwrap(), &their_pubkeys.delayed_payment_basepoint, &their_pubkeys.htlc_basepoint, &revocation_basepoint, &htlc_basepoint), "Remote tx keys generation got bogus keys"))
+               Ok(secp_check!(TxCreationKeys::new(&self.secp_ctx, &self.their_cur_commitment_point.unwrap(), &their_pubkeys.delayed_payment_basepoint, &their_pubkeys.htlc_basepoint, revocation_basepoint, &htlc_basepoint), "Remote tx keys generation got bogus keys"))
        }
 
        /// Gets the redeemscript for the funding transaction output (ie the funding transaction output
@@ -3315,7 +3315,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                        to_self_delay: self.our_to_self_delay,
                        max_accepted_htlcs: OUR_MAX_HTLCS,
                        funding_pubkey: local_keys.funding_pubkey,
-                       revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
+                       revocation_basepoint: local_keys.revocation_basepoint,
                        payment_point: local_keys.payment_point,
                        delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
                        htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
@@ -3349,7 +3349,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
                        to_self_delay: self.our_to_self_delay,
                        max_accepted_htlcs: OUR_MAX_HTLCS,
                        funding_pubkey: local_keys.funding_pubkey,
-                       revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
+                       revocation_basepoint: local_keys.revocation_basepoint,
                        payment_point: local_keys.payment_point,
                        delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
                        htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
index ffb05762ae6f0a5172548560faac57975905d1c9..425b2124f9cc146bca00363489f4118fbfee4638 100644 (file)
@@ -35,7 +35,6 @@ impl EnforcingChannelKeys {
 impl EnforcingChannelKeys {
        fn check_keys<T: secp256k1::Signing + secp256k1::Verification>(&self, secp_ctx: &Secp256k1<T>,
                                                                       keys: &TxCreationKeys) {
-               let revocation_base = PublicKey::from_secret_key(secp_ctx, &self.inner.revocation_base_key());
                let htlc_base = PublicKey::from_secret_key(secp_ctx, &self.inner.htlc_base_key());
 
                let remote_points = self.inner.remote_channel_pubkeys.as_ref().unwrap();
@@ -44,14 +43,13 @@ impl EnforcingChannelKeys {
                                                        &keys.per_commitment_point,
                                                        &remote_points.delayed_payment_basepoint,
                                                        &remote_points.htlc_basepoint,
-                                                       &revocation_base,
+                                                       &self.inner.pubkeys().revocation_basepoint,
                                                        &htlc_base).unwrap();
                if keys != &keys_expected { panic!("derived different per-tx keys") }
        }
 }
 
 impl ChannelKeys for EnforcingChannelKeys {
-       fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() }
        fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() }
        fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() }
        fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() }