* [bitcoindev] [BIP Proposal] Canonical Form for Output Script Descriptors
@ 2026-12-01 8:03 Craig Raw
0 siblings, 0 replies; only message in thread
From: Craig Raw @ 2026-12-01 8:03 UTC (permalink / raw)
To: Bitcoin Development Mailing List
[-- Attachment #1: Type: text/plain, Size: 4489 bytes --]
Hi all,
For any wallet that is not single-signature, the output script descriptor
is an essential part of the backup. Users are routinely asked to compare
one descriptor with another: to check that a restored wallet matches the
original, or that each participant in a multisig holds the same wallet.
Descriptors do not currently support this well. The same wallet has many
valid textual representations, differing in such things as the hardened
derivation marker, the case of hexadecimal and the order of the keys in a
sortedmulti(). Each representation has its own BIP380 checksum, so the
checksums of two backups of the same wallet may not match, and confirming
by eye that the strings describe the same wallet is difficult.
Implementations have responded to this individually, and they do not agree.
Some preserve the order in which the keys were supplied, while others sort
them, variously by the public keys derived at some index or by the text of
the key expressions, with or without key origin information. Each choice is
reasonable, but because none is specified, they do not interoperate.
This BIP proposal defines a canonical form for output descriptors: a
deterministic textual encoding such that descriptors that differ only in
how they are written produce the same string, and therefore the same
checksum. Canonicalization is a purely textual operation that derives no
keys. In summary:
- Hardened derivation is written with h, hexadecimal and Bech32 in
lowercase, and miniscript in its sugared form
- Compressed raw public keys in taproot positions are written as x-only
keys, except for the participants of musig()
- The keys of sortedmulti(), sortedmulti_a() and musig(), the two children
of each tr() script tree branch, and annotation pairs are sorted in ASCII
order of their canonical text
- Everything else, including the keys of multi(), retains its written order
Because key origin information is written first where present,
sortedmulti() keys that include it are ordered by master fingerprint, which
a person can check by eye. A descriptor has no canonical form if it
performs hardened derivation after an xpub (unless the final step is a
hardened wildcard), or if it contains expressions whose canonical form has
not been specified.
Example: these two descriptors (keys abbreviated)
wsh(sortedmulti(2,[b7868815/48'/0'/0'/2']xpub6FA5r.../<0;1>/*,[1cf0bf7e/48'/0'/0'/2']xpub6FL8F.../<0;1>/*,[4fc1dd4a/48'/0'/0'/2']xpub6EebM.../<0;1>/*))
wsh(sortedmulti(2,[4fc1dd4a/48h/0h/0h/2h]xpub6EebM.../<0;1>/*,[b7868815/48h/0h/0h/2h]xpub6FA5r.../<0;1>/*,[1cf0bf7e/48h/0h/0h/2h]xpub6FL8F.../<0;1>/*))
have the same canonical form:
wsh(sortedmulti(2,[1cf0bf7e/48h/0h/0h/2h]xpub6FL8F.../<0;1>/*,[4fc1dd4a/48h/0h/0h/2h]xpub6EebM.../<0;1>/*,[b7868815/48h/0h/0h/2h]xpub6FA5r.../<0;1>/*))#jecfc8v2
The same wallet can also be described by genuinely different descriptors,
for example by deriving the xpub to a different depth. Canonicalization
does not unify these, so the document separately recommends which
descriptor to export: in general, the xpub at the last hardened derivation
step, with receiving and change combined in one BIP389 multipath
descriptor. It also describes how future descriptor BIPs can specify their
own canonical form.
Note that the canonical form does not change how descriptors are parsed or
the scripts they produce, and implementations must continue to accept
descriptors in any valid form. Implementations that use descriptor text as
a key for stored state, such as BIP388 wallet policy registrations, are
advised to leave that state unchanged and apply the canonical form only on
export, display and comparison.
The canonical form is not intended as a wallet identifier, although one
could be defined on top of it. I see strong demand for interwallet
communication, which may require some form of wallet identifier, and this
BIP is a stepping stone to that goal.
The full text of the BIP, including test vectors, can be found at
https://github.com/craigraw/bips/blob/canonical-descriptor/bip-canonical-descriptor.md
Feedback is welcome.
--Craig
--
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/CAPR5oBOVkQAy5aOVM-dCtJvEcw_PSqV_De3z234Yph%2Bn7PFGWQ%40mail.gmail.com.
[-- Attachment #2: Type: text/html, Size: 5093 bytes --]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 8:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 8:03 [bitcoindev] [BIP Proposal] Canonical Form for Output Script Descriptors Craig Raw
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox