musig_sessions: store up to 32 sessions
What changed, and why it matters
This commit is a simple capacity increase, not a security fix. It raises the number of simultaneous MuSig2 signing sessions the Ledger Bitcoin app can keep in memory from 8 to 32, because users with multiple MuSig accounts or wallets that pre-generate nonces could hit the old limit. The documentation and a test constant are updated to match, and the full-storage eviction test is made optional because filling 32 sessions is slow.
No security action needed; treat as a normal feature/usability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change modifies a single #define in src/musig/musig_sessions.h: MAX_N_MUSIG_SESSIONS goes from 8 to 32. CHANGELOG.md and doc/musig.md are updated to reflect the new limit. tests/test_sign_psbt_musig.py updates the test constant and skips the eviction test unless –enable_slow_tests is enabled, since filling 32 sessions is slow. There is no change to session structure, eviction logic, cryptographic handling, or memory allocation strategy.
Changed components
src/musig/musig_sessions.hdoc/musig.mdCHANGELOG.mdtests/test_sign_psbt_musig.pyInspect captured patch +12 / −5
### CHANGELOG.md
@@ -17,6 +17,7 @@ Dates are in `dd-mm-yyyy` format.
- MuSig2: the pubnonces no longer depend on the transaction, so they can be pre-generated before the transaction is known. See [doc/musig.md](doc/musig.md).
- MuSig2 (breaking): as a consequence, at most one signing session can be pending for a given wallet policy; executing round 1 again for the same wallet policy discards the previous session, and round 2 with the old pubnonces fails. In order to allow software wallets to manage multiple simultaneous sessions for the same wallet policy, this version adds support for a `MUSIG2_SESSION_ID` proprietary PSBT field. See [doc/musig.md](doc/musig.md) for more info.
+- MuSig2: up to 32 signing sessions can be pending (previously 8); when the storage is full, the oldest one is evicted.
### Fixed
### doc/musig.md
@@ -10,7 +10,7 @@ MuSig2 is a 2-round multi-signature scheme compatible with the public keys and s
- At most 5 keys are allowed in the musig expression; performance limitations, however, might apply in practice.
- `musig(...)` is allowed among the key expressions of `multi_a`, but not of `sortedmulti_a`.
-- At most 8 MuSig2 signing sessions can be pending at the same time, due to the need to persist state in the device's memory; when the storage is full, starting a new session evicts the oldest one.
+- At most 32 MuSig2 signing sessions can be pending at the same time, due to the need to persist state in the device's memory; when the storage is full, starting a new session evicts the oldest one.
- By default, at most one session can be pending for each wallet policy. Software wallets that need multiple transactions in flight for the same wallet policy can identify each session with the [`MUSIG2_SESSION_ID`](#the-musig2_session_id-psbt-field) PSBT field (see [below](#generalization-to-multiple-psbt-signing-sessions)).
- The pubnonces can be generated before the transaction is known, and then used for a different transaction than the one given to the device in round 1 (see [below](#pre-generating-the-pubnonces)).
- Only `musig(...)/**` or `musig(...)/<M;N>/*` key expressions are supported; the public keys must be xpubs aggregated without any further derivation. Schemes where each pubkey is derived prior to aggregation (for example descriptors similar to `musig(xpub1/<0;1>/*,xpub2/<0;1>/*,...)`) are not supported.
@@ -102,7 +102,7 @@ where $H_{tag}$ is the BIP-0340 tagged hash, the first two arguments are the has
The `psbt_session_id` deliberately depends only on the wallet policy and on the `MUSIG2_SESSION_ID`, and not on the transaction; together with the transaction-independent arguments of _NonceGen_, this is what allows [pre-generating the pubnonces](#pre-generating-the-pubnonces). The tradeoff is that, without a `MUSIG2_SESSION_ID`, at most one session can be pending for each wallet policy.
-The device can store up to 8 sessions.
+The device can store up to 32 sessions.
Collisions of the `psbt_session_id` do not constitute a security risk: they only cause the previous session to be deleted, and the following Phase 2 to fail.
### src/musig/musig_sessions.h
@@ -12,7 +12,7 @@
// the maximum number of musig sessions that are stored in permanent memory; when the storage is
// full, storing a new session evicts the oldest one
-#define MAX_N_MUSIG_SESSIONS 8
+#define MAX_N_MUSIG_SESSIONS 32
// state of a musig_psbt_session. Members are private and must not be accessed directly by any
// code outside of musig_sessions.c.
### tests/test_sign_psbt_musig.py
@@ -667,12 +667,18 @@ def test_sign_psbt_musig2_missing_session_fails_before_review(navigator: Navigat
[Round2OnlyCosigner(signer_1_with_review), Round2OnlyCosigner(signer_2)], KEYPATH_SIGHASHES)
-MAX_N_MUSIG_SESSIONS = 8
+MAX_N_MUSIG_SESSIONS = 32
-def test_sign_psbt_musig2_evicts_oldest_session(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str, speculos_globals: SpeculosGlobals):
+def test_sign_psbt_musig2_evicts_oldest_session(navigator: Navigator, firmware: Firmware, client: RaggerClient, test_name: str, speculos_globals: SpeculosGlobals, enable_slow_tests: int):
# The device stores at most MAX_N_MUSIG_SESSIONS sessions; when the storage is full, round 1
# evicts the oldest session, regardless of the slot it occupies.
+
+ # slow test (it fills the whole storage), only run it if --enable_slow_tests is set to a value
+ # greater than 0
+ if enable_slow_tests < 1:
+ pytest.skip()
+
wallet_policy, wallet_hmac = keypath_wallet_policy(speculos_globals)
signer_1 = LedgerMusig2Cosigner(client, wallet_policy, wallet_hmac,Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.