Skip to content
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

WIP: HSM_VERSION=6: get_per_commitment_point no longer returns secret #107

Open
wants to merge 6 commits into
base: 2024-02-remote-hsmd-v24.02.1
Choose a base branch
from

Conversation

ksedgwic
Copy link

@ksedgwic ksedgwic commented Mar 15, 2024

Removes returned old_secret from get_per_commitment_point making it safe to call on all commits

Motivation: When get_per_commitment_point returns the old secret it implies a revocation of index - 2. This causes a crash when VLS has validated a commitment but not seen the following revoke of the prior and the channel is asynchronously restarted. See https://gitlab.com/lightning-signer/validating-lightning-signer/-/issues/469

The last two commits are somewhat optional: by increasing the HSM_VERSION to 6 we can inform the signer that it should never return an old_secret (and therefore can't fail). The native hsmd implementation doesn't have the safety issue and it would be ok to leave it at HSM_VERSION 5. But it's cleaner to have consistent semantics.

All but the last two commits in the PR sequence are cleanup and reduction refactoring and worth considering even if an HSM_VERSION change is not considered.

@ksedgwic ksedgwic force-pushed the 2024-03-get-per-commit-no-old-secret branch from 1a39979 to d6e4832 Compare March 15, 2024 15:15
Changelog-None: shouldn't affect others

HSM_MIN_VERSION is 5 which implies use of
WIRE_HSMD_REVOKE_COMMITMENT_TX; prune branches that can't happen.
Changelog-None: internal to channeld

Since we don't need a special path for early old_secrets from validate
we can factor away duplicate code.
@ksedgwic ksedgwic force-pushed the 2024-03-get-per-commit-no-old-secret branch from d6e4832 to 31b74c9 Compare March 15, 2024 22:26
@ksedgwic ksedgwic marked this pull request as ready for review March 15, 2024 22:46
@ksedgwic ksedgwic requested a review from devrandom as a code owner March 15, 2024 22:46
Copy link
Collaborator

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

ACK 31b74c9

Some small nits but are not important to avoid ack this PR

channeld/channeld.c Outdated Show resolved Hide resolved
@@ -436,7 +436,7 @@ static struct io_plan *init_hsm(struct io_conn *conn,
struct secret *hsm_encryption_key;
struct bip32_key_version bip32_key_version;
u32 minversion, maxversion;
const u32 our_minversion = 4, our_maxversion = 5;
const u32 our_minversion = 4, our_maxversion = 6;
Copy link
Collaborator

Choose a reason for hiding this comment

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

thinking, duer that we always upgrade this in sync, our_maxversion can be HSM_MAX_VERSION?

Changelog-None: channeld internal

This factoring makes it much clearer which callers need the pubkey and
which need the old_secret.

It does not alter the unfortunate semantic that fetching future
pubkeys beyond the next commit is an error (because the signer will
only release secrets for revoked commitments).  Using HSM_VERSION 6
will fix this semantic in hsmd.
Changelog-Changed: hsmd: HSM_VERSION 6: get_per_commitment_point does
not imply index - 2 is revoked, makes it safe to call on any index.
Changelog-Changed: hsmd: the hsmd now supports HSM_VERSION 6

This is actually optional, everything should be ok leaving native hsmd
support at HSM_VERSION 5.
@ksedgwic ksedgwic force-pushed the 2024-03-get-per-commit-no-old-secret branch from 31b74c9 to 3005799 Compare March 16, 2024 20:59
Copy link
Author

@ksedgwic ksedgwic left a comment

Choose a reason for hiding this comment

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

I fixed some code comments and commit comments.

The code comment fixes are in an intermediate commit and thus don't appear in the Compare above ...

channeld/channeld.c Outdated Show resolved Hide resolved
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