Skip to content

Split sign_justice_transaction in two halves #923

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 2 commits into from
May 18, 2021

Conversation

ariard
Copy link

@ariard ariard commented May 15, 2021

To avoid caller data struct storing HTLC-related information when
a revokeable output is claimed on top of a commitment/second-stage
HTLC transactions, we split keysinterface::sign_justice_transaction
in two new halves keysinterfaces::sign_justice_revoked_output and
keysinterfaces::sign_justice_revoked_htlc.

Further, this split offers more flexibility to signer policy as a
commitment revokeable output might be of a value far more significant
than HTLC ones.

Note to reviewers: Should we take opportunity to split further sign_justice_revoked_output to enable even better signer policy flexibility (e.g pre-signed transactions for the balance output, key handover for HTLC output w.r.t to watchtower interactions).

Required for #642

@codecov
Copy link

codecov bot commented May 15, 2021

Codecov Report

Merging #923 (6319690) into main (fcc0723) will increase coverage by 0.65%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #923      +/-   ##
==========================================
+ Coverage   90.50%   91.15%   +0.65%     
==========================================
  Files          59       59              
  Lines       29769    32442    +2673     
==========================================
+ Hits        26942    29574    +2632     
- Misses       2827     2868      +41     
Impacted Files Coverage Δ
lightning/src/chain/keysinterface.rs 94.92% <100.00%> (+1.25%) ⬆️
lightning/src/ln/onchaintx.rs 87.52% <100.00%> (+0.04%) ⬆️
lightning/src/util/enforcing_trait_impls.rs 90.38% <100.00%> (+0.28%) ⬆️
lightning-block-sync/src/rest.rs 65.45% <0.00%> (-1.79%) ⬇️
lightning-block-sync/src/rpc.rs 78.37% <0.00%> (-1.11%) ⬇️
lightning-block-sync/src/poll.rs 91.66% <0.00%> (-0.38%) ⬇️
lightning-block-sync/src/lib.rs 95.18% <0.00%> (-0.20%) ⬇️
lightning-net-tokio/src/lib.rs 76.25% <0.00%> (-0.17%) ⬇️
lightning-block-sync/src/init.rs 93.56% <0.00%> (-0.15%) ⬇️
lightning/src/ln/functional_tests.rs 97.18% <0.00%> (+0.18%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcc0723...6319690. Read the comment docs.

@@ -279,8 +279,24 @@ pub trait BaseSign {
#[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
fn unsafe_sign_holder_commitment_and_htlcs(&self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<(Signature, Vec<Signature>), ()>;

/// Create a signature for the given input in a transaction spending an HTLC or commitment
/// transaction output when our counterparty broadcasts an old state.
/// Create a signature for the given input in a transaction spending a HTLC transction output
Copy link
Member

Choose a reason for hiding this comment

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

spelling "transaction"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also "an HTLC" not "a HTLC". English sucks.

@devrandom
Copy link
Member

ACK

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.

Just some spelling and grammar stuff, looks good.

@@ -279,8 +279,24 @@ pub trait BaseSign {
#[cfg(any(test,feature = "unsafe_revoked_tx_signing"))]
fn unsafe_sign_holder_commitment_and_htlcs(&self, commitment_tx: &HolderCommitmentTransaction, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<(Signature, Vec<Signature>), ()>;

/// Create a signature for the given input in a transaction spending an HTLC or commitment
/// transaction output when our counterparty broadcasts an old state.
/// Create a signature for the given input in a transaction spending a HTLC transction output
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also "an HTLC" not "a HTLC". English sucks.

@ariard ariard force-pushed the 2021-05-split-sign-justice branch from dee518a to 8b97f1d Compare May 17, 2021 18:28
@ariard
Copy link
Author

ariard commented May 17, 2021

Thanks for review, I think I've addressed all the grammar stuff and took code style suggestion in 8b97f1d

@TheBlueMatt TheBlueMatt added this to the 0.0.15 milestone May 17, 2021
Err(_) => return Err(())
let revocation_pubkey = chan_utils::derive_public_revocation_key(&secp_ctx, &per_commitment_point, &self.pubkeys().revocation_basepoint).map_err(|_| ())?;
let witness_script = {
let counterparty_delayedpubkey = match chan_utils::derive_public_key(&secp_ctx, &per_commitment_point, &self.counterparty_pubkeys().delayed_payment_basepoint) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: here and a couple more places for .map_err, but it can also be done in a future PR

Copy link
Author

Choose a reason for hiding this comment

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

Yes but did it for some more switches

@ariard ariard force-pushed the 2021-05-split-sign-justice branch from 8b97f1d to 30a41dd Compare May 18, 2021 02:24
Antoine Riard added 2 commits May 17, 2021 22:31
To avoid caller data struct storing HTLC-related information when
a revokeable output is claimed on top of a commitment/second-stage
HTLC transactions, we split `keysinterface::sign_justice_transaction`
in two new halves `keysinterfaces::sign_justice_revoked_output` and
`keysinterfaces::sign_justice_revoked_htlc`.

Further, this split offers more flexibility to signer policy as a
commitment revokeable output might be of a value far more significant
than HTLC ones.
@ariard ariard force-pushed the 2021-05-split-sign-justice branch from 30a41dd to 6319690 Compare May 18, 2021 02:32
@TheBlueMatt TheBlueMatt merged commit 5d74cae into lightningdevkit:main May 18, 2021
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.

3 participants