Skip to content

Commit

Permalink
BIP341 test vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Nov 5, 2021
1 parent 708ce10 commit 1216cb8
Show file tree
Hide file tree
Showing 2 changed files with 462 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bip-0341.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,17 @@ The reason for this is to increase leaf entropy and prevent an observer from lea

== Test vectors ==

The test vectors used in the [https://github.com/bitcoin/bitcoin/blob/3820090bd619ac85ab35eff376c03136fe4a9f04/src/test/script_tests.cpp#L1718 Bitcoin Core unit test framework] can be found [https://github.com/bitcoin-core/qa-assets/blob/main/unit_test_data/script_assets_test.json?raw=true here].
Test vectors for wallet operation (scriptPubKey computation, key path spending, control block construction) can be found [[bip-0341/wallet-test-vectors.json|here]].
It consists of two sets of vectors.
* The first "scriptPubKey" tests concern computing the scriptPubKey and (mainnet) BIP350 address given an internal public key, and a script tree.
The script tree is encoded as <code>null</code> to represent no scripts, a JSON object to represent a leaf node, or a 2-element array to represent an inner node.
The control blocks needed for script path spending are also provided for each of the script leaves.
* The second "keyPathSpending" tests consists of a list of test cases, each of which provides an unsigned transaction and the UTXOs it spends. For each of
its BIP341 inputs, the internal private key and the Merkle root it was derived from is given, as well as the expected witness to spend it.
All signatures are created with an all-zero (0x0000...0000) BIP340 auxiliary randomness array.
* In all cases, hexadecimal values represent byte arrays, not numbers. In particular, that means that provided hash values have the hex digits corresponding to the first bytes first. This differs from the sometimes used convention (like in txids and block hashes) to represent them as numbers where the order is revered.
Validation test vectors used in the [https://github.com/bitcoin/bitcoin/blob/3820090bd619ac85ab35eff376c03136fe4a9f04/src/test/script_tests.cpp#L1718 Bitcoin Core unit test framework] can be found [https://github.com/bitcoin-core/qa-assets/blob/main/unit_test_data/script_assets_test.json?raw=true here].

== Rationale ==

Expand Down
Loading

0 comments on commit 1216cb8

Please sign in to comment.