Skip to content

BIP 377: Signing Message Encoding - #2353

Open
pythcoiner wants to merge 12 commits into
bitcoin:masterfrom
pythcoiner:bip_signing
Open

pythcoiner wants to merge 12 commits into
bitcoin:masterfrom
pythcoiner:bip_signing

Conversation

@pythcoiner

@pythcoiner pythcoiner commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This is a bip for signing message encoding, a byte encoding for the messages a coordinator and an external signer exchange: get info, get keys, descriptor registration, address verification and signing.

Mailing list post: https://groups.google.com/g/bitcoindev/c/gmHOr6JRJyU/m/kkWnI_NAAgAJ
Delving post: https://delvingbitcoin.org/t/qr-based-signing-flow-payloads-in-miniscript-context/2464

@jonatack jonatack left a comment

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.

Looks complete. Seems to fill a real gap, provided hardware-wallet vendors would be interested to adopt it.

@danielabrozzoni danielabrozzoni left a comment

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.

Reviewed 383f7c7 - I gave a first read and left a few ideas.

I think the BIP is well specified, but sometimes the reading order isn't very helpful to the reader, sometimes terms are used but then specified only later (one example: POR is used on L212 but specified on L506).

What do you think of adding an overview section, to give a high level explanation of the BIP, before jumping into the specification?

I asked claude to generate one, I think is a good start (but please double check that it's correct, and rewrite/remove any part you don't like): danielabrozzoni@729ac8a

Comment thread bip-signing.md Outdated
`EXTENDED_KEY`: 78 bytes, the BIP-32 serialization of an extended public or private
key (4 version + 1 depth + 4 parent fingerprint + 4 child number + 32 chain code +
33 key). A private key carries `0x00` followed by its 32-byte key in place of the
33-byte public key, and its own version bytes, so both have the same length.

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.

What do you mean by "and its own version bytes"? It's tripping me up a little bit. I thought you were saying "the private key has 0x00 + the 32 byte key, so it's the same length as the 33 bytes public key", what does the version have with it?

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.

it was about the bip32 version:

* 4 bytes: version bytes (mainnet: 0x0488B21E public, 0x0488ADE4 private; testnet: 0x043587CF public, 0x04358394 private)

but i dropped the capability to export private key, it's purpose was to allow using bip352 with a signer, but after talking with @notTanveer we both agree it does not feel right to allow exporting a private key only for that purpose, it's a big footgun from the external signer POV, I guess the right way to do is rather to use a SP private scan key generated from an public key exported from the external signer

Comment thread bip-signing.md Outdated
| 0x00 | Stable (final) |
| 0x01 | Alpha |
| 0x02 | Beta |
| 0x03 | Release candidate |

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.

Usually release candidates carry a number too - rc1 vs rc2 etc, this should be specified too

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.

added a byte to carry the rc number

Comment thread bip-signing.md Outdated

`VERSION`: in a response body, 8 bytes of device firmware version, `MAJOR` `MINOR`
`PATCH` `FLAG` (the message's protocol `VERSION` is defined under Encoding). `MAJOR`
and `MINOR` are 2-byte big-endian unsigned integers, `PATCH` is a 3-byte big-endian

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.

Why are you reserving 3 bytes for patch? I can understand 2 bytes for major/minor (1 byte is 0-255 and might not be enough), but 2 seem enough for patch too...

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.

my bad, I think my initial intent was to reserve a byte for the rc number, fixed

Comment thread bip-signing.md Outdated
Unregister Descriptor request without bit 6, or a `musig()` key without bit 7. A
`FORM` that needs a capability the signer does not advertise, such as `FORM` `0x01`
without bit 0 or `FORM` `0x03` without bit 5, is the exception: it gets `ERROR`
`0x06` (see Error response body).

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.

This should link to the "Error response" paragraph below

(Both here and in the other 3 places with the same sentence)

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.

done

Comment thread bip-signing.md Outdated
policy always converts to a BIP-380 descriptor, while a descriptor converts to a
wallet policy only when it fits BIP-388's restrictions.

A signer taking bit 0 or bit 1 handles the basic descriptors whatever its other

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.

"taking" and "whatever" read a bit weird here, I would say:

A signer that sets bit 0 or bit 1 handles the basic descriptors regardless of its other bits: ...

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.

done

Comment thread bip-signing.md Outdated

`MODEL`: `STRING`, the device model.

`VERSION`: in a response body, 8 bytes of device firmware version, `MAJOR` `MINOR`

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 think this should be called FW_VERSION, DEVICE_VERSION, or equivalent, so when reading the BIP we don't confuse it with the protocol version specified below

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, renamed to FW_VERSION

@jonatack jonatack changed the title BIP draft: Signing message encoding BIP 377: Signing Message Encoding Nov 19, 2026
@jonatack

jonatack commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Assigned 377. Please update (also have a look at the review feedback), rename the files, and add a README entry.

@pythcoiner

Copy link
Copy Markdown
Contributor Author

@danielabrozzoni thanks for the review, I think all your comments are addressed

@jonatack thanks for the bip #, I think everything is up to date now

@pythcoiner

Copy link
Copy Markdown
Contributor Author

rebased on master

pythcoiner added a commit to pythcoiner/bip377 that referenced this pull request Nov 20, 2026
ENCODING.md drifted from draft BIP-377 (bitcoin/bips#2353), which is now
the reference. The nonce cache is ahead of the BIP and can only land there
once its own BIP draft has a draft PR, so NONCE_CACHE.md documents the
pending changes against BIP-377 until then.
@craigraw

Copy link
Copy Markdown
Contributor

The Motivation opens with "No standard defines the messages a coordinator exchanges with an external signer." I don't think that holds, and the BIP has no prior art or related work section to support it.

Blockchain Commons has worked on this problem for years. The UR encoding (BCR-2020-005) and its type registry (BCR-2020-006) define crypto-psbt, crypto-hdkey, crypto-account and crypto-output. These are widely used today for exchanging keys, descriptors and PSBTs between airgapped coordinators and signers. Beyond the data types, BCR-2021-001 defined explicit request/response messages: derive a key at a keypath, sign a PSBT, return a descriptor against a challenge. It has since been superseded by envelope-based requests and responses (GSTP, BCR-2023-014). Within the BIPs, BIP 129 (BSMS) standardises the key and descriptor exchange for multisig setup, which overlaps directly with Register Descriptor. BIP 391 was a previous attempt at a binary descriptor encoding that positioned itself against the BCR formats.

I think this BIP covers real gaps that none of these address. Registering a descriptor on a signer that can't store it, verifying addresses, and handling wallet policies, MuSig2 and silent payments are all new, as is returning just the signatures rather than the whole PSBT. But the case for it should come from comparing it with what exists, not from saying nothing exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants