Skip to content

Conversation

@OttoAllmendinger
Copy link
Contributor

This PR adds complete signing support to the WASM-UTXO library with
three key components:

  1. MuSig2 Nonce Generation

    • Add FirstRound HashMap storage to WASM BitGoPsbt struct
    • Add generate_musig2_nonces WASM method with security checks
    • Add generateMusig2Nonces() TypeScript method
    • Security: Custom session IDs only allowed on testnets
  2. MuSig2 Nonce Combination

    • Implement combineMusig2Nonces method for nonce exchange
    • Enable proper nonce exchange between cosigners
    • Validate network compatibility and input count matching
  3. Single Input Signing

    • Implement sign methods for individual inputs by index
    • Support wallet inputs (BIP32) via sign_with_xpriv
    • Support raw private keys (ECPair) via sign_with_privkey
    • Handle MuSig2 inputs with existing first round state
    • Support replay protection inputs with proper P2SH sighashing

The implementation includes comprehensive tests, documentation, and examples
showing the complete MuSig2 signing workflow.

Issue: BTC-2786

OttoAllmendinger and others added 3 commits November 26, 2025 21:42
- Add FirstRound HashMap storage to WASM BitGoPsbt struct
- Add generate_musig2_nonces WASM method with security checks
- Add generateMusig2Nonces() TypeScript method
- Add to_xpriv() method to WasmBIP32 for internal use
- Create walletKeys.util.ts test helper
- Create musig2Nonces.ts test file with comprehensive test cases
- Security: Custom session IDs only allowed on testnets

Issue: BTC-2786
Add sign methods to BitGoPsbt to support signing individual inputs by index:

- Implement `sign` in JS that dispatches based on key type
- Add Rust `sign_with_xpriv` method for wallet inputs (BIP32)
- Add Rust `sign_with_privkey` method for raw private keys (ECPair)
- Handle MuSig2 inputs with existing first round state
- Support replay protection inputs with proper P2SH sighashing
- Add comprehensive tests and documentation

Issue: BTC-2786

Co-authored-by: llm-git <llm-git@ttll.de>
Implements new combineMusig2Nonces method to merge MuSig2 nonces from
different PSBTs. This enables proper nonce exchange between cosigners
during the MuSig2 signing workflow. The method copies nonces and
partial signatures between PSBTs, validates network compatibility,
and handles input count matching.

Includes comprehensive tests and updated documentation with examples
showing the complete MuSig2 signing workflow.

Issue: BTC-2786

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger force-pushed the BTC-2786.cosigning-with-strong-key-types branch from 64e10e1 to 322a745 Compare November 27, 2025 08:10
Add clippy::boxed_local allow annotations for methods that use Box<[T]>
parameters, which are required by wasm-bindgen for passing JavaScript arrays.

Issue: BTC-2786

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review November 27, 2025 08:47
@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner November 27, 2025 08:47
@OttoAllmendinger OttoAllmendinger merged commit 9556545 into master Nov 27, 2025
1 check passed
@OttoAllmendinger OttoAllmendinger deleted the BTC-2786.cosigning-with-strong-key-types branch November 27, 2025 21:07
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.

3 participants