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

Use signed scratch arrays in the thresh ops and stack size computations

Public commit record

What the developer wrote

Authored by Salvatore Ingala

85/100 · Strong
Use signed scratch arrays in the thresh ops and stack size computations

sumcheck() and maxcheck() return -1 for invalid (dis)satisfactions,
which was stored in uint16_t arrays; this wasn't a bug only because it
is later converted back to -1 when read as int16_t.

Using int16_t directly is clearer.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit is a small code cleanup in Ledger's Bitcoin app. It changes two local arrays from unsigned (uint16_t) to signed (int16_t) in functions that count operations and stack sizes for Bitcoin miniscript 'thresh' policies. The commit message says the old code was not actually buggy because the stored -1 values were later read back as signed -1 anyway, but using signed types directly is clearer and less error-prone.

Recommended action

Treat as a minor hardening/cleanup change. No urgent action is required, but downstream forks or audits should adopt the same type-correctness fix to avoid future bugs if the read path ever changes. Review related miniscript analysis code for similar signed/unsigned mismatches.

Security signals we found

01

Signed/unsigned type mismatch in sentinel handling

02

Potential latent integer interpretation bug in miniscript threshold policy analysis

03

Code clarity improvement around invalid (dis)satisfaction markers

Risk score

Why this scored 18/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 2/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.