diff --git a/src/handler/lib/policy.c b/src/handler/lib/policy.c index 7af8280f..9ecf5428 100644 --- a/src/handler/lib/policy.c +++ b/src/handler/lib/policy.c @@ -420,7 +420,7 @@ execute_processor(policy_parser_state_t *state, policy_parser_processor_t proc, // convenience function, split from get_derived_pubkey only to improve stack usage // returns -1 on error, 0 if the returned key info has no wildcard (**), 1 if it has the wildcard -__attribute__((noinline, warn_unused_result)) int get_extended_pubkey( +__attribute__((noinline, warn_unused_result)) int get_extended_pubkey_from_client( dispatcher_context_t *dispatcher_context, const wallet_derivation_info_t *wdi, int key_index, @@ -464,7 +464,10 @@ __attribute__((warn_unused_result)) static int get_derived_pubkey( serialized_extended_pubkey_t ext_pubkey; if (key_expr->type == KEY_EXPRESSION_NORMAL) { - if (0 > get_extended_pubkey(dispatcher_context, wdi, key_expr->k.key_index, &ext_pubkey)) { + if (0 > get_extended_pubkey_from_client(dispatcher_context, + wdi, + key_expr->k.key_index, + &ext_pubkey)) { return -1; } } else if (key_expr->type == KEY_EXPRESSION_MUSIG) { @@ -473,7 +476,10 @@ __attribute__((warn_unused_result)) static int get_derived_pubkey( plain_pk_t keys[MAX_PUBKEYS_PER_MUSIG]; for (int i = 0; i < musig_info->n; i++) { // we use ext_pubkey as a temporary variable; will overwrite later - if (0 > get_extended_pubkey(dispatcher_context, wdi, key_indexes[i], &ext_pubkey)) { + if (0 > get_extended_pubkey_from_client(dispatcher_context, + wdi, + key_indexes[i], + &ext_pubkey)) { return -1; } memcpy(keys[i], ext_pubkey.compressed_pubkey, sizeof(ext_pubkey.compressed_pubkey)); diff --git a/src/handler/lib/policy.h b/src/handler/lib/policy.h index 25f0e564..e5cd2418 100644 --- a/src/handler/lib/policy.h +++ b/src/handler/lib/policy.h @@ -54,23 +54,18 @@ typedef struct { } wallet_derivation_info_t; /** - * Computes the a derived compressed pubkey for one of the key of the wallet policy, - * for a given change/address_index combination. - * - * This function computes the extended public key (xpub) based on the provided - * BIP32 derivation path. It supports both standard BIP32 derivation and - * the derivation of Musig (multi-signature) keys. + * Requests and parses the serialized extended public key from the client. * * @param[in] dispatcher_context Pointer to the dispatcher content * @param[in] wdi Pointer to a `wallet_derivation_info_t` struct with the details of the - * necessary details of the wallet policy, and the desired change/address_index pair. + * necessary details of the wallet policy. The change/addr_index pairs are not * @param[in] key_index Index of the pubkey in the vector of keys of the wallet policy. * @param[out] out Pointer to a `serialized_extended_pubkey_t` that will contain the requested * extended pubkey. * * @return -1 on error, 0 if the returned key info has no wildcard (**), 1 if it has the wildcard. */ -__attribute__((warn_unused_result)) int get_extended_pubkey( +__attribute__((warn_unused_result)) int get_extended_pubkey_from_client( dispatcher_context_t *dispatcher_context, const wallet_derivation_info_t *wdi, int key_index, diff --git a/src/handler/sign_psbt.c b/src/handler/sign_psbt.c index 3f54a113..ecf853a9 100644 --- a/src/handler/sign_psbt.c +++ b/src/handler/sign_psbt.c @@ -2595,7 +2595,7 @@ static bool compute_musig_per_input_info(dispatcher_context_t *dc, LEDGER_ASSERT(musig_info->n <= MAX_PUBKEYS_PER_MUSIG, "Too many keys in musig key expression"); for (int i = 0; i < musig_info->n; i++) { // we use ext_pubkey as a temporary variable; will overwrite later - if (0 > get_extended_pubkey(dc, &wdi, key_indexes[i], &ext_pubkey)) { + if (0 > get_extended_pubkey_from_client(dc, &wdi, key_indexes[i], &ext_pubkey)) { return -1; } memcpy(out->keys[i], ext_pubkey.compressed_pubkey, sizeof(ext_pubkey.compressed_pubkey));