Skip to content

Fix master_fingerprint for no-origin raw keys - #1023

Closed
elnafateh wants to merge 2 commits into
rust-bitcoin:masterfrom
elnafateh:fix/master-fingerprint-no-origin
Closed

Fix master_fingerprint for no-origin raw keys#1023
elnafateh wants to merge 2 commits into
rust-bitcoin:masterfrom
elnafateh:fix/master-fingerprint-no-origin

Conversation

@elnafateh

Copy link
Copy Markdown

DescriptorPublicKey::master_fingerprint is documented to return 0x00000000 when a key has no origin, but for raw (Single) keys with no origin it instead returned a synthetic fingerprint derived from the key bytes. That fabricated value then leaked into PSBT bip32_derivation / tap_key_origins as an invented (fingerprint, empty_path) origin.

This makes master_fingerprint return the all-zero fingerprint for no-origin raw keys, matching the documented contract. xpub keys are unchanged (their no-origin fingerprint is the real xpub fingerprint).

plan.rs keyed signing assets by (fingerprint, path), which now collides for distinct raw keys; added a raw_keys set keyed by the key itself for no-origin raw keys.

Fixes #998.

@apoelstra

Copy link
Copy Markdown
Member

Wow. This is some old code. Dates to #219 (by me) which was approved and merged with no comments. I'm not sure what I was thinking.

Later in #265 we fixed the doccomment but were distracted by a bug in the other branch of the function and didn't look at this.

CI is failing because this breaks one of the examples.

The example signed via BIP32 keysource lookup on xprvs. Since
master_fingerprint now returns the all-zero fingerprint for raw no-origin
keys, the BIP32 match can no longer succeed. Sign by pubkey instead, which
the PSBT signer's pubkey/xonly fallback handles natively.
@elnafateh

Copy link
Copy Markdown
Author

@apoelstra Appreciate the pointer , and the history . You're right that this dates back to #219 (by you) and the doc was corrected in #265, but the implementation branch was left untouched, so the two were inconsistent ever since.

I fixed the example to sign by public key (a <PublicKey, PrivateKey>), which is the correct approach for raw keys anyway — there was never a keysource to match against.

@apoelstra

Copy link
Copy Markdown
Member

Lol wtf you can't even sign for an xpub using an xprv anymore? I will file an issue about the weird fingerprint computation.

Meanwhile please stop contributing to this organization.

@apoelstra apoelstra closed this Aug 16, 2026
@elnafateh
elnafateh deleted the fix/master-fingerprint-no-origin branch August 16, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

master_fingerprint() docs promise 0x00000000 for no-origin keys, but PSBT helpers export synthetic fingerprints instead

2 participants