Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIP 87: Hierarchy for Deterministic Multisig Wallets #1089

Merged
merged 30 commits into from
May 17, 2021

Conversation

Rspigler
Copy link
Contributor

Updates derivation paths for descriptors, by removing the redundant script_type currently in use.

@luke-jr @harding @hugohn

@Sjors
Copy link
Member

Sjors commented Apr 12, 2021

This seems like a nice simplification. The key distinction here is that users are expected to store the wallet descriptors along with the seed.

I don't know if this is flexible enough for wallets that need additional derivations, e.g. for nonces in schemes like https://medium.com/blockstream/musig-dn-schnorr-multisignatures-with-verifiably-deterministic-nonces-27424b5df9d6

It might be fine to just create another BIP when that becomes a problem, but then perhaps this BIP should get a more narrow scope.

@Rspigler
Copy link
Contributor Author

This seems like a nice simplification

Thanks!

The key distinction here is that users are expected to store the wallet descriptors along with the seed.

Yes, in a multisig setup, every user has to store every other cosigner's xpub anyway, so they might as well do so via the descriptor (since it provides this information in a standardized format, with the benefit of key origin information and error detection)

I don't know if this is flexible enough for wallets that need additional derivations, e.g. for nonces in schemes

I understand the concept of MuSig-DN, but not its implementation details unfortunately. I didn't realize that the nonces would be a level in the BIP32 path?

@Sjors
Copy link
Member

Sjors commented Apr 12, 2021

Yes, in a multisig setup, every user has to store every other cosigner's xpub anyway

Ideally yes, but the current "BIP48" approach has the benefit of being able to recover using only the mnemonics and the threshold. This BIP would drop that ability. That's OK, but it's useful to point out the trade-off.

I didn't realize that the nonces would be a level in the BIP32 path?

I don't know if that's the case. Perhaps they can be derived from the private key. I haven't read the blog in enough detail.

@Rspigler
Copy link
Contributor Author

Not ideally - necessary. You need the threshold # of mnemonics and all xpubs to recover funds.

@prusnak
Copy link
Contributor

prusnak commented Apr 12, 2021

