#36073 fuzz: Add musig harness

full analysis

https://github.com/bitcoin/bitcoin/pull/36073 · nervana21 · +211/-0 in 2 files, 1 commits · labels: Fuzzing

Goal

  • Add fuzz testing for MuSig2 cryptographic APIs to exercise error handling and corner cases
  • Protects against regressions in routines that currently lack dedicated unit tests

This pull request adds a new fuzz target (`musig`) to test the `src/musig` module. It exercises key aggregation, synthetic xpub creation, session ID generation, nonce creation, and partial as well as aggregate MuSig2 signing routines.

Problem: The MuSig2 module APIs currently lack dedicated unit tests and fuzz harnesses, leaving error handling and corner cases underexercised outside of a python functional test.

Category: Test infrastructure (#24 of 45)

P3 · test coverage

  • P3 because it adds fuzz coverage for MuSig2 routines that currently lack unit tests
  • MuSig2 is not yet on critical consensus or peer-to-peer hot paths

P3 because it provides new fuzz coverage for MuSig2 cryptographic routines that currently lack unit tests. As jeanpablojp noted, 'the four signing functions in the module have no unit test today... so the harness covers ground that was empty'. While valuable for hardening cryptographic operations, MuSig2 is not yet on critical consensus or p2p hot paths.

Membership: Adds a new fuzz target harness under src/test/fuzz/ and updates the fuzz CMakeLists.txt.

Factors: security/stability 1, bug 0, performance 0, user value 0, leverage 1

Reviewability: Ready

  • Ready for review
  • Clean CI and author addressed initial review feedback

The code has clean CI, no merge conflicts, and the author addressed all feedback from the initial review round.

Author status: active; addressed all reviewer feedback and force-pushed updates

Resolved concerns:

  • jeanpablojp noted that passing ungenerated secnonces caused libsecp256k1 assertion aborts and recommended deferring that arm to #35422; the author removed it.
  • jeanpablojp suggested generating valid nonces and keys for multi-participant sessions so signature aggregation paths are actually reachable; the author adopted the approach.

Agreement: Strong

  • Strong concept support because it covers MuSig2 signing routines that have no unit tests (jeanpablojp)
  • Technical suggestions to improve reachability were adopted by the author

Strong concept support from jeanpablojp noting missing unit test coverage; technical feedback has been addressed.

jeanpablojp gave a Concept ACK with detailed rationale on coverage gaps, helped improve fuzz target reachability, and no objections were raised.

  • jeanpablojp: 'Concept ACK. The four signing functions in the module have no unit test today, only the wallet_musig.py functional test, so the harness covers ground that was empty.'
  • nervana21 implemented all suggested changes and dropped the aborting arm.

Review verdicts (DrahtBot): 0

Files

211 lines under test/bench/ci.

  • src/test/fuzz/musig.cpp +210/-0
  • src/test/fuzz/CMakeLists.txt +1/-0

Card

Adds a dedicated fuzz target for MuSig2 module APIs covering key aggregation, nonce generation, and partial and aggregate signing paths. The module currently lacks unit tests, so the fuzz target fills an untested gap in cryptographic utility code. Reviewer feedback regarding libsecp assertions and path reachability has been fully addressed, and the PR is ready for review.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T15:57, confidence high, input hash 5840328a7c6f47c6