Skip to content

Commit 08010b8

Browse files
committed
test: fix failing schnorr sig creation in bip341_keypath_test_vectors
1 parent 47dff66 commit 08010b8

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/test/script_tests.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
#include <univalue.h>
3535

36+
using namespace std;
37+
3638
// Uncomment if you want to output updated JSON tests.
3739
// #define UPDATE_JSON_TESTS
3840

@@ -1756,6 +1758,7 @@ BOOST_AUTO_TEST_CASE(script_assets_test)
17561758
file.close();
17571759
}
17581760

1761+
// ELEMENTS: TODO: Some of these test vectors need updating
17591762
BOOST_AUTO_TEST_CASE(bip341_keypath_test_vectors)
17601763
{
17611764
UniValue tests;
@@ -1777,9 +1780,14 @@ BOOST_AUTO_TEST_CASE(bip341_keypath_test_vectors)
17771780

17781781
PrecomputedTransactionData txdata;
17791782
txdata.Init(tx, std::vector<CTxOut>{utxos}, true);
1783+
// ELEMENTS: add a txout witness for each output
1784+
for (u_int i = 0; i < (u_int)utxos.size(); i++) {
1785+
tx.witness.vtxoutwit.emplace_back(CTxOutWitness());
1786+
}
17801787

17811788
BOOST_CHECK(txdata.m_bip341_taproot_ready);
1782-
// BOOST_CHECK_EQUAL(HexStr(txdata.m_spent_amounts_single_hash), vec["intermediary"]["hashAmounts"].get_str());
1789+
// ELEMENTS: FIXME
1790+
//BOOST_CHECK_EQUAL(HexStr(txdata.m_spent_amounts_single_hash), vec["intermediary"]["hashAmounts"].get_str());
17831791
BOOST_CHECK_EQUAL(HexStr(txdata.m_outputs_single_hash), vec["intermediary"]["hashOutputs"].get_str());
17841792
BOOST_CHECK_EQUAL(HexStr(txdata.m_prevouts_single_hash), vec["intermediary"]["hashPrevouts"].get_str());
17851793
BOOST_CHECK_EQUAL(HexStr(txdata.m_spent_scripts_single_hash), vec["intermediary"]["hashScriptPubkeys"].get_str());
@@ -1809,22 +1817,24 @@ BOOST_AUTO_TEST_CASE(bip341_keypath_test_vectors)
18091817
provider.keys[key.GetPubKey().GetID()] = key;
18101818
MutableTransactionSignatureCreator creator(&tx, txinpos, utxos[txinpos].nValue, &txdata, hashtype);
18111819
std::vector<unsigned char> signature;
1820+
BOOST_CHECK(creator.CreateSchnorrSig(provider, signature, pubkey, nullptr, &merkle_root, SigVersion::TAPROOT));
18121821
// ELEMENTS: FIXME
1813-
// BOOST_CHECK(creator.CreateSchnorrSig(provider, signature, pubkey, nullptr, &merkle_root, SigVersion::TAPROOT));
1814-
// BOOST_CHECK_EQUAL(HexStr(signature), input["expected"]["witness"][0].get_str());
1822+
//BOOST_CHECK_EQUAL(HexStr(signature), input["expected"]["witness"][0].get_str());
18151823

18161824
// We can't observe the tweak used inside the signing logic, so verify by recomputing it.
1817-
// BOOST_CHECK_EQUAL(HexStr(pubkey.ComputeTapTweakHash(merkle_root.IsNull() ? nullptr : &merkle_root)), input["intermediary"]["tweak"].get_str());
1825+
// ELEMENTS: FIXME
1826+
//BOOST_CHECK_EQUAL(HexStr(pubkey.ComputeTapTweakHash(merkle_root.IsNull() ? nullptr : &merkle_root)), input["intermediary"]["tweak"].get_str());
18181827

18191828
// We can't observe the sighash used inside the signing logic, so verify by recomputing it.
18201829
ScriptExecutionData sed;
18211830
sed.m_annex_init = true;
18221831
sed.m_annex_present = false;
1823-
// uint256 sighash;
1824-
// BOOST_CHECK(SignatureHashSchnorr(sighash, sed, tx, txinpos, hashtype, SigVersion::TAPROOT, txdata, MissingDataBehavior::FAIL));
1832+
uint256 sighash;
1833+
BOOST_CHECK(SignatureHashSchnorr(sighash, sed, tx, txinpos, hashtype, SigVersion::TAPROOT, txdata, MissingDataBehavior::FAIL));
18251834
// BOOST_CHECK_EQUAL(HexStr(sighash), input["intermediary"]["sigHash"].get_str());
18261835

18271836
// To verify the sigmsg, hash the expected sigmsg, and compare it with the (expected) sighash.
1837+
// ELEMENTS: FIXME
18281838
//BOOST_CHECK_EQUAL(HexStr((CHashWriter(HASHER_TAPSIGHASH_ELEMENTS) << Span{ParseHex(input["intermediary"]["sigMsg"].get_str())}).GetSHA256()), input["intermediary"]["sigHash"].get_str());
18291839
}
18301840

0 commit comments

Comments
 (0)