-
Notifications
You must be signed in to change notification settings - Fork 410
Drop ChannelKeys Private Key Methods #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1d536e
9f7bcfb
1a574d2
d9f5df9
d77e40f
e5a7422
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,18 +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 private key for the anchor tx | ||
fn funding_key<'a>(&'a self) -> &'a SecretKey; | ||
/// 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 the to_remote output of remote commitment tx (ie the | ||
/// output to us in transactions our counterparty broadcasts). | ||
/// Also as part of obscured commitment number. | ||
fn payment_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 | ||
fn htlc_base_key<'a>(&'a self) -> &'a SecretKey; | ||
/// Gets the commitment seed | ||
fn commitment_seed<'a>(&'a self) -> &'a [u8; 32]; | ||
/// Gets the local channel public keys and basepoints | ||
|
@@ -345,17 +333,17 @@ pub trait KeysInterface: Send + Sync { | |
/// A simple implementation of ChannelKeys that just keeps the private keys in memory. | ||
pub struct InMemoryChannelKeys { | ||
/// Private key of anchor tx | ||
funding_key: SecretKey, | ||
pub funding_key: SecretKey, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think even for this concrete implementation, it would be better to not make the private key properties public. Perhaps add a test config constraint? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need them to be able to sign transactions when handling SpendableOutput events, so there needs to be some way to get at them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't know the full context, but might it be better to expose a way to use them (e.g. expose a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the signing only handles in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, we dont require signing functions for SpendableOutputs events as those are purely external and can happen a month later. eg the use in the tests at https://github.com/rust-bitcoin/rust-lightning/blob/master/lightning/src/ln/functional_tests.rs#L4299 |
||
/// Local secret key for blinded revocation pubkey | ||
revocation_base_key: SecretKey, | ||
pub revocation_base_key: SecretKey, | ||
/// Local secret key used for our balance in remote-broadcasted commitment transactions | ||
payment_key: SecretKey, | ||
pub payment_key: SecretKey, | ||
/// Local secret key used in HTLC tx | ||
delayed_payment_base_key: SecretKey, | ||
pub delayed_payment_base_key: SecretKey, | ||
/// Local htlc secret key used in commitment tx htlc outputs | ||
htlc_base_key: SecretKey, | ||
pub htlc_base_key: SecretKey, | ||
/// Commitment seed | ||
commitment_seed: [u8; 32], | ||
pub commitment_seed: [u8; 32], | ||
/// Local public keys and basepoints | ||
pub(crate) local_channel_pubkeys: ChannelPublicKeys, | ||
/// Remote public keys and base points | ||
|
@@ -416,11 +404,6 @@ impl InMemoryChannelKeys { | |
} | ||
|
||
impl ChannelKeys for InMemoryChannelKeys { | ||
fn funding_key(&self) -> &SecretKey { &self.funding_key } | ||
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key } | ||
fn payment_key(&self) -> &SecretKey { &self.payment_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 } | ||
fn pubkeys<'a>(&'a self) -> &'a ChannelPublicKeys { &self.local_channel_pubkeys } | ||
fn key_derivation_params(&self) -> (u64, u64) { self.key_derivation_params } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future work, should we move
commitment_seed
out-of-memory and behind the interface by moving insidechan_utils::build_commitment_secret
? In case of undetected node compromise, access to the commitment seed let you derive revocation secret for future non-yet-existent local commitment transactions ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I think we have to. If you want an external signer to prevent the host from burning all the coins, you need some kind of exchange here, but we'd also need to get the ordering right, like, to call get_commitment_revocation_secret we'd have to first provide a copy of the new commitment transaction.