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

Improve swap-in protocol with taproot and musig2 #563

Merged
merged 29 commits into from
Feb 15, 2024

Commits on Feb 8, 2024

  1. Configuration menu
    Copy the full SHA
    24ed675 View commit details
    Browse the repository at this point in the history
  2. Add an example of swapin transaction that uses musig2 and taproot

    Add a simple test that uses how to modify the swap-in-potentiam protocol to use musig2 and taproot:
    - taproot key path is used for the mutual user key + server key use case, which sends to a single musig2 aggregated key
    - tapscript path is used for the refund case (user key + delay)
    
    Add another example with taproot but not musig2 that uses 2 differents scripts (mutual case and refund case)
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    7054f5f View commit details
    Browse the repository at this point in the history
  3. Add a RemoteSwapInV2 message

    This message includes all outputs from the remote tx and not just the one that is included in the swap.
    This is needed for Schnorr signatures.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    e6c9038 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d097480 View commit details
    Browse the repository at this point in the history
  5. Use different user keys for the common and refund paths

    This allows us to easily rotate swap-in addresses and generate a single generic taproot descriptor (for bitcoin core 26 and newer) that can be used to recover
    swap-in funds once the refund delay has passed, assuming that:
    - user and server keys are static
    - user refund keys follow BIP derivation
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    af9b0d7 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    54988f9 View commit details
    Browse the repository at this point in the history
  7. Add a musig2 secret nonce field to local/remote musing2 swap-in classes

    It makes the code cleaner and we get rid of the secret nonces map.
    These nonces are replaced with dummy values whenever this classes are serialized, which is safe since they're never reused for signing txs.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    bd2690b View commit details
    Browse the repository at this point in the history
  8. Rework TxComplete to use implicit ordering for musig2 nonces

    Instead of sending an explicit serialId -> nonce map, we send a list of public nonces ordered by serial id.
    This matches how signatures are sent in TxSignatures.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    28b69ba View commit details
    Browse the repository at this point in the history
  9. Revert to using a map to store musig2 secret nonces

    The semantics of the secret nonce field added to tx inputs were wrong, these nonces are transient and should be tied to the lifecycle
    of the interactive tx session, this is much more explicit now.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    626aeca View commit details
    Browse the repository at this point in the history
  10. Upgrade bitcoin-kmp

    It now provides different types for individual and aggregated musig2 nonces.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    2f295bb View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    6909368 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    89d3956 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    c485329 View commit details
    Browse the repository at this point in the history
  14. Update musig2 api

    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    339cd73 View commit details
    Browse the repository at this point in the history
  15. Address review comments

    - add a pubkey script to the SharedInput() class (we don't need the full TxOut which we can recreate)
    - remove aggregate nonce check ins FullySignedTx: code already handles transactions that are not properly signed
    - generate musig2 nonces when we send TxAddInput
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    0c0c7dc View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    7f7f9af View commit details
    Browse the repository at this point in the history
  17. Do not send the previous tx for swap-in inputs

    They use taproot v1, providing the tx output and not the entire tx is safe (see #579).
    Here we add the swap-in input output and txout to the swap-in TLV, so this change does not interface with proposed changes to the LN spec.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    5bab5d5 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    7bfd022 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    1ec236d View commit details
    Browse the repository at this point in the history
  20. Revert "Do not send the previous tx for swap-in inputs"

    This reverts commit c0a6d5a.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    4b04f5f View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    9871f48 View commit details
    Browse the repository at this point in the history
  22. Use musig2 helpers to simplify swap-in protocol (#592)

    We use the musig2 helpers exposed by ACINQ/bitcoin-kmp#114
    to simplify the swap-in protocol and hide all of the musig2 internal
    details (key aggregation cache, control block, internal taproot key,
    opaque session object, nonce aggregation).
    
    The code is simpler to reason about and signing is more similar to
    signing normal single-sig inputs.
    t-bast authored and sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    2b4ad8d View commit details
    Browse the repository at this point in the history
  23. Restore ignored tests

    They were disabled when we experimented with not sending the full tx.
    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    7578574 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    f7c8b07 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    c215ad4 View commit details
    Browse the repository at this point in the history
  26. Fix failing splice tests

    sstone committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    f963c21 View commit details
    Browse the repository at this point in the history

Commits on Feb 13, 2024

  1. Rework recovery procedure

    The current recovery process needed to be updated to derive the correct master priv key from the seed by specifying our
    custom BIP32 path (m/52h/0h/2h/0) when we create the wallet.
    
    We also export 2 descriptor methods: one to get the private swap-in wallet descriptor, which can be used as-is, and the other to get the
    public swap-in wallet descriptor, which can be used to create a watch-only wallet to monitor swap-in funds and to recovery funds using our recovery procedure.
    
    Both descriptor use the refund master key, and not the master key itself because we use hardened paths to derive the refund key, which means that it is not
    possible to compute the refund master public key from the master public: importing the descriptor would fail.
    sstone committed Feb 13, 2024
    Configuration menu
    Copy the full SHA
    7d17663 View commit details
    Browse the repository at this point in the history

Commits on Feb 14, 2024

  1. Configuration menu
    Copy the full SHA
    bf2f7b0 View commit details
    Browse the repository at this point in the history
  2. Set version to 1.6-SNAPSHOT

    Co-authored-by: Bastien Teinturier <[email protected]>
    sstone and t-bast authored Feb 14, 2024
    Configuration menu
    Copy the full SHA
    335e4c2 View commit details
    Browse the repository at this point in the history