Skip to content

Miniscript optimization for slowly-decaying multisigs #2014

@darosior

Description

@darosior

Any multisig that decays by 1 key at every step can be represented as a single threshold instead of (nested) or() fragments. For instance or(and(pk(A),and(pk(B),pk(C))),and(thresh(2,pk(A),pk(B),pk(C)),older(42))) can be flattened into thresh(3,pk(A),pk(B),pk(C),older(42)). This generalizes to any number of spending paths, as long as they all have increasing timelocks, the very same set of public keys, and multisig thresholds that decrease by one on each step.

Currently Liana never benefits from this optimization for two reasons:

  • It never builds a policy such as the same keys are repeated in the different spending paths. This can be addressed with some complexity by removing (and caching) the derivation paths of all xpubs in the policy, such as Miniscript tooling is able to recognize pairs of (origin, xpub) as being the same key (the same owner). The policy with duplicate keys may then be normalized or compiled to perform the optimization, if at all possible.
  • Rust-miniscript is not able to perform this optimisation. The compiler does not support duplicate keys, and the normalization of abstract policies does not merge the nested thresholds in these conditions. It should be possible to implement the optimization in a somewhat general manner, but the conditions under which it is available are fairly specific to some (fairly specific) usages of Liana. I brought it up on the Miniscript IRC channel here.

I'm opening this issue for discussion. At present i believe the juice is not worth the squeeze. Note that in Taproot there is also a privacy tradeoff to this optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCNeeds conceptual discussion and/or feedback from users

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions