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

Think about how MiniscriptKey interacts with Musig keys #427

Open
sanket1729 opened this issue Jun 7, 2022 · 2 comments
Open

Think about how MiniscriptKey interacts with Musig keys #427

sanket1729 opened this issue Jun 7, 2022 · 2 comments

Comments

@sanket1729
Copy link
Member

Integrating musig2 keys with the existing API introduces a couple of new challenges:

  1. We currently support Terminal::Pk(Pk) in our miniscript decoding. This means we should parse musig(A,B,C) as a single Pk.
  2. At the same time, we want the translation API to allow to translation of native A, B and C.

Seems like we might to re-design some parts of the codebase to support it. cc @apoelstra

@sanket1729
Copy link
Member Author

It seems like the best solution would be to support parsing as a new struct KeyExpr.

struct KeyExpr<Pk: MiniscriptKey> {
      SingleKey(Pk),
      Musig(Vec<KeyExpr<Pk>>),
}
  1. Then we change Terminal::Pk(Pk) => Terminal::Pk(KeyExpr).
  2. For Pkh, as discussed elsewhere first, we need to change from Pkh(Pk::Hash) to Pkh(Option, Pk::Hash). That will changed to Pkh(Option<KeyExpr<Pk>>, Pk::Hash)
  3. Multi will change to use KeyExpr as above

@apoelstra
Copy link
Member

This sounds like the right direction to me. The keyhash stuff is a bit ugly but I think that's inherent to the problem domain.

SarcasticNastik added a commit to SarcasticNastik/rust-miniscript that referenced this issue Jun 9, 2022
As suggested in rust-bitcoin#427, this refactor helps to incorporate musig in the codebase.
SarcasticNastik added a commit to SarcasticNastik/rust-miniscript that referenced this issue Jun 9, 2022
As suggested in rust-bitcoin#427, this refactor helps to incorporate musig in the codebase.
sanket1729 added a commit that referenced this issue Jun 17, 2022
8d0cf06 Remove `ForEach` Trait (Aman Rojjha)
5cb2bcf Refactor PkH to include key. (Aman Rojjha)
09299b0 Refactor ForEach to contain only Pk. (Aman Rojjha)
701c9cc Remove un-necessary lifetimes (Aman Rojjha)
ca16bd8 Fix formatter configuration errors with latest nightly (sanket1729)

Pull request description:

  As suggested in #427, this refactor helps to incorporate musig in the codebase.

ACKs for top commit:
  apoelstra:
    ACK 8d0cf06
  sanket1729:
    ACK 8d0cf06. The last commit message should be `Remove ForEach struct` instead of `Remove ForEach trait`. But won't holdoff this over that.

Tree-SHA512: 645974d9055e0458f64e214d95a73647420d46f05246be6809ae11dbfd8dacc05500c5e9f9f1b10b532b539b2d30883c014177a33e7666aea8ae383722910ff9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants