Skip to content

ChannelKeys - separate commitment revocation from getting the per-commitment point #655

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

Merged
merged 1 commit into from
Jul 22, 2020

Conversation

devrandom
Copy link
Member

@devrandom devrandom commented Jul 11, 2020

The commitment secret is sensitive - it can be used by an attacker to steal funds if the node also signs the same transaction. In general, the signer should be considered more secure - it will, for example, be implemented in secure hardware. It should not give the rest of the node access to data which can be used by an attacker and it should enforce policy which prevents attacks.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, seems a bit cleaner than before 👍 Was there a specific motivation for this change?

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Val pointed out a good docs change, I think, but would be cool to do enforcement as well, no pressure if you don't want to do that right now, though.

@devrandom
Copy link
Member Author

devrandom commented Jul 12, 2020

@valentinewallace the motivation is that the commitment secret is sensitive - it can be used by an attacker to steal funds if the node also signs the same transaction. In general, the signer should be considered more secure - it will, for example, be implemented in secure hardware. It should not give the rest of the node access to data which can be used by an attacker and it should enforce policy which prevents attacks.

In this particular case, some of the policies include: revoke commitments in order, don't sign a revoked transaction, don't revoke a signed transaction. In the third commit I implemented the first two policies policy.

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK 0c98489, that's a good step forward, in case of node compromise, it will prevent to yell a revocation secret to a an attacker already owning a signed commitment and thus freely spendable with counterparty's revocation secret.

@@ -217,6 +225,7 @@ pub trait ChannelKeys : Send+Clone {
/// Create a signature for a local commitment transaction. This will only ever be called with
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
/// that it will not be called multiple times.
/// The commitment must not have been revoked.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you say this policy enforcement has been implemented, namely "don't sign a revoked transaction" ? I think you need to verify the new revoked_commitment against commitment transaction number. I guess you can access it by unveiling it from LocalCommitmentTransaction 's unsigned_tx. This can be addressed later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I misspoke above. I thought about implementing this, but didn't get to it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe since it's not implemented yet, rephrase the line to be a TODO?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but again, I think it should be attached to EnforcingChannelKeys

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all of our other comments are phrased as "what rust-lightning guarantees it will do" ie, instead of "The commitment must not have been revoked" this could read "The commitment transaction contained will not have been revoked by release_commitment_secret, and external signers may wish to enforce this".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworded, please take a look

@jkczyz
Copy link
Contributor

jkczyz commented Jul 13, 2020

Thanks for updating the PR description with the motivation. Could you also include this in the commit message as per the contributing guidelines? This would be useful for those looking through the commit log.

Generally, I see the PR description used for the broader motivation for a set of commits, though here there is only one commit.

@@ -217,6 +225,7 @@ pub trait ChannelKeys : Send+Clone {
/// Create a signature for a local commitment transaction. This will only ever be called with
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
/// that it will not be called multiple times.
/// The commitment must not have been revoked.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe since it's not implemented yet, rephrase the line to be a TODO?

@devrandom devrandom force-pushed the per-commitment branch 4 times, most recently from 950fa02 to b661164 Compare July 15, 2020 11:48
@devrandom
Copy link
Member Author

I rephrased a few things and added TODOs. Please take another look.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this one - I was playing with it to see if I could make the asserts pass. I believe you got the issue right, so happy take this as-is, but would be nice to get the assertions in sooner or later. I commented on your PR at https://github.com/lightning-signer/rust-lightning/pull/1/files#r457548944.

/// Gets the commitment secret for a specific commitment number as part of the revocation process
///
/// An implementation must error here if the commitment was already signed.
/// After this method is called, an implementation must ensure that it will refuse sign the relevant
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it MUST - in theory we ensure that on the rust-lightning end, certainly it can, at least if you're in a separate memory space :).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reworded

@@ -217,6 +225,7 @@ pub trait ChannelKeys : Send+Clone {
/// Create a signature for a local commitment transaction. This will only ever be called with
/// the same local_commitment_tx (or a copy thereof), though there are currently no guarantees
/// that it will not be called multiple times.
/// The commitment must not have been revoked.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all of our other comments are phrased as "what rust-lightning guarantees it will do" ie, instead of "The commitment must not have been revoked" this could read "The commitment transaction contained will not have been revoked by release_commitment_secret, and external signers may wish to enforce this".

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs rebase + squash, but otherwise looks good!

…mitment point

The commitment secret is sensitive - it can be used by an attacker to
steal funds if the node also signs the same transaction. Therefore,
only release the secret from ChannelKeys when we are revoking a
transaction.
@devrandom
Copy link
Member Author

Done

@TheBlueMatt TheBlueMatt merged commit ed84b02 into lightningdevkit:master Jul 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants