AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 19 Bitcoin

api: use unstable sorting for keys

Public commit record

What the developer wrote

Authored by benma's agent

68/100 · Adequate
api: use unstable sorting for keys

Stable sorting is unnecessary for these keys and adds sorting code to the
firmware. Using sort_unstable() saves 832 bytes in the BitBox02 multi
firmware with Rust 1.96.0, reducing firmware.bin from 661,896 to 661,064
bytes.

Sort serialized multisig xpubs, derived public keys, and Cardano signing
paths with the same lexicographic ordering. Equal values have identical
contents, so changing their relative order cannot affect registration
hashes, output scripts, or witness order. Cardano still removes duplicate
paths after sorting.

The unstable sort also avoids the stable sort's possible temporary
allocation.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit swaps Rust's stable sort for an unstable sort in three places inside the BitBox02 firmware. The change only affects the order in which equal items are arranged, and the commit message explicitly states that equal items have identical contents, so the result is the same. The main benefit is a smaller firmware file and avoiding a possible memory allocation during sorting. There is no direct evidence this fixes a security vulnerability.

Recommended action

No immediate action required. Treat as a code-size optimization. If reviewing for audit purposes, verify the claim that equal serialized xpubs/public keys/keypaths are byte-identical and that unstable reordering therefore cannot change externally observable outputs.

Security signals we found

01

Behavior-preserving optimization with no change to sorted outputs when keys are unique or equal values are identical

02

Commit message explicitly addresses determinism concerns for registration hashes, output scripts, and witness order

03

No input validation, memory-safety, or cryptographic changes in the diff

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.