Skip to content

Commit

Permalink
Merge pull request #1225 from sipa/202110_bip341_vectors
Browse files Browse the repository at this point in the history
BIP341 test vectors
  • Loading branch information
kallewoof committed Nov 13, 2021
2 parents b155143 + e35a46e commit 93adfba
Show file tree
Hide file tree
Showing 2 changed files with 459 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bip-0341.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,13 @@ 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 convention used for txids and block hashes, where the hex strings represent numbers, resulting in a reversed order.
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 93adfba

Please sign in to comment.