Conversation
src/descriptor/mod.rs
Outdated
|
|
||
| #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)] | ||
| pub struct DescriptorXPub { | ||
| source: Option<([u8; 4], DerivationPath)>, |
There was a problem hiding this comment.
All key types seem to allow a source description. Move this to a DescriptorKey struct.
There was a problem hiding this comment.
Might be preferable to use use bitcoin::util::bip32::Fingerprint instead of [u8; 4]
src/descriptor/mod.rs
Outdated
| source: Option<([u8; 4], DerivationPath)>, | ||
| xpub: bitcoin::util::bip32::ExtendedPubKey, | ||
| derivation_path: DerivationPath, | ||
| is_wildcard: bool, |
There was a problem hiding this comment.
Do you think it would make sense to also support a "hardened wildcard"? Something like /*'.
Currently the parser in magical-bitcoin-wallet supports it, even tough I don't really see many use-cases that could use it.
There was a problem hiding this comment.
In principle yes. I just didn't implement any private key types so far, so this didn't make any sense (no hardened derivations are currently supported).
I'm still not sure if we should even support anything priv-key related in rust-miniscript. The only use case would be recovering old funds automatically by searching a lot of possible (private) paths. But if you view miniscript more as a exchange format for policies/scripts private keys in it become somewhat hazardous. xpubs should be still seen as confidential, but to a way lesser degree than actual xprivs.
One use case I can imagine is to setup a new multisig wallet client for one of your cosigners you just copy the descriptor of your multisig wallet over. If it accidentally contains your xpriv instead of your xpub that would be really, really bad.
Maybe I'm just to paranoid. Maybe two different parses would help, one returns an error if the descriptor contains an xpriv.
There was a problem hiding this comment.
Well if you are trying to build a wallet with rust-miniscript and not just a "monitor" then yeah I think it's pretty useful to have private keys in a descriptor, just like Core does.
But yeah, I agree with you that it should be an "explicit" parser/type to avoid the issues you described.
One thing that I have in Magical which I could probably upstream if this PR is merged is a way to transform a descriptor into its "public" version. It's very useful if you have a descriptor with some private keys inside and you just want to make a watch-only out of it, so instead of manually converting the keys you can just use that method.
There was a problem hiding this comment.
I think core compatibility as a good reason to do it. But I'd still argue that it's better to have private keys separate from the descriptor. They are used in two completely different steps of tx creation and more often than not there might not even be a private key on the device the wallet is running on.
That's how I imagine wallet/miniscript/PSBT interaction:
Imo it's not a big advantage to have a config only consisting of a descriptor with private keys instead of a descriptor and a separate set of private keys.
There was a problem hiding this comment.
I thought about adding private key support again and I have to be damn careful when implementing Ord (required by the MiniscriptKey trait) as it could easily lead to side channels that leak the key. So I'll probably implement inefficiently by first computing the public key (should be constant time in libsecp) and then using it for comparisons.
@apoelstra / @sanket1729 do you have any opinions on implementing MiniscriptKey for private key types?
There was a problem hiding this comment.
cc @sipa
@sgeisler the way that Core works when parsing a descriptor with private keys is that it outputs a descriptor containing public keys, along with a map from pubkeys to privkeys. I think we should do something analogous, and have our map use the Satisfier trait to allow users to produce signatures etc with it.
There was a problem hiding this comment.
...so I think we (a) should not impl Ord on any private key types; (b) not directly support private keys in descriptors. Instead we should write a function that parses a privkey-containing descriptor, converts all the privkeys to pubkeys, and outputs a mapping. I can offer guidance on how to do this.
48a3512 to
50d0183
Compare
|
Hi @sgeisler, what's the status of this PR ? I'd happily help you polish it if this is not a priority for you right now :-) |
50d0183 to
d9fa945
Compare

Keys in script descriptors can come in a wide variety of formats:
all with or without origin information.
The xpub/xpriv variety can also allow further derivations by ending its derivation path with
*. This PR allows all of theses keys to be represented andDescriptorsto be derived. Deriving a descriptor leaves all keys as they are except wildcard keys. They are derived using a supplied path resulting in aDescriptorwithout wildcard keys/with the respective derived keys.For example to derive the first 5 addresses of a 2-of-3 multisig wallet with one static key (for some reason) and two derived keys the resulting code would look like this:
This would generate
As in the title, this is still heavily WIP, I mainly want to get concept feedback.