mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-21 14:22:38 +02:00
tests, fuzz: use new NUMS_H const
This commit is contained in:
parent
b946f8a4c5
commit
9408a04e42
@ -309,9 +309,6 @@ const struct KeyComparator {
|
||||
// A dummy scriptsig to pass to VerifyScript (we always use Segwit v0).
|
||||
const CScript DUMMY_SCRIPTSIG;
|
||||
|
||||
//! Public key to be used as internal key for dummy Taproot spends.
|
||||
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
|
||||
|
||||
//! Construct a miniscript node as a shared_ptr.
|
||||
template<typename... Args> NodeRef MakeNodeRef(Args&&... args) {
|
||||
return miniscript::MakeNodeRef<CPubKey>(miniscript::internal::NoDupCheck{}, std::forward<Args>(args)...);
|
||||
@ -1018,7 +1015,7 @@ CScript ScriptPubKey(MsCtx ctx, const CScript& script, TaprootBuilder& builder)
|
||||
|
||||
// For Taproot outputs we always use a tree with a single script and a dummy internal key.
|
||||
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
|
||||
builder.Finalize(XOnlyPubKey{NUMS_PK});
|
||||
builder.Finalize(XOnlyPubKey::NUMS_H);
|
||||
return GetScriptForDestination(builder.GetOutput());
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <common/system.h>
|
||||
#include <key_io.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <test/util/random.h>
|
||||
#include <test/util/setup_common.h>
|
||||
@ -364,4 +365,13 @@ BOOST_AUTO_TEST_CASE(key_ellswift)
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(bip341_test_h)
|
||||
{
|
||||
std::vector<unsigned char> G_uncompressed = ParseHex("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8");
|
||||
HashWriter hw;
|
||||
hw.write(MakeByteSpan(G_uncompressed));
|
||||
XOnlyPubKey H{hw.GetSHA256()};
|
||||
BOOST_CHECK(XOnlyPubKey::NUMS_H == H);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
@ -288,9 +288,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
//! Public key to be used as internal key for dummy Taproot spends.
|
||||
const std::vector<unsigned char> NUMS_PK{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
|
||||
|
||||
using Fragment = miniscript::Fragment;
|
||||
using NodeRef = miniscript::NodeRef<CPubKey>;
|
||||
using miniscript::operator"" _mst;
|
||||
@ -330,7 +327,7 @@ CScript ScriptPubKey(miniscript::MiniscriptContext ctx, const CScript& script, T
|
||||
|
||||
// For Taproot outputs we always use a tree with a single script and a dummy internal key.
|
||||
builder.Add(0, script, TAPROOT_LEAF_TAPSCRIPT);
|
||||
builder.Finalize(XOnlyPubKey{NUMS_PK});
|
||||
builder.Finalize(XOnlyPubKey::NUMS_H);
|
||||
return GetScriptForDestination(builder.GetOutput());
|
||||
}
|
||||
|
||||
|
@ -1268,8 +1268,7 @@ BOOST_AUTO_TEST_CASE(sign_invalid_miniscript)
|
||||
const auto invalid_pubkey{ParseHex("173d36c8c9c9c9ffffffffffff0200000000021e1e37373721361818181818181e1e1e1e19000000000000000000b19292929292926b006c9b9b9292")};
|
||||
TaprootBuilder builder;
|
||||
builder.Add(0, {invalid_pubkey}, 0xc0);
|
||||
XOnlyPubKey nums{ParseHex("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0")};
|
||||
builder.Finalize(nums);
|
||||
builder.Finalize(XOnlyPubKey::NUMS_H);
|
||||
prev.vout.emplace_back(0, GetScriptForDestination(builder.GetOutput()));
|
||||
curr.vin.emplace_back(COutPoint{prev.GetHash(), 0});
|
||||
sig_data.tr_spenddata = builder.GetSpendData();
|
||||
|
Loading…
x
Reference in New Issue
Block a user