From 91fdd5d3aa9e9131c4109cf84891241d8dce7f3a Mon Sep 17 00:00:00 2001 From: Oli Date: Thu, 6 Aug 2026 10:26:50 +0200 Subject: [PATCH] bip379: add test vectors from rust-miniscript --- bip-0379.md | 111 +- bip-0379/conflict_from_alloy.txt | 1773 +++ bip-0379/edge_cases.txt | 42 + bip-0379/go.mod | 27 + bip-0379/go.sum | 30 + bip-0379/invalid.txt | 5574 ++++++++ bip-0379/limits.txt | 8 + bip-0379/limits_tap.txt | 2 + bip-0379/main.go | 981 ++ bip-0379/malleable_from_alloy.txt | 7024 ++++++++++ bip-0379/opcodes.txt | 18185 ++++++++++++++++++++++++++ bip-0379/props_from_rust.tsv | 8199 ++++++++++++ bip-0379/props_from_rust_tap.tsv | 8199 ++++++++++++ bip-0379/redeem.json | 304 + bip-0379/scripts_from_rust.tsv | 8198 ++++++++++++ bip-0379/scripts_from_rust_tap.tsv | 8198 ++++++++++++ bip-0379/valid_8f1e8_from_alloy.txt | 3492 +++++ bip-0379/valid_from_alloy.txt | 5896 +++++++++ 18 files changed, 76242 insertions(+), 1 deletion(-) create mode 100644 bip-0379/conflict_from_alloy.txt create mode 100644 bip-0379/edge_cases.txt create mode 100644 bip-0379/go.mod create mode 100644 bip-0379/go.sum create mode 100644 bip-0379/invalid.txt create mode 100644 bip-0379/limits.txt create mode 100644 bip-0379/limits_tap.txt create mode 100644 bip-0379/main.go create mode 100644 bip-0379/malleable_from_alloy.txt create mode 100644 bip-0379/opcodes.txt create mode 100644 bip-0379/props_from_rust.tsv create mode 100644 bip-0379/props_from_rust_tap.tsv create mode 100644 bip-0379/redeem.json create mode 100644 bip-0379/scripts_from_rust.tsv create mode 100644 bip-0379/scripts_from_rust_tap.tsv create mode 100644 bip-0379/valid_8f1e8_from_alloy.txt create mode 100644 bip-0379/valid_from_alloy.txt diff --git a/bip-0379.md b/bip-0379.md index cace8f859a..03c2ae3918 100644 --- a/bip-0379.md +++ b/bip-0379.md @@ -405,7 +405,116 @@ paths hit any of the limits. ## Test Vectors -TBD +### Conventions + +Text files have one vector per line, no comments. `*.txt` is space separated, +`*.tsv` tab separated. Expressions contain no whitespace. A key argument is a letter +`A`..`Z` standing for the public key of the secret key `0x00…01` … `0x00…1a`, +serialized compressed in P2WSH and x-only in Tapscript. The limit vectors need more +distinct keys than that and write `K` followed by the secret key in decimal instead +(`K1`, `K2`, …). Hash arguments are literal hex. A type string is the basic type +(`B`/`V`/`K`/`W`) plus its properties (`zondumsfe`) in arbitrary order, so compare +sorted. Files with a `_tap` suffix are Tapscript (`multi_a`, x-only, Schnorr), the +others P2WSH. + +### Files + +| File | Lines | Line format | Asserts | +|------|-------|-------------|---------| +| `valid_from_alloy.txt` | 5,896 | ` ` | parses, is a valid top level, has that type | +| `valid_8f1e8_from_alloy.txt` | 3,492 | same | same, corpus of an earlier upstream revision | +| `malleable_from_alloy.txt` | 7,024 | same | parses, has that type, but has no `m` property, i.e. is not sane | +| `conflict_from_alloy.txt` | 1,773 | same | parses and has that type; combines height- and time-based `after()`, on one spending path in 1,586 lines (not sane) and on alternative `andor` branches in the other 187 (sane) | +| `edge_cases.txt` | 42 | `` | a hand-written file: `thresh` at `k=1`/`k=n`, `multi` with 1 and 20 keys, all four hash fragments, the timelock boundaries (`499999999`/`500000000`, `4194304`/`4194305`), and the sugar forms | +| `invalid.txt` | 5,574 | `` | must be rejected (mostly type-check failures) | +| `opcodes.txt` | 18,185 | ` ` | as above, plus the op count of a satisfaction, see `op_count` below | +| `limits.txt`, `limits_tap.txt` | 8, 2 | ` ` | hand-written files: each resource limit at its boundary, `limit` being one of `ops`, `script_size`, `witness_elements` and `stack`. A `within` expression is sane; an `over` expression exceeds that limit by one and must be rejected, by the parser or by the sanity checks | +| `props_from_rust[_tap].tsv` | 8,198 + header | `expr script_size op_count sat_witness_elements exec_stack mixed_timelocks non_malleable requires_sig sat_size` | the static analysis, with the columns described below. A two-field row ending in `PARSE_ERR` must be rejected (1,470 of them in the Tapscript file, from the `multi`→`multi_a` substitution) | +| `scripts_from_rust[_tap].tsv` | 8,198 | `\t