What changed, and why it matters
This commit tightens public-key validation inside PSBT (Partially Signed Bitcoin Transaction) handling by rejecting 'hybrid' public keys. Hybrid keys are an old, non-standard encoding that sits between compressed and uncompressed formats. The change swaps a lenient verifier for a strict one in four places where PSBT data is parsed, so malformed or non-standard keys are now refused rather than accepted.
Review whether any callers or downstream users intentionally relied on hybrid-key acceptance; update tests to cover compressed, uncompressed, and rejected hybrid encodings; consider documenting the stricter parsing behavior in release notes.
Security signals we found
Rejects non-standard hybrid public-key encoding in transaction-related data
Narrows public-key acceptance to only compressed/uncompressed standard encodings
Applies consistent strict validation across keypath, signature, and blinding pubkey paths
Could prevent malleability or parsing confusion caused by hybrid-key representations
Evidence from the diff
The patch replaces wally_ec_public_key_verify() with wally_ec_public_key_strict_verify() in src/map.c (keypath_key_verify) and src/psbt.c (pubkey_sig_verify, pset_output_field_verify, psbt_output_get_blinding_state). The strict variant rejects hybrid public keys (legacy 65-byte format with an odd/even prefix byte but no full y-coordinate semantics), while the previous function accepted them. This affects keypath derivation records, pubkey+signature pairs in PSBT inputs, PSET output blinding/ECDH pubkeys, and blinding state checks.
Changed components
src/map.c keypath_key_verify()src/psbt.c pubkey_sig_verify()src/psbt.c pset_output_field_verify()src/psbt.c psbt_output_get_blinding_state()Inspect captured patch +4 / −4
### src/map.c
@@ -597,7 +597,7 @@ static int keypath_key_verify(const unsigned char *key, size_t key_len, struct e
} else if (key_len == EC_PUBLIC_KEY_LEN ||
key_len == EC_PUBLIC_KEY_UNCOMPRESSED_LEN) {
/* Compressed or uncompressed pubkey */
- ret = wally_ec_public_key_verify(key, key_len);
+ ret = wally_ec_public_key_strict_verify(key, key_len);
} else if (key_len == BIP32_SERIALIZED_LEN) {
/* BIP32 extended pubkey */
ret = bip32_key_unserialize(key, key_len, key_out);
### src/psbt.c
@@ -539,7 +539,7 @@ static int der_sig_verify(const unsigned char *der, size_t der_len)
static int pubkey_sig_verify(const unsigned char *key, size_t key_len,
const unsigned char *val, size_t val_len)
{
- int ret = wally_ec_public_key_verify(key, key_len);
+ int ret = wally_ec_public_key_strict_verify(key, key_len);
if (ret == WALLY_OK)
ret = der_sig_verify(val, val_len);
return ret;
@@ -725,7 +725,7 @@ static int pset_output_field_verify(uint32_t field_type,
/* 33 byte compressed pubkeys */
if (val_len != EC_PUBLIC_KEY_LEN)
return WALLY_EINVAL; /* Uncompressed keys are not allowed */
- return wally_ec_public_key_verify(val, val_len);
+ return wally_ec_public_key_strict_verify(val, val_len);
break;
case PSET_OUT_VALUE_RANGEPROOF:
case PSET_OUT_ASSET_SURJECTION_PROOF:
@@ -1028,7 +1028,7 @@ static int psbt_output_get_blinding_state(const struct wally_psbt_output *output
if ((p = wally_map_get_integer(&output->pset_fields, ft))) {
*written |= PSET_FT(ft);
if ((ft == PSET_OUT_BLINDING_PUBKEY || ft == PSET_OUT_ECDH_PUBKEY) &&
- wally_ec_public_key_verify(p->value, p->value_len) != WALLY_OK)
+ wally_ec_public_key_strict_verify(p->value, p->value_len) != WALLY_OK)
return WALLY_ERROR; /* Invalid */
}
}Why this scored 47/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.