Skip to content

Commit

Permalink
Check return value when calling musig_key_agg
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Jan 10, 2025
1 parent e02379d commit 3a7100e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/handler/lib/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ __attribute__((warn_unused_result)) static int get_derived_pubkey(
qsort(keys, musig_info->n, sizeof(plain_pk_t), compare_plain_pk);

musig_keyagg_context_t musig_ctx;
musig_key_agg(keys, musig_info->n, &musig_ctx);
if (0 > musig_key_agg(keys, musig_info->n, &musig_ctx)) {
return -1;
}

// compute the aggregated extended pubkey
memset(&ext_pubkey, 0, sizeof(ext_pubkey));
Expand Down
4 changes: 3 additions & 1 deletion src/handler/sign_psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,9 @@ static bool fill_keyexpr_info_if_internal(dispatcher_context_t *dc,
qsort(keys, musig_info->n, sizeof(plain_pk_t), compare_plain_pk);

musig_keyagg_context_t musig_ctx;
musig_key_agg(keys, musig_info->n, &musig_ctx);
if (0 > musig_key_agg(keys, musig_info->n, &musig_ctx)) {
return false;
}

// compute the aggregated extended pubkey
memset(&keyexpr_info->pubkey, 0, sizeof(keyexpr_info->pubkey));
Expand Down
6 changes: 5 additions & 1 deletion src/musig/musig.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ static int musig_get_session_values(const musig_session_context_t *session_ctx,

// Perform key aggregation and tweaking
musig_keyagg_context_t keyagg_ctx;
musig_key_agg(session_ctx->pubkeys, session_ctx->n_keys, &keyagg_ctx);

if (0 > musig_key_agg(session_ctx->pubkeys, session_ctx->n_keys, &keyagg_ctx)) {
return -1;
}

for (size_t i = 0; i < session_ctx->n_tweaks; i++) {
if (0 > apply_tweak(&keyagg_ctx, session_ctx->tweaks[i], session_ctx->is_xonly[i])) {
return -1;
Expand Down

0 comments on commit 3a7100e

Please sign in to comment.