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

Align miniscript type and ops computations with bitcoin-core

Public commit record

What the developer wrote

Authored by Salvatore Ingala

91/100 · Strong
Align miniscript type and ops computations with bitcoin-core

Fixes several discrepancies, all making the analysis stricter than
necessary, which could cause valid policies to be rejected:

- and_n(X,Y) is andor(X,Y,0): since 0 has the 's' property, non-
malleability does not require s_X or s_Y; and the dissatisfaction
of Y is never executed, so it does not contribute to the ops count.
- thresh: the timelock mixing check compared each child with the
accumulated timelocks including its own, so a child with different
kinds of timelocks in separate branches was flagged as mixing.

Also aligns the 'e' property of or_b, thresh and d: with bitcoin-core.
This has no effect on the final result, since the computed 'e' only
differed for nodes that are not 'm'.

A previous non-regression test lost its coverage after these changes;
wrapping the child in ltv: makes sure that it has e=1 but m=0, and the
test properly checks that thresh requires all the children to have 'm'.

As a reference, compare with:
https://github.com/bitcoin/bitcoin/blob/3eca89820e1fb152ebf0315e3924fc374cb35958/src/script/miniscript.cpp#L119-L230
https://github.com/bitcoin/bitcoin/blob/3eca89820e1fb152ebf0315e3924fc374cb35958/src/script/miniscript.h#L1046-L1051

Implementation and tests from Claude Opus 5.5.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes the Ledger Bitcoin app's internal checker for Miniscript wallet policies. The checker was incorrectly rejecting some valid Bitcoin spending policies as unsafe, and in a few places it was computing safety properties using formulas that differ from the reference implementation in Bitcoin Core. The changes make the Ledger app match Bitcoin Core's stricter-but-correct rules. There is no direct evidence in the commit that user funds were at risk of theft; the main effect was that legitimate wallet setups could be wrongly rejected.

Recommended action

Review the updated formulas against the cited Bitcoin Core source lines to confirm they match. Run the expanded unit tests and, if possible, fuzz-test Miniscript policy parsing to ensure no new invalid policies are accepted. Consider whether any user-facing error messages need updating now that previously rejected valid policies are accepted.

Security signals we found

01

Logic change in Miniscript policy analysis

02

Alignment with upstream Bitcoin Core reference implementation

03

Relaxation of overly strict non-malleability and timelock-mixing checks

04

Correction of ops-count accounting for and_n/andor

05

Addition of regression tests for previously rejected valid policies

Risk score

Why this scored 48/100

Our methodology →
Potential impact 12/30
Exploitability 8/25
Stealth signal 7/15
Affected reach 10/15
Confidence 7/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.