Skip to content

BIP-0322: clarify motivation/purpose, add prefix, clarify Proof of Funds format, describe PSBT based signing#2141

Open
guggero wants to merge 13 commits intobitcoin:masterfrom
guggero:bip-0322-finalization
Open

BIP-0322: clarify motivation/purpose, add prefix, clarify Proof of Funds format, describe PSBT based signing#2141
guggero wants to merge 13 commits intobitcoin:masterfrom
guggero:bip-0322-finalization

Conversation

@guggero
Copy link
Copy Markdown
Contributor

@guggero guggero commented Apr 14, 2026

This PR is an attempt to push this PR forward, hopefully closer to a Complete state.

If it helps the process and @kallewoof agrees, I'm volunteering to be named as a deputy for this BIP.

The PR addresses the following discussion items:

TODO (will follow up with these items soon):

@murchandamus I went through the different discussions you linked and also both Bitcoin Core PRs and tried to extract all discussion items that I felt were not yet addressed.
If anyone feels like a previous discussion item is missing here and not yet addressed by my changes, please comment below!

@jonatack jonatack added Proposed BIP modification PR by non-owner to update BIP content Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified labels Apr 14, 2026
@jonatack
Copy link
Copy Markdown
Member

jonatack commented Apr 14, 2026

Thank you @guggero for picking this up.

If it helps the process and @kallewoof agrees, I'm volunteering to be named as a deputy for this BIP.

@kallewoof thoughts? (If helpful, see BIP3 here for details about the Deputy role.)

Comment thread bip-0322.mediawiki Outdated
== Changelog ==

* '''1.0.0''' (202?-??-??):
** Mark Final
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per BIP3, statuses are now one of Draft | Complete | Deployed | Closed.

The BIP status doesn't appear to be updated from Draft in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, added the change from Draft -> Complete now in the last commit and fixed the changelog.

Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review of the first three commits.

Comment thread bip-0322.mediawiki Outdated
== Changelog ==

* '''1.0.0''' (202?-??-??):
** Mark Final
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "BIP-0322: add tentative changelog"

Final is a loaded term in context of the BIPs process. It used to refer to the status that we now call Deployed. Perhaps you could clarify whether you intend to move the BIP to Complete ("all planned work is done, and you are recommending it for adoption") or to Deployed ("all of the above, and at least one project is using it in production on mainnet"). This Changelog entry would then best be paired with the corresponding status change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you're right, changed to Complete.

Comment thread bip-0322.mediawiki Outdated

The current message signing standard only works for P2PKH (1...) invoice addresses. We propose to extend and generalize the standard by using a Bitcoin Script based approach. This ensures that any coins, no matter what script they are controlled by, can in-principle be signed for. For easy interoperability with existing signing hardware, we also define a signature message format which resembles a Bitcoin transaction (except that it contains an invalid input, so it cannot be spent on any real network).

The Proof-of-Funds variant allows demonstrating control of a set of UTXOs. The list of UTXOs may or may not be related to the address being signed (the address is optional in the Proof-of-Funds variant). But in any case, the UTXO list does not aim to prove completeness (e.g. it does NOT mean: "these are all UTXOs that exist for an address") nor that they are unspent (e.g. a validator must consult the blockchain to verify that).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“The list of UTXOs may or may not be related to the address being signed”

What “address” is this referring to? I thought BIP 322 message signing works by essentially creating a “fake” transaction where the list of inputs demonstrates control of UTXOs by providing valid inputs for the corresponding output scripts. I’m confused by the singular address vs UTXO list in this line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The address is the pkScript you spend in the to_spend transaction, also called the message_challenge in the BIP. In the simple and full case, that's the single UTXO you spend with the fake transaction. In the proof of funds case, you can add more UTXOs, but those don't have to be related to the address. I clarified this in the latest update.

Comment thread bip-0322.mediawiki Outdated
Additionally, the current message signature format uses ECDSA signatures which do not commit to the public key, meaning that they do not actually prove knowledge of any secret keys. (Indeed, valid signatures can be tweaked by 3rd parties to become valid signatures on certain related keys.)

Ultimately no message signing protocol can actually prove control of funds, both because a signature is obsolete as soon as it is created, and because the possessor of a secret key may be willing to sign messages on others' behalf even if it would not sign actual transactions. No signmessage protocol can fix these limitations.
Ultimately no message signing protocol can actually prove control of funds, both because a signature is obsolete as soon as it is created, and because the possessor of a secret key may be willing to sign messages on others' behalf even if it would not sign actual transactions. No message signing protocol can fix these limitations.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please generally limit the length of any lines you add? Whitespace in the Mediawiki sourcecode doesn’t affect the rendering of the document, but GitHub stops highlighting the changed words after certain lengths:

Image

It is easier to parse what changed across commits when the text is composed of shorter lines, and it is also easier to provide suggestions in review comments. I would suggest a maximum text-width of 100 characters for the initial additions, and would request that diffs are minimized afterwards (i.e., when updating any line, allow for slightly shorter or longer lines over rebreaking or otherwise affecting untouched lines; for longer additions prefer inserting another line over changing linebreak of the following lines).

E.g., in the example below instead of moving "procedures" to the next line to make the first line adhere to the original length limit, which would make the diff appear bigger than it is, it’s kept in the same line to minimize the diff.

Image

Basically, please treat the document’s text like code! 🤓

Please Note that I’m not requesting that you reformat the entire existing document. Should you decide to do that, please make it a separate commit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yeah, I also don't like long lines. I remembered mediawiki being really weird when it comes to lists, so I didn't change the line length initially (I also try to match the code style of any project I contribute to).
But shorter lines makes it much easier to work with text, I agree. So I added a commit at the beginning that does some formatting.

IMO the deeply nested lists don't become easier to read with this. So I opted for just keeping the long lines there for now. Let me know if you think it's worth changing those.

The alternative of course would be to move over to markdown completely. Which I'm not sure is a documented process?

@kallewoof
Copy link
Copy Markdown
Contributor

Thank you @guggero for picking this up.

If it helps the process and @kallewoof agrees, I'm volunteering to be named as a deputy for this BIP.

@kallewoof thoughts? (If helpful, see BIP3 here for details about the Deputy role.)

Sounds good to me!

guggero added 4 commits April 15, 2026 06:35
This re-formats the document for easier editing and diff viewing.
Wiki syntax is weird for lists and line wraps break them. Simple lists
were changed to <ul> or <ol> tags but complex lists remain as they are
to not bloat the diff too much.
This fixes small inconsistencies or incomplete definitions based on
previous, already merged changes.
This addresses two discussion items:
 - The list of UTXOs should not be interpreted as a "proof that no other
   UTXOs for an address exist".
 - The BIP only addresses "signer receives funds with the address" and
   not "signer sent a previous transaction" use case.
@guggero guggero force-pushed the bip-0322-finalization branch 2 times, most recently from f3ffd34 to 7809e72 Compare April 15, 2026 04:47
@guggero
Copy link
Copy Markdown
Contributor Author

guggero commented Apr 15, 2026

I updated the prefixes to be fixed-size (smp, ful, pof) and removed the colon to make copy/paste errors by users less likely.

@murchandamus I don't really understand the failing CI check... Am I supposed to change the background color of the row in the README?

@guggero
Copy link
Copy Markdown
Contributor Author

guggero commented Apr 15, 2026

I've implemented the proposed changes (prefix, Proof of Funds format) in the btcd PR and updated the test vectors here. With that, all (current) TODOs are addressed and I think this PR is ready for a closer look by anyone interested.

guggero added 7 commits April 15, 2026 14:54
Since the term "signature" can be pretty overloaded dependin on the
context, we clarify what it actually means in this BIP.
This commit proposes a fix for the problem that an offline verifier
previously was not able to even verify the witness stack of additional
inputs. By providing the full finalized PSBT, a verifier has all the
input data necessary to run the script through the validation engine.

We require the PSBT to be finalized to make sure it contains the final
script witness or final script sig but no extra potentially
privacy-sensitive fields. The Non-Witness and Witness UTXO fields are
explicitly allowed for finalized PSBTs, which makes the format perfect
for the use case.
This commit proposes a new PSBT input field type for transporting the
message to be signed to different signers in a multisig signing use
case.
This commit updates the test vectors to reflect all the changes in the
previous commits and also introduces new test vectors for the Proof of
Funds variant.
Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished my first pass. I think it’s great that you want to pick up this proposal and bring it up to speed. Strong concept ACK. You also seem to have buy-in from @kallewoof, which is great.
Given the age of the proposal and the breaking change, I would heartily recommend that you write to the mailing list about the changes you are proposing in this PR.

Comment thread bip-0322.mediawiki
Comment on lines +302 to +303
To support backward compatibility with implementations of this BIP before it was finalized, a
verifier might assume the ''simple' variant in the absence of a prefix.
Copy link
Copy Markdown
Member

@murchandamus murchandamus Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds like it warrants a Changelog entry. Could you please record the breaking change there?

You can find guidance about that in BIP3 here: https://github.com/bitcoin/bips/blob/master/bip-0003.md#changelog-section-and-version-header

Comment thread bip-0322.mediawiki
Comment on lines 7 to 8
Comments-Summary: No comments yet.
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0322
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at the comments wiki page. It just contains a couple questions and a link to this Bitcoin Talk discussion: https://bitcointalk.org/index.php?topic=5408898.l0.

I did not read the discussion, but if you find it interesting, you could add it as an entry to the "Discussion" header. You would then be free to drop the Comments headers as they are not required per BIP3 and the page doesn’t seem useful to me for this BIP.

Comment thread README.mediawiki
| Karl-Johan Alm
| Specification
| Draft
| Complete
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to update the background color in line 1075 (above) to

|- style="background-color: #cfffcf"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, that’s the cause of the CI failure.

Comment on lines +190 to +193
| Generic Signed Message
| <tt>PSBT_IN_GENERIC_SIGNED_MESSAGE = 0x21</tt>
| [[bip-0322.mediawiki|322]]
|-
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @achow101, no action required, just wanted to make you aware of this overlap with PSBTs, in case you had thoughts on PSBTs being used for Generic Message Signing.

Comment thread bip-0322.mediawiki
Comment on lines +482 to +487
== Changelog ==

* '''1.0.0''' (2026-04-15):
** Mark Complete
* '''0.0.1''' (2018-09-10):
** Proposed as draft
Copy link
Copy Markdown
Member

@murchandamus murchandamus Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIP322 has been out there for nigh a decade and I think there are some implementations of it in production. From what I understand this update includes a breaking change to the format. While it was in Draft status and changes should still be expected, this may come as a surprise due to the age of the proposal. Therefore, I would request that you clearly document the breaking change in the Changelog and write to the mailing list about this update to BIP322.

Copy link
Copy Markdown
Member

@murchandamus murchandamus Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you start versioning the document per a Changelog section, please also add the Version header to the preamble!

Copy link
Copy Markdown
Member

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh one more observation:

Comment thread bip-0322.mediawiki
Comment on lines +208 to +224
<ol>
<li>
They construct <code>to_spend</code> and <code>to_sign</code> as specified above, using the
scriptPubKey of ''A'' for <code>message_challenge</code> and tagged hash of ''m'' as
<code>message_hash</code>.
</li>
<li>
Optionally, they may set nLockTime of <code>to_sign</code> or nSequence of its first input.
</li>
<li>
Optionally, they may add any additional inputs to <code>to_sign</code> that they wish to prove
control of.
</li>
<li>
They satisfy <code>to_sign</code> as they would any other transaction.
</li>
</ol>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changing the formatting to shorter lines!

I am not sure what you mean about Mediawiki having issues with lists, I wasn’t aware, but if it helps, I wouldn’t have minded longer lines in lists. The HTML list syntax (…<ol><li>…) strikes me as more visual clutter in the source code compared to the Mediawiki syntax. It looks fine in the rendered document, though, so no need to change it again.

@murchandamus murchandamus added PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author and removed Proposed BIP modification PR by non-owner to update BIP content Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified labels Apr 15, 2026
@murchandamus murchandamus added the BIP Update by Owner PR by Author or Deputy to modify their own BIP label Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BIP Update by Owner PR by Author or Deputy to modify their own BIP PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants