Skip to content

MuSig2#794

Draft
Sjors wants to merge 20 commits into
bitcoin-core:masterfrom
Sjors:musig2
Draft

MuSig2#794
Sjors wants to merge 20 commits into
bitcoin-core:masterfrom
Sjors:musig2

Conversation

@Sjors

@Sjors Sjors commented Jul 21, 2025

Copy link
Copy Markdown
Member

This is based on:

(I marked these as draft, because I need to rebase them and make some adjustments to match the approach here - after that I'll redo this branch as a series of merges followed by individual commits)

To be used with, and developed in parallel to:

The general workflow is:

  • create a Bitcoin Core wallet with an external signer and a tr(musig(...)) descriptor
  • register the policy: bitcoin-cli registerpolicy "MuSigTest" (Core calls hwi register and stores the hmac)
  • verify a receive address on the device with bitcoin-cli walletdisplayaddress (Core calls hwi displayaddress --policy-name ...)
  • send coins to it
  • spend with a single call: bitcoin rpc send '[{"bc1p...": 0.000001}]' fee_rate=1
    • Core runs both MuSig2 rounds in-process: round 1 exchanges pub nonces (hot cosigners + hwi signtx --policy-name ... per device), round 2 collects partial signatures, then Core aggregates and broadcasts
    • if the device is unplugged mid-flow, the PSBT with the partial contributions is returned; a later walletprocesspsbt resumes the dance
  • hwi signtx/walletprocesspsbt round-tripping by hand still works if you prefer to drive the rounds yourself

To work around a Ledger quirk, we stash other participants' pubnonce and partial sig before sending it to the device and merge them back afterwards.

Works with the Ledger Bitcoin app 2.4.1, i.e. this does not depend on #819.

CI runs an end-to-end scenario (register → display → fund → 2-round spend → confirm) against a bitcoind built from the Core branch above, plus device tests for register/displayaddress against speculos.

Potential follow-ups:

  • ColdCard support (needs a firmware bump)
  • multi-device scenario (e.g. 3-of-3 across several simulators)

@Sjors

Sjors commented Jul 31, 2025

Copy link
Copy Markdown
Member Author

Cherry-picked the latest version of all the independent PRs. Other than displaying an address this should be all you need to use MuSig2.

@Sjors

Sjors commented Sep 5, 2025

Copy link
Copy Markdown
Member Author

Somehow I thought I already implemented sending, but it seems I didn't. Done now. Tested with key path as well as script path.

Sjors and others added 4 commits July 3, 2026 21:30
The rolling nightly toolchain has drifted past what trezor-firmware
core/v2.9.6 supports: recent nightlies reject its
reexport_test_harness_main attribute with error E0658. Pin the nightly
to 2025-04-15, matching the firmware's own shell.nix.

Co-authored-by: Claude (Fable 5) <noreply@anthropic.com>
cache_unsigned_tx_pieces() decided whether to call setup_from_tx()
by checking if self.tx is None. But it never is: __init__ sets it to
an empty CTransaction. So for PSBTv2, which has no global transaction,
setup_from_tx() replaced the deserialized tx version and fallback
locktime with the empty transaction's defaults (version 1, locktime 0).

This silently modified any PSBTv2 transaction with a different version
or locktime, such as those made by Bitcoin Core (version 2 and an
anti-fee-sniping locktime), invalidating signatures created before the
round-trip through HWI.

Check the PSBT version instead, as the docstring already describes.

Co-authored-by: Claude (Fable 5) <noreply@anthropic.com>
Also drops Python 3.6 dataclasses leftover.
@Sjors

Sjors commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Did a complete overhaul to match Sjors/async-hwi#2 (though just Ledger, we'll leave ColdCard for a followup). Much vibed, but manually tested. I'll extract smaller patches as separate PR's later.

This PR is orthogonal to #819, however I would prefer to use the newer Ledger app version from it, since it contains various MuSig2 related fixes.

bigspider and others added 8 commits July 9, 2026 13:39
The Ledger bitcoin app repos have moved:
- new: from LedgerHQ/app-bitcoin-new to LedgerHQ/app-bitcoin
- legacy: from LedgerHQ/app-bitcoin to LedgerHQ/app-bitcoin-legacy
Taken from LedgerHQ/app-bitcoin-new at 2.4.1

Conflicts:
	hwilib/devices/ledger.py

Rename tx to psbt.
This adds support handling public nonces and partial signatures.
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

Successfully merging this pull request may close these issues.

2 participants