Skip to content

Commit 9408a04

Browse files
committed
tests, fuzz: use new NUMS_H const
1 parent b946f8a commit 9408a04

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/test/fuzz/miniscript.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ const struct KeyComparator {
309309
// A dummy scriptsig to pass to VerifyScript (we always use Segwit v0).
310310
const CScript DUMMY_SCRIPTSIG;
311311

312-
//! Public key to be used as internal key for dummy Taproot spends.
313-
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
314-
315312
//! Construct a miniscript node as a shared_ptr.
316313
template<typename... Args> NodeRef MakeNodeRef(Args&&... args) {
317314
return miniscript::MakeNodeRef<CPubKey>(miniscript::internal::NoDupCheck{}, std::forward<Args>(args)...);
@@ -1018,7 +1015,7 @@ CScript ScriptPubKey(MsCtx ctx, const CScript& script, TaprootBuilder& builder)
10181015

10191016
// For Taproot outputs we always use a tree with a single script and a dummy internal key.
10201017
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
1021-
builder.Finalize(XOnlyPubKey{NUMS_PK});
1018+
builder.Finalize(XOnlyPubKey::NUMS_H);
10221019
return GetScriptForDestination(builder.GetOutput());
10231020
}
10241021

src/test/key_tests.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <common/system.h>
88
#include <key_io.h>
9+
#include <span.h>
910
#include <streams.h>
1011
#include <test/util/random.h>
1112
#include <test/util/setup_common.h>
@@ -364,4 +365,13 @@ BOOST_AUTO_TEST_CASE(key_ellswift)
364365
}
365366
}
366367

368+
BOOST_AUTO_TEST_CASE(bip341_test_h)
369+
{
370+
std::vector<unsigned char> G_uncompressed = ParseHex("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8");
371+
HashWriter hw;
372+
hw.write(MakeByteSpan(G_uncompressed));
373+
XOnlyPubKey H{hw.GetSHA256()};
374+
BOOST_CHECK(XOnlyPubKey::NUMS_H == H);
375+
}
376+
367377
BOOST_AUTO_TEST_SUITE_END()

src/test/miniscript_tests.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,6 @@ class TestSignatureChecker : public BaseSignatureChecker {
288288
}
289289
};
290290

291-
//! Public key to be used as internal key for dummy Taproot spends.
292-
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
293-
294291
using Fragment = miniscript::Fragment;
295292
using NodeRef = miniscript::NodeRef<CPubKey>;
296293
using miniscript::operator"" _mst;
@@ -330,7 +327,7 @@ CScript ScriptPubKey(miniscript::MiniscriptContext ctx, const CScript& script, T
330327

331328
// For Taproot outputs we always use a tree with a single script and a dummy internal key.
332329
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
333-
builder.Finalize(XOnlyPubKey{NUMS_PK});
330+
builder.Finalize(XOnlyPubKey::NUMS_H);
334331
return GetScriptForDestination(builder.GetOutput());
335332
}
336333

src/test/script_tests.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,8 +1268,7 @@ BOOST_AUTO_TEST_CASE(sign_invalid_miniscript)
12681268
const auto invalid_pubkey{ParseHex("173d36c8c9c9c9ffffffffffff0200000000021e1e37373721361818181818181e1e1e1e19000000000000000000b19292929292926b006c9b9b9292")};
12691269
TaprootBuilder builder;
12701270
builder.Add(0, {invalid_pubkey}, 0xc0);
1271-
XOnlyPubKey nums{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
1272-
builder.Finalize(nums);
1271+
builder.Finalize(XOnlyPubKey::NUMS_H);
12731272
prev.vout.emplace_back(0, GetScriptForDestination(builder.GetOutput()));
12741273
curr.vin.emplace_back(COutPoint{prev.GetHash(), 0});
12751274
sig_data.tr_spenddata = builder.GetSpendData();

0 commit comments

Comments
 (0)