How is the descriptor wsh(sortedmulti(2,[xfpForA/XY'/0'/0']XpubA/*,[xfpForB/XY'/0'/0']XpubB/*))#Checksum going to find all external and all change addresses of the wallet? (m/XY'/0'/0'/0/* and m/XY'/0'/0'/1/*)

@Rspigler
Copy link
Contributor Author

That's hardware/software specific, and doesn't affect this BIP. Again, this is an ongoing debate/conversation

Most hardware wallets and coordinators use a single parent descriptor, and expand it locally for change and receive addresses.
In BSMS, the parent descriptor is used, and a list of accepted derivation paths that the Signers can use to generate addresses are included.
If someone else wants to use a descriptor each for change and receive addresses, that works too (although I think there are serious usability issues).

Regardless, it doesn't affect this BIP/how co-signers generate keys.

@Sjors
Copy link
Member

Sjors commented Apr 13, 2021

Not ideally - necessary. You need the threshold # of mnemonics and all xpubs to recover funds.

You can derive xpubs from the mnemonics if you use the BIP48 convention and stick to account 0. The threshold is trivial to remember or can be found with trial and error. You do need all of them, which is of course another disadvantage of that mechanism compared to just backing up descriptors.

@Rspigler
Copy link
Contributor Author

You can derive xpubs from the mnemonics

Of course, but then you've lost the entire purpose of multisig if you rely on this. If you set up an M-of-N wallet, and you store only the mnemonics, the moment you have only N-1 mnemonic, you've lost your funds. You need M mnemonics and N public keys (you don't know which M mnemonics you will use to restore, so you can't rely on deriving the xpubs).

You might as well store this information as a standardized, single descriptor. Under BSMS every Signer (software or hardware) must be able to display this information to the user. Users should back this up just like they do the mnemonic.

There's no reason generating the xprv should have anything to do with the script type

@Rspigler
Copy link
Contributor Author

@Sjors @prusnak Addressed your concerns.

Way too many commits. So likely will squash at some point. I would recommend just viewing the file

@apoelstra
Copy link
Contributor

In Musig-DN (and in RFC6979) you can derive nonces just from the private key.

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

I thought I've seen dev ML discussion of this, but searching isn't coming up with it. Can you link me?


==Motivation==

With the increase of more user friendly (offline) multisignature wallets, and adoption of new technologies such as [https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md the descriptor language] and [https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki BIP-0174 (Partially Signed Bitcoin Transactions)], it is necessary to create a common derivation scheme that makes use of all new technologies.
Copy link
Member

Choose a reason for hiding this comment

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

Currently the descriptor language is wallet-specific - it should probably be made a BIP before relying on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a BIP could be very helpful, seeing how all wallets will likely (or should) be moving towards this direction. Are you saying a Descriptor-BIP is a blocker for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tagging @sipa , as I believe he is the author of the descriptor language


The structure proposed later in this paper solves these issues and is quite comprehensive. It allows for the handling of multiple accounts, external and internal chains per account, and millions of addresses per chain, in a multi-party, multisignature, hierarchical deterministic wallet regardless of the script type <ref>'''Why propose this structure only for multisignature wallets?''' Currently, single-sig wallets are able to restore funds using just the master private key data (in the format of BIP39 usually). Even if the user doesn't recall the derivation used, the wallet implementation can iterate through common schemes (BIP44/49/84). With this proposed hierarchy, the user would either have to now backup additional data (the descriptor), or the wallet would have to attempt all script types for every account level when restoring. Because of this, even though the descriptor language handles the signature type just like it does the script type, it is best to restrict this script-agnostic hierarchy to multisignature wallets only. Co-signers in multisignature wallets need to backup all other cosigner public keys anyway in order to restore, so the descriptor provides this information with the benefit of key origin information and error detection.</ref>.

Any script that is supported by descriptors (and the specific wallet implementation) is compatible with this BIP.
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to a Backward Compatibility section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

@Rspigler
Copy link
Contributor Author


==Address Discovery==

The multisig descriptors or descriptor template that is generated from the cosigners' combined key records should be used to generate and discover addresses.

Choose a reason for hiding this comment

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

Would be nice to explicitly require the descriptor template to include key origin information since it is useful for the PSBT creator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@luke-jr luke-jr changed the title BIP Proposal: Modern Hierarchy for Deterministic Multisignature Wallets BIP 87: Modern Hierarchy for Deterministic Multisignature Wallets May 14, 2021
@luke-jr
Copy link
Member

luke-jr commented May 14, 2021

Assigned BIP number 87, please rename file and update README

@luke-jr
Copy link
Member

luke-jr commented May 15, 2021

CI is failing:

bip-0087.mediawiki has too-long TItle (57 > 44 char max) at scripts/buildtable.pl line 128, <$F> line 4.

Suggest dropping "Modern", since that's relative to present time. (Note that will only get it down to 51 characters; an additional 7 still need to go)

@Rspigler Rspigler changed the title BIP 87: Modern Hierarchy for Deterministic Multisignature Wallets BIP 87: Hierarchy for Deterministic Multisig Wallets May 15, 2021
@Rspigler
Copy link
Contributor Author

@luke-jr sorry, not sure what the issue is now

@sipa
Copy link
Member

sipa commented May 15, 2021

@Sjors MuSig-DN needs a different kind of keys for nonce derivation (it doesn't even use the same secp256k1 for that). I think it's unlikely that those will be integrated into descriptors in common software - it's pretty complex unfortunately.

MuSig2 is a lot simpler, but it relies on (actual) randomness or state in the signers.

@luke-jr luke-jr merged commit 2371906 into bitcoin:master May 17, 2021
@luke-jr
Copy link
Member

luke-jr commented May 17, 2021

@Rspigler The colours were incorrect in your README. Fixed them for you.

@Rspigler
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants