Skip to content

BIP-379: add test vectors from rust-miniscript - #2240

Open
guggero wants to merge 1 commit into
bitcoin:masterfrom
guggero:bip379-test-vectors
Open

guggero wants to merge 1 commit into
bitcoin:masterfrom
guggero:bip379-test-vectors

Conversation

@guggero

@guggero guggero commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The BIP-379 currently has a TBD in the test vector section.
I have extracted a bunch of test vectors from the rust-miniscript project, either directly or by slightly modifying test code to dump them into text/TSV files.
They have been very helpful for re-implementation in another language, so I think they should be made easily available here.

@jonatack jonatack added Proposed BIP modification PR by non-owner to update BIP content Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified labels Aug 6, 2026
@jonatack

jonatack commented Aug 7, 2026

Copy link
Copy Markdown
Member

Concept ACK. It may be handy to provide a file here that runs/verifies the test vectors.

@guggero
guggero force-pushed the bip379-test-vectors branch from 3ef799a to 9334aa2 Compare August 7, 2026 08:56
@guggero

guggero commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Concept ACK. It may be handy to provide a file here that runs/verifies the test vectors.

That's a great idea. I've added that in the latest push.
Output looks like this:

$ cd bip-0379; go run main.go
Checking the BIP379 test vectors in . against
github.com/btcsuite/btcd/descriptors/miniscript.

Testing vectors in valid_from_alloy.txt       [positive]: 5896/5896 done (type column not compared)
Testing vectors in valid_8f1e8_from_alloy.txt [positive]: 3492/3492 done (type column not compared)
Testing vectors in malleable_from_alloy.txt   [positive/negative]: 7024/7024 + 7024/7024 done
Testing vectors in conflict_from_alloy.txt    [positive]: 1773/1773 done (1586 of them are rejected by the sanity checks)
Testing vectors in edge_cases.txt             [positive]: 42/42 done
Testing vectors in opcodes.txt                [positive]: 18185/18185 done (type and op count columns not compared)
Testing vectors in invalid.txt                [negative]: 5574/5574 done
Testing vectors in props_from_rust.tsv        [positive]: 8198/8198 done (op_count and exec_stack columns not compared)
Testing vectors in props_from_rust_tap.tsv    [positive/negative]: 6728/6728 + 1470/1470 done (op_count and exec_stack columns not compared)
Testing vectors in scripts_from_rust.tsv      [positive]: 8198/8198 done
Testing vectors in scripts_from_rust_tap.tsv  [positive/negative]: 6728/6728 + 1470/1470 done
Testing vectors in redeem.json                [positive/negative]: 12/12 + 34/34 done (each spend is executed in the script engine)

All 81848 vectors passed (0 skipped).

@murchandamus

Copy link
Copy Markdown
Member

cc Authors: @sipa, @apoelstra, @sanket1729, @darosior, @achow101

@sipa

sipa commented Aug 19, 2026

Copy link
Copy Markdown
Member

I tried to run these tests through the Bitcoin Core miniscript implementation, but quickly hit the problem that the typing rules are inplemented inconsistently. This isn't a problem in production, because the differences are all within expressions that are invalid (for the correctness-related typing rules) or malleable (for the malleability-related typing rules) anyway, but it does mean that exact type tests like the ones in malleable_from_alloy.txt enforce than strictly needed.

In fact, rust-miniscript, Bitcoin Core, and the BIP text are all inconsistent with each other, in minor irrelevant ways. If we want to go the direction of having strict test vectors (which I support), I think we also need to first align all implementations and specifications. My suggestion would be to make everything match the BIP text. I have an (LLM written) patch for Bitcoin Core to make it do that (which passes all its unit & fuzz tests) which I'm happy to PR, but someone else will need to do the same for rust-bitcoin. It differs from the BIP in one rule: the thresh rule for the "unique dissatisfiable" e rule in the BIP is that all children are s, while rust-miniscript (and Bitcoin Core, so far) additionally (and superfluously) require that all children are e.

@jonatack

Copy link
Copy Markdown
Member

My suggestion would be to make everything match the BIP text.

(non-author) approach ACK

@guggero

guggero commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks a lot for testing the test vectors with Bitcoin Core, @sipa.

I'm also in favor of attempting to align everything with the BIP text.

but someone else will need to do the same for rust-bitcoin

Will attempt that soon-ish.

EDIT: Here's the BIP amendment PR and the rust-miniscript PR.

@guggero

guggero commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

I I've pushed up a fixup commit (3526e43) that addresses #2240 (comment) (and also fixes the Golang import issues I didn't realize were there).

@apoelstra

Copy link
Copy Markdown
Contributor

concept ACK. Great effort. I'm sure a LLM can fill in the documented gaps in a followup PR.

I didn't look at the test vectors or the Go code, but the markdown updates look good to me.

Will review rust-bitcoin/rust-miniscript#1032 more carefully.

guggero added a commit to guggero/bips that referenced this pull request Aug 26, 2026
Both tables give the properties of a fragment in function of those of its
subexpressions, and both are written assuming that the conditions in the
"Requires" column of that fragment hold. Where they do not, the tables
still assign values, but the values carry none of the meaning the
descriptions of the properties give them, and implementations are free to
differ on them.

thresh is the case that surfaced this. Its rule is "e=all are s", so
thresh(2,or_i(pk(A),pk(B)),a:or_i(pk(C),pk(D))) is "e" even though each
or_i child has two unconditional dissatisfactions, giving the threshold
four, which is the opposite of the "unique unconditional dissatisfaction"
that the description of "e" promises. The threshold fails the "e"
requirement the same table imposes, though, so it is malleable and the
value is a don't-care.

Say so below both tables, so that implementations which disagree on the
type of an invalid or malleable expression are not read as contradicting
this document. Bitcoin Core (bitcoin/bitcoin#36028) and rust-miniscript
are aligning on the values the tables give, and the test vectors proposed
in bitcoin#2240 leave out the properties that are not meaningful: z/o/n/d/u for
invalid expressions and s/f/e for malleable ones.
@guggero

guggero commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

I've updated the test vectors in a fixup commit to match the discussion in #2267 and the proposed changes in rust-bitcoin/rust-miniscript#1037.

guggero added a commit to guggero/bips that referenced this pull request Aug 30, 2026
Both tables give the properties of a fragment in function of those of its
subexpressions, and both are written assuming that the conditions in the
"Requires" column of that fragment hold. Where they do not, the tables
still assign values, but the values carry none of the meaning the
descriptions of the properties give them, and implementations are free to
differ on them.

thresh is the case that surfaced this. Its rule is "e=all are s", so
thresh(2,or_i(pk(A),pk(B)),a:or_i(pk(C),pk(D))) is "e" even though each
or_i child has two unconditional dissatisfactions, giving the threshold
four, which is the opposite of the "unique unconditional dissatisfaction"
that the description of "e" promises. The threshold fails the "e"
requirement the same table imposes, though, so it is malleable and the
value is a don't-care.

Say so below both tables, so that implementations which disagree on the
type of an invalid or malleable expression are not read as contradicting
this document. Bitcoin Core (bitcoin/bitcoin#36028) and rust-miniscript
are aligning on the values the tables give, and the test vectors proposed
in bitcoin#2240 leave out the properties that are not meaningful: z/o/n/d/u for
invalid expressions and s/f/e for malleable ones.
@guggero
guggero force-pushed the bip379-test-vectors branch from ae37c13 to 576b4da Compare September 8, 2026 11:39
@guggero guggero changed the title BIP-379: add test vectors from rust-miniscript BIP-379: add test vectors from rust-miniscript and btcd Sep 8, 2026
@guggero guggero changed the title BIP-379: add test vectors from rust-miniscript and btcd BIP-379: add test vectors from rust-miniscript Sep 8, 2026
@guggero
guggero force-pushed the bip379-test-vectors branch 2 times, most recently from 000ec94 to 47047eb Compare September 8, 2026 11:55
@murchandamus

Copy link
Copy Markdown
Member

Thanks for the reviews and updates to the implementations, great to see that y’all are on it.

@fametrano

Copy link
Copy Markdown

The harness compares sat_witness_elements and sat_size, and both count as rust-miniscript does. The BIP does not say what they count. An implementation that counts as Bitcoin Core does fails every sat_witness_elements row and 21% of sat_size rows.

I ran the vectors at 47047eb through btclib-wallet's miniscript module, which reproduces the resource numbers in Core's miniscript_tests.cpp. Once malleable expressions carry no "s", "f" or "e", as #2267 says, it agrees on every row for validity, types, timelock mixing, malleability, requires_sig, script_size and both script tables. It also disagrees on 10% of the opcodes.txt ops and on op_count and exec_stack, none of which the harness compares.

Two examples. pk(A) has sat_witness_elements 2 where Core counts 1: the vector counts the witness script, which the BIP's 100-element rule excludes. In the Tapscript table, thresh(1,pk(A),s:pk(B)) has sat_size 132, two 66-byte signatures, and no valid witness is that large. Two valid signatures make the count 2, not 1. Under BIP342 a failed non-empty signature fails the script, so the key that does not sign gives an empty signature. The largest witness is then 67, which is what Core gives. Other differences come from dissatisfactions Core does not count, such as a hash's.

Could the Files table say what each of these columns counts, or could the harness skip sat_witness_elements and sat_size as it does op_count and exec_stack?

@guggero
guggero force-pushed the bip379-test-vectors branch from 47047eb to 217afc1 Compare October 6, 2026 12:05
@guggero

guggero commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for running the vectors against btclib, that's very useful independent validation.

There were two separate issues:

  • thresh was a bug. The extraction sized k+1 satisfied sub expressions instead of k (fixed upstream in fix(miniscript): count exactly k satisfactions in thresh max-size bounds rust-bitcoin/rust-miniscript#1040). The regenerated tables now give 67 for thresh(1,pk(A),s:pk(B)), the same as you got.
  • The rest is how the columns are counted. They follow rust-miniscript: sat_witness_elements adds one for the witness script, and op_count / sat_size maximize over all satisfactions, malleable ones included. Core never dissatisfies a hash fragment. Changing only that rule in the Go implementation reproduces your figures: 9.6% of opcodes.txt ops and 20–22% of sat_size rows.

I went with your first suggestion and updated the PR:

  • A new "Resource Columns" section defines each column and states the difference from Core. exec_stack and the Tapscript op_count are marked informative only.
  • New limits[_tap].txt has within/over vectors at each limit (201 ops, 3,600 bytes, 100 witness elements, 1,000 Tapscript stack elements), with no hash fragments. Core and the Go implementation agree on all ten verdicts. rust-miniscript rejects the 100-element within vector, because it counts the witness script against that limit.
  • The harness now compares types, op counts and the limit verdicts. It skips only exec_stack and the Tapscript op_count.
  • Everything now comes from unmodified rust-miniscript master (698b97f).

@fametrano

Copy link
Copy Markdown

ACK 217afc1

I ran the vectors through btclib-wallet's miniscript module (not redeem.json, and not the Go harness). Parsing, types, scripts and the ten limit verdicts agree. The resource columns differ only by the two rules the new section describes, apart from exec_stack and the Tapscript op_count, which the section already sets aside.

Two wording nits. The Files table says every line of conflict_from_alloy.txt mixes timelock kinds on one path, but 187 of the 1,773 do not, for example and_v(v:multi(2,A,B,C),andor(multi(2,D,E,F),after(500000001),after(1))), which props_from_rust.tsv marks mixed_timelocks=false. And edge_cases.txt is not "the only hand-written file": limits.txt and limits_tap.txt are too.

@guggero
guggero force-pushed the bip379-test-vectors branch from 217afc1 to c923f2e Compare October 7, 2026 09:06
@guggero

guggero commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback, @fametrano! I've updated the text to fix the nits you mentioned.

@fametrano

Copy link
Copy Markdown

reACK c923f2e

Only bip-0379.md and main.go changed since 217afc1, and the vector files are identical, so my earlier run still holds. Both nits are fixed, and the new conflictInsane = 1586 is the 1,773 lines minus the 187 sane ones I found.

@guggero
guggero force-pushed the bip379-test-vectors branch from c923f2e to 91fdd5d Compare November 10, 2026 12:04
@jonatack

Copy link
Copy Markdown
Member

cc authors @sipa, @apoelstra, @sanket1729, @darosior, @achow101 for acceptance

@sanket1729

Copy link
Copy Markdown
Contributor

Approach and concept ACK.

@apoelstra

Copy link
Copy Markdown
Contributor

concept ACK from me

@fametrano fametrano left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reACK 91fdd5d

Only go.mod and go.sum changed since c923f2e. The vectors, main.go and bip-0379.md are identical, so my earlier run still holds.

@murchandamus

Copy link
Copy Markdown
Member

I see that you have conceptual support from Pieter, Sanket, and Andrew, but it seems like at least Pieter’s PR is not yet merged. I also see that Andrew said the markdown changes look good to him.
@guggero: What’s your read on the situation, should this BIP update wait until the implementation updates have landed to ensure the BIP update is solid, or could it go in independently?

If the former, perhaps we could turn this into a draft until the relevant implementation PRs land. If the latter, could we perhaps get more obvious acceptance signals from the owners than Concept ACKs?

@guggero

guggero commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

I would go out on a limb here and say that this can probably be merged independently.

The main discussion item of this PR (the type of malleable expressions) was resolved by #2267, and the vectors follow that. They agree with the current BIP text and with rust-miniscript@698b97f (apart from the one limits.txt vector it rejects, as documented in Provenance).

Bitcoin Core still reports s, f and e on malleable expressions. Once those are dropped, as #2267 says an API should, Core agrees with every type in the vectors, so this is not a bug and can be handled in the test code.
Pieter's PR is independent of that. It makes Core's typing rules match the BIP's tables literally, but with that rule applied it doesn't change Core's results on these vectors. So neither PR has to wait for the other.

EDIT: corrected the part about bitcoin/bitcoin#36028 after running the test vectors through Core. Added the cross-check table(s).

Cross-check between different implementations (LLM-generated)

Summary

  • All three implementations agree with every vector on parsing and rejection, sanity,
    timelock mixing, script_size, non_malleable, requires_sig, the script encoding
    in both contexts, and the redeem.json spends. The only exception is one limit
    vector in rust-miniscript (item 6 below).
  • Bitcoin Core and btclib-wallet produce identical values for every resource column,
    and so they fail on exactly the same rows. Every one of those rows is a difference in
    how a quantity is counted, and the BIP text already describes it. No vector is wrong.
  • Bitcoin Core also reports s, f and e on malleable expressions. The vectors
    leave them out, as BIP-379: note that the type properties assume their requirements #2267 asks of APIs. Once Core's types drop them, Core and
    btclib-wallet fail exactly the same 16,573 vectors, with the same values.
  • miniscript: make typing rule match BIP-379 exactly bitcoin#36028 doesn't change any of this. Applied on current master, it
    leaves the results identical once s/f/e are dropped. Comparing raw types, it
    adds 558 failures. Details are under item 1.

What was compared

Source Version
Test vectors this PR, 91fdd5d3
BIP text this PR, 91fdd5d3
rust-miniscript 698b97f, the commit named in Provenance
Bitcoin Core master a527a0077a0f, and the same with bitcoin/bitcoin#36028 (2631ece7b5) applied on top
btclib-wallet cab4c7b (main)

Each implementation read every expression with its own parser, with the keys
substituted as the Conventions section describes. These were the checks:

  • Types: compared as sorted letters.
  • Resource columns: every column of props_from_rust[_tap].tsv and the <ops> of
    opcodes.txt were compared exactly, exec_stack and the Tapscript op_count
    included.
  • Limit vectors: a within vector has to parse as sane, and an over vector has to
    be rejected.
  • redeem.json: each implementation built the witness with its own non-malleable
    satisfier, signed with SIGHASH_ALL, and the spend of the P2WSH output was executed.
    rust-miniscript used libbitcoinconsensus, Bitcoin Core its own interpreter with the
    standard flags, and btclib-wallet its own script engine.

Results per file

A ✓ means every vector of the file passes. Otherwise the cell gives the number of
failing vectors.

File Vectors rust-miniscript Core Core + #36028 btclib-wallet
valid_from_alloy.txt 5,896 ✓ ✓ ✓ ✓
valid_8f1e8_from_alloy.txt 3,492 ✓ 1,732 (type) 2,070 (type) ✓
malleable_from_alloy.txt 7,024 + 7,024 not sane ✓ 7,024 (type) 7,024 (type) ✓
conflict_from_alloy.txt 1,773 + 1,586 not sane ✓ ✓ ✓ ✓
edge_cases.txt 42 ✓ ✓ ✓ ✓
opcodes.txt 18,185 ✓ 9,192 (8,756 type, 1,741 ops) 9,412 1,741 (ops)
invalid.txt 5,574 ✓ ✓ ✓ ✓
limits.txt 8 1 ✓ ✓ ✓
limits_tap.txt 2 ✓ ✓ ✓ ✓
props_from_rust.tsv 8,198 ✓ 8,151 8,151 8,151
props_from_rust_tap.tsv 6,728 + 1,470 PARSE_ERR ✓ 6,681 6,681 6,681
scripts_from_rust.tsv 8,198 ✓ ✓ ✓ ✓
scripts_from_rust_tap.tsv 6,728 + 1,470 ERR ✓ ✓ ✓ ✓
redeem.json 12 + 34 ✓ ✓ ✓ ✓
Failing, of 81,860 1 32,780 33,338 16,573

Here is what makes the props rows fail, counted per column. Core (with or without
#36028) and btclib-wallet have the same counts:

Column props_from_rust.tsv props_from_rust_tap.tsv Cause
op_count 691 (8.4%) 5,004 (4,883 multi_a + 121 hash) items 4 and 5
sat_witness_elements (after adding one, see item 3) 1,345 (16.4%) 1,209 (18.0%) item 4
sat_size 1,623 (19.8%) 1,474 (21.9%) item 4
exec_stack 8,015 6,660 item 5
everything else 0 0

Differences

# Topic Vectors and BIP text rust-miniscript Bitcoin Core btclib-wallet Proposed resolution
1 s/f/e in the type of a malleable expression left out; the BIP says an API should report them false left out reports them left out Core: drop them when comparing against the vectors. BIP: say so in Conventions.
2 sat_witness_elements counts the witness script yes, "plus one" yes no no BIP: explain why the column is one higher, and that such implementations compare their count plus one.
3 Malleable satisfactions in op_count, sat_witness_elements and sat_size counted, as the BIP describes counted not counted not counted BIP: make the summary sentence say exactly which columns agree.
4 Tapscript op_count of multi_a 0; the BIP says the column has no meaning 0 counts the opcodes counts the opcodes BIP: name the difference. Don't compare this column.
5 exec_stack rust-miniscript's estimate, as the BIP describes same peak stack size including the witness same as Core BIP: name what Core reports instead. Don't compare this column.
6 limits.txt witness_elements within 100 elements, the witness script excluded rejects it accepts it accepts it rust-miniscript: fix the off-by-one. The existing note in Provenance stays until then.

1. s, f and e on malleable expressions, and bitcoin/bitcoin#36028

#2267, which was merged, added this to the Malleability section: "Implementors of APIs
which unconditionally return values for these properties should always return false
for malleable expressions."
The vectors follow it, and so do rust-miniscript (since
rust-bitcoin/rust-miniscript#1037) and btclib-wallet. Bitcoin Core's type computation
still reports these letters on malleable expressions. For example,
andor(jc:pk_k(A),after(500000001),0) has type doB in the vectors, but Core reports
Bodes. That accounts for every type failure in Core: 1,732 lines of
valid_8f1e8_from_alloy.txt, all 7,024 of malleable_from_alloy.txt and 8,756 of
opcodes.txt. Once Core's type drops s, f and e whenever m is absent, Core
agrees with every type in every file.

bitcoin/bitcoin#36028 applies cleanly to current master, and Core's own
miniscript_tests still pass with it. It changes four rules to match the BIP's tables
literally:

  • d: always gets o and e;
  • or_b always gets e;
  • thresh gets e when all its children are s.

Each of these changes only the type of an expression that is invalid or malleable
anyway. On the vectors:

  • Comparing raw types, Core with #36028 fails more vectors: 33,338 instead of
    32,780. All 249 expressions whose type changes are malleable, and they all gain an
    e that the vectors leave out. For example,
    and_b(multi(2,A,B,C),a:or_b(j:multi(2,D,E,F),a:multi(2,G,I,J))) goes from Bndus
    to Bndues, while the vectors say Bdnu.
  • With s/f/e dropped from malleable types, Core produces exactly the same
    results with and without #36028.

So #36028 neither resolves nor causes any difference with the vectors. What makes Core
agree is the rule from #2267 (malleable means no s, f or e). This can be applied
in Core's test code, as sipa suggested in #2267 ("the actual logic implementing this
can be pushed to the tests, so no internal code changes are needed"), or in Core's
type accessor. #36028 is still useful on its own merits, because it makes Core's raw
typing rules read like the BIP's tables. But this PR doesn't need to wait for it.

2. sat_witness_elements is one higher than Core's count

The column is rust-miniscript's max_satisfaction_witness_elements. It counts the
witness script as one of the witness elements, in both contexts. Core's
GetStackSize() and btclib-wallet's max_stack_items count only the elements that
satisfy the script, which is also the number the 100-element P2WSH standardness limit
applies to. For pk(A), the witness is <sig> <script>, so the column says 2, while
Core and btclib-wallet say 1.

So every row that has a satisfaction is exactly one higher than Core's value. An
implementation that counts like Core has to add one to its own count before comparing.
The BIP already says "plus one", but not why, or what such an implementation should do;
the proposed wording adds both. After adding one, the rows that still differ are the
ones described in item 3.

3. Malleable satisfactions in op_count, sat_witness_elements and sat_size

As the Resource Columns section says, these columns are the maximum over every
satisfaction the fragment rules allow, malleable ones included. One such satisfaction
dissatisfies a hash fragment with a 32-byte value that is not the preimage. Core and
btclib-wallet count only non-malleable satisfactions, and those never dissatisfy a hash
fragment. Every differing row contains a hash fragment, Core and btclib-wallet are
always the lower value, and the two agree with each other in every row.

  • opcodes.txt: or_d(c:pk_k(A),or_d(sha256(926a…),multi(2,B,C,D))) has <ops>
    15, but Core and btclib-wallet say 12. The vectors count the path that dissatisfies
    pk_k(A) and sha256, then executes the CHECKMULTISIG with its 3 keys. Without
    dissatisfying sha256, multi is never reached.
  • props_from_rust.tsv: or_b(sha256(926a…),ac:pk_k(A)) has sat_size 106, a
    73-byte signature plus 33 bytes of non-preimage. Core and btclib-wallet say 34, the
    33-byte preimage plus an empty dissatisfaction of pk_k(A).

The rates match what the BIP says ("roughly one in ten op counts and one in five
sat_size values"):

  • op counts: 8.4% of props_from_rust.tsv and 9.6% of opcodes.txt;
  • sat_size: 19.8% and 21.9%.

The one sentence I'd change is "an implementation that counts like Core reproduces
every other column". It doesn't hold for exec_stack or for the Tapscript op_count
(items 4 and 5). It also doesn't say that sat_witness_elements keeps differing in
these rows after adding one (16.4% and 18.0%).

4. Tapscript op_count

The column counts a multi_a as no ops at all, and the BIP already says the column has
no meaning in Tapscript. Core and btclib-wallet count its opcodes: multi_a(1,A) is 0
in the vectors and 2 in both of them. That accounts for 4,883 rows. The remaining 121
rows of the 5,004 are the hash-fragment rows of item 3. main.go already skips this
column, and other implementations should skip it too.

5. exec_stack

The column is rust-miniscript's estimate of how many elements the script pushes above
its witness, and the BIP says so. Core's GetExecStackSize() and btclib-wallet's
max_exec_stack_items report the peak stack size during execution, witness elements
included, which is what the 1,000-element limit bounds. For example,
and_b(after(1),a:and_b(after(1),ac:pk_k(A))) is 3 in the vectors and 4 in both of
them. No offset maps one quantity onto the other: even after subtracting the witness
elements, the difference ranges from −2 to +2 in P2WSH and from −4 to 0 in Tapscript.
main.go already skips this column, and other implementations should skip it too.

6. rust-miniscript rejects the witness_elements within vector

In limits.txt, within is a chain of and_v(v:pk(K1),…) with 100 keys, so its
satisfaction has 100 elements. over has 101 keys. The BIP's Resource Limits section,
like Core's policy, excludes the witness script from the 100-element limit. However,
rust-miniscript's Segwitv0::check_local_policy_validity compares
max_satisfaction_witness_elements(), which includes the script, against 100. It
therefore rejects a satisfaction with exactly 100 elements. The code is unchanged on
current master (d57bb31). Core and btclib-wallet accept within and reject over.
The vector is correct, and the BIP already documents this behaviour in Provenance. The
fix belongs in rust-miniscript: compare the count minus one.

@apoelstra

Copy link
Copy Markdown
Contributor

Cross-check between different implementations (LLM-generated)

For finding 2 (rust-miniscript max_satisfaction_witness_elements counts the witness script as a witness element) the bot proposes just documenting the difference.

But I think we should fix rust-miniscript to not count the witness script.

Finding 6 is related (when checking limits, rust-miniscript counts the witness script against the 100 limit), and there the bot suggests fixing rust-miniscript, which I agree with.

Both of these seem to stem from the same confusion on my part about whether the witness script counts as a witness element.

The other four findings I agree are uninteresting and (at most) just need a mention that the implementations differ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified Proposed BIP modification PR by non-owner to update BIP content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants