Skip to content

Creating fresh destination scripts for every channel in KeysManager #2174

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

Closed
wants to merge 1 commit into from

Conversation

vss96
Copy link
Contributor

@vss96 vss96 commented Apr 11, 2023

Continuing from #1312. This pr is to address #1139.

@vss96 vss96 force-pushed the Fresh-DestScripts branch from 52a983d to 4e52db2 Compare April 11, 2023 14:39
@codecov-commenter
Copy link

codecov-commenter commented Apr 11, 2023

Codecov Report

Attention: Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.56%. Comparing base (4f806f5) to head (733aee3).
Report is 3375 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/keysinterface.rs 92.59% 2 Missing ⚠️
lightning/src/util/test_utils.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2174      +/-   ##
==========================================
- Coverage   91.57%   91.56%   -0.01%     
==========================================
  Files         104      104              
  Lines       51782    51802      +20     
  Branches    51782    51802      +20     
==========================================
+ Hits        47417    47434      +17     
- Misses       4365     4368       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}

fn get_shutdown_scriptpubkey(&self) -> ShutdownScript {
ShutdownScript::new_p2wpkh_from_pubkey(self.shutdown_pubkey.clone())
ShutdownScript::new_p2wpkh_from_pubkey(self.shutdown_pubkey.public_key.clone())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also make this different per channel too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will deriving from the existing shutdown_pubkey at some fixed index and creating a shutdown script work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd think we just use the same derivation logic (effectively merging destination and shutdown scripts).

Change order for methods in the impl block for NodeSigner for KeysManger.

Add channel_keys_id to the methods implementing KeyProvider's get_destination_script.
@vss96 vss96 force-pushed the Fresh-DestScripts branch from 9e0d1e6 to 733aee3 Compare April 27, 2023 09:34
@@ -1087,6 +1093,7 @@ impl KeysManager {

channel_master_key,
channel_child_index: AtomicUsize::new(0),
disallow_downgrades: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs to be a parameter/configurable.

let derivation_idx = if self.disallow_downgrades {
u32::from_be_bytes(channel_keys_id[0..4].try_into().unwrap())
} else {
3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Destination key was 1 on current git, so 3 is a totally different key.

let derivation_idx = if output.script_pubkey == self.destination_script {
1
} else {
} else if Some(&output.script_pubkey) == destination_script.as_ref() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not convinced the logic here is right, the destination script in the output should always be what get_destination_script gives us, so we need to use the derivation idx as calculated there, not just always use the channel_keys_id one here.

@vss96
Copy link
Contributor Author

vss96 commented May 27, 2023

Looks like the Signerprovider has changed 😞

@TheBlueMatt
Copy link
Collaborator

Indeed, sorry about that. It hasn't changed a lot in practice, just renames and some splits. The rebase may be a bit annoying but its all the same code, really, so should be pretty doable.

@benthecarman
Copy link
Contributor

benthecarman commented Jun 6, 2023

@vss96 are you still working on this? Was hoping to try to get this in before next release

@vss96
Copy link
Contributor Author

vss96 commented Jun 7, 2023

@benthecarman if that's the case and you want to take this ahead please do so. I have been stuck on this for a while and I don't know if I can get it in before the next release.

@TheBlueMatt
Copy link
Collaborator

Any desire to pick this back up @vss96?

@TheBlueMatt
Copy link
Collaborator

When we do this we should also make the payment_key in the channel less reliant on as much entropy, so that it can theoretically be derived from the seed if we have to (maybe 32-bits of entropy or something smaller).

@vss96
Copy link
Contributor Author

vss96 commented Jul 16, 2023

Any desire to pick this back up @vss96?

Yes! let me try to rebase and fix the conflicts 😪

@TheBlueMatt
Copy link
Collaborator

Closing as abandoned.

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.

4 participants