public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* [bitcoin-dev] New BIP to align descriptors, xpub derivation and miniscript
@ 2023-09-10 17:13 Dr Maxim Orlovsky
  2023-09-11 12:03 ` Antoine Poinsot
  0 siblings, 1 reply; 2+ messages in thread
From: Dr Maxim Orlovsky @ 2023-09-10 17:13 UTC (permalink / raw)
  To: Bitcoin Protocol Discussion

Hi,

Script output descriptors ("output descriptors", "wallet descriptors", or 
simply "descriptors") are getting more and more traction. Descriptors work 
in combination with miniscript, extended BIP32 keys (xpub/xprivs 
"descriptors" equipped with origin and derivation information) and are used
to construct new primitives like "wallet templates" used in Ledger and 
BitBox today.

Nevertheless, due to historical reasons, the resulting combination of the 
mentioned technologies is frequently redundant and leaves a lot of 
unspecified caveats, when it is unclear how descriptor with 
internally-conflicting data has to be handled by wallets and/or devices. 
For instance,
- derivation path standards (following BIP44) commit to the type of the 
  script pubkey (P2PKH, P2SH, P2WSH, P2WPKH, P2TR), but the same information
  is present in the descriptor itself;
- each of the public keys within the descriptor replicates the derivation 
  information and information about Bitcoin network (testnet or mainnet);
- if the same signer participates in different miniscript branches, due 
  to miniscript anti-malleability rules a new derivation path has to be used
  in pre-Taproot context (but not in Taproot) -= and multiple contradictory
  approaches exist on how to handle that;
- client-side-validation approach, used by several projects, introduces new
  descriptor-level concepts, like taproot-ebmedded OP_RETURN commitments 
  (so-called "tapret"), which are not handled by existing standards.

As a result, descriptors contain a lot of redundant information, which makes
them bulk, hard to read or type, and impossible to handle in the narrow UI
of hardware wallets.

At LNP/BP Standards Association we'd like to work/coordinate efforts on 
a new BIP proposal removing all the issues above. Before working on the 
BIP proposal text I would like to start by discussing an approach, seeking
Concept (n)ACKs and Approach (n)ACKs from this mail list.


The approach
------------

Existing separate BIP44 standards, committing to a specific form of script
pubkey are made redundant with the introduction of output descriptors. Thus,
I think we need a new BIP44 purpose field which will be used with all 
descriptor formats. The standard must _lexicographically require_ all keys 
to follow the same standard and use the same network and terminal derivation
format. By "lexicographically require" I mean that there must be no 
syntactic option to do otherwise, i.e. the information must not repeat 
within the descriptor for each of the keys and has to be placed in the 
descriptor itself, using prefix (for the network) and suffix (for the 
terminal derivation format):

```
wsh/test(or(
    and(1@[fe569a81//1']xpub1..., 2@[8871bad9//1h]xpub2..., 3@[beafcafe//1']xpub3...), 
    and(older(1000), thresh(2, @1, @2, @3))
))/<0;1>/*
```

Please note that each of the keys appears in the descriptor only once, and
is aliased using the `i@` construction preceding the key origin. These
aliases must be incremental starting from `1` (otherwise the descriptor is
invalid). Each other time the same account xpub is used in some other
condition only the alias should be used.

For the mainnet the prefix must be omitted: `wsh(or...)/<0;1>/*`

The descriptor is used to construct derivation for each of the keys 
in the same way:

`m/89'/network'/account'/branch/<0;1>/*`

where:
- 89' is the purpose - an assumed number for the newly proposed BIP;
- `network'` is either `0'` or `1'` and is taken from the descriptor prefix;
- `account` is taken from the xpub origin in the descriptor (it follows the
  master fingerprint and `//` character) and the last `/<0;1>/*` must match
  the descriptor suffix.
- `branch` part, which is a new segment compared to BIP44. This branch index
  must be always unhardened and is computed from the descriptor, starting 
  with 0 for each key and incrementing each time the same key alias is found
  in the descriptor;
- `<0;1>` may contain only 0, 1 index, unless a dedicated BIP extending 
  the meaning of this segment is filed. One such case may be the use of 
  a change index for storing an associated state in client-side-validation,
  like in RGB protocol, where indexes 9 and 10 are used to represent the
  assignation of an external state or the presence of a tapret commitment.
  It is important to require the standardization of new change indexes since
  without that wallets unaware of clinet-side-validation may spend the UTXO
  and burn the external state.


Reference implementation
------------------------

Once the approach is acknowledged by the mailing list the reference 
implementation will be written on Rust and deployed with MyCitadel wallet 
(https://mycitadel.io), which is the only wallet supporting since spring
2022 combination of all three: descriptors, miniscript and taproot (there 
are more descriptor/miniscript wallets which have appeared over the last 
year, but they are still lacking taproot support AFAIK).


Kind regards,
Maxim Orlovsky
LNP/BP Standards Association
https://www.lnp-bp.org/

GitHub: @dr-orlovsky
Nostr: npub13mhg7ksq9efna8ullmc5cufa53yuy06k73q4u7v425s8tgpdr5msk5mnym



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-11 12:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-10 17:13 [bitcoin-dev] New BIP to align descriptors, xpub derivation and miniscript Dr Maxim Orlovsky
2023-09-11 12:03 ` Antoine Poinsot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox