Skip to content

Commit

Permalink
hsmd: increase the min version
Browse files Browse the repository at this point in the history
Increasing the min version of the hsmd due that we
added new code that required the hsmd to sign an announcements.

One of the solution is to increase the min version in this way
a signer like VLS fails directly during the init phase.

Link: ElementsProject#7074
Changelog-None: hsmd: increase the min version
Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo authored and cdecker committed Feb 27, 2024
1 parent b7b8e8d commit ef40b2f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/hsm_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
* v5 with hsmd_revoke_commitment_tx: 5742538f87ef5d5bf55b66dc19e52c8683cfeb1b887d3e64ba530ba9a4d8e638
* v5 with sign_any_cannouncement: 5fdb9068c43a21887dc03f7dce410d2e3eeff6277f0d49b4fc56595a798fd4a4
*/
#define HSM_MIN_VERSION 3
#define HSM_MIN_VERSION 5
#define HSM_MAX_VERSION 5
#endif /* LIGHTNING_COMMON_HSM_VERSION_H */
7 changes: 5 additions & 2 deletions hsmd/hsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 2, our_maxversion = 3;
const u32 our_minversion = 4, our_maxversion = 5;

/* This must be lightningd. */
assert(is_lightningd(c));
Expand Down Expand Up @@ -489,7 +489,10 @@ static struct io_plan *init_hsm(struct io_conn *conn,
if (hsm_encryption_key)
discard_key(take(hsm_encryption_key));

return req_reply(conn, c, hsmd_init(hsm_secret, bip32_key_version));
/* Define the minimum common max version for the hsmd one */
u64 mutual_version = maxversion < our_maxversion ? maxversion : our_maxversion;
return req_reply(conn, c, hsmd_init(hsm_secret, mutual_version,
bip32_key_version));
}

/*~ Since we process requests then service them in strict order, and because
Expand Down
4 changes: 2 additions & 2 deletions hsmd/libhsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,7 @@ u8 *hsmd_handle_client_message(const tal_t *ctx, struct hsmd_client *client,
return hsmd_status_bad_request(client, msg, "Unknown request");
}

u8 *hsmd_init(struct secret hsm_secret,
u8 *hsmd_init(struct secret hsm_secret, const u64 hsmd_version,
struct bip32_key_version bip32_key_version)
{
u8 bip32_seed[BIP32_ENTROPY_LEN_256];
Expand Down Expand Up @@ -2297,7 +2297,7 @@ u8 *hsmd_init(struct secret hsm_secret,
* incompatibility detection) with alternate implementations.
*/
return take(towire_hsmd_init_reply_v4(
NULL, 4,
NULL, hsmd_version,
/* Capabilities arg needs to be a tal array */
tal_dup_arr(tmpctx, u32, capabilities,
ARRAY_SIZE(capabilities), 0),
Expand Down
2 changes: 1 addition & 1 deletion hsmd/libhsmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct hsmd_client {
* Returns the `hsmd_init_reply` with the information required by
* `lightningd`.
*/
u8 *hsmd_init(struct secret hsm_secret,
u8 *hsmd_init(struct secret hsm_secret, const u64 hsmd_version,
struct bip32_key_version bip32_key_version);

struct hsmd_client *hsmd_client_new_main(const tal_t *ctx, u64 capabilities,
Expand Down

0 comments on commit ef40b2f

Please sign in to comment.