Skip to content

Commit

Permalink
Verify xpub checksum after decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Jul 18, 2023
1 parent bdea9a0 commit dafaff1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/common/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,16 @@ int parse_policy_map_key_info(buffer_t *buffer, policy_map_key_info_t *out, int
return WITH_ERROR(-1, "Error decoding serialized extended pubkey");
}

// verify checksum
uint8_t checksum[4];
crypto_get_checksum((uint8_t *) &ext_pubkey_check.serialized_extended_pubkey,
sizeof(ext_pubkey_check.serialized_extended_pubkey),
checksum);

if (memcmp(&ext_pubkey_check.checksum, checksum, sizeof(checksum)) != 0) {
return WITH_ERROR(-1, "Wrong extended pubkey checksum");
}

out->ext_pubkey = ext_pubkey_check.serialized_extended_pubkey;

// either the string terminates now, or it has a final "/**" suffix for the wildcard.
Expand Down

0 comments on commit dafaff1

Please sign in to comment.