buidl-bitcoin/buidl-python

Add a MuSig2 function to multiwallet.

Opened this issue · 5 comments

Now that MuSig2 is merged, add something to multiwallet to play with it on signet.

Very much interested in MuSig2 support. Be happy to help make this happen if I could get some direction

Awesome! Take a look at taproot.py, particularly the MuSigTapScript class and the tests associated with it (test/test_musig.py). That should give you a good idea of how MuSig is called with multiple parties.

If you have any questions, please ask here. I'll try to be helpful by adding documentation.

Okay great, I think I understand the MuSig aspect. A bit unsure about the integration with multiwallet and the format for passing the required data around. Will this use a coordinator, or will all parties have to pass data to each other?

I believe the steps are:

  • Round 1
  1. Generate a p2tr private and public key pair
  2. Run nonce_gen to get nonce_secrets and nonce_points
  3. Share public key and nonce_points
  4. Aggregate public keys using a MuSigTapScript to get MuSig p2tr address (fund the address)
  • Round 2
  1. Construct a Tx that spends from MuSig p2tr address
  2. Calculate sum of shared nonce_points
  3. Sign sig_hash of Tx using own nonce_secrets, priv_key and nonce_sums
  4. Share signature
  5. Aggregate signatures
  6. Use signature to finalize spend of MuSig p2tr input.
  7. Broadcast tx

Should this be using PSBTs somehow to store and share the partial signatures between participants?

This is a pretty big project, but there's a BIP for PSBT for MuSig2:

https://github.com/achow101/bips/blob/musig2-psbt/bip-musig2-psbt.mediawiki

It makes integration much wider scope, but any other transport to other users is bound to be deprecated.

I see, interesting. Will take a look