0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-05 10:17:30 -05:00
bitcoin-bitcoin-core/src/script
fanquake bd65a76b9d
Merge #21330: Deal with missing data in signature hashes more consistently
725d7ae049 Use PrecomputedTransactionData in signet check (Pieter Wuille)
497718b467 Treat amount<0 also as missing data for P2WPKH/P2WSH (Pieter Wuille)
3820090bd6 Make all SignatureChecker explicit about missing data (Pieter Wuille)
b77b0cc507 Add MissingDataBehavior and make TransactionSignatureChecker handle it (Pieter Wuille)

Pull request description:

  Currently we have 2 levels of potentially-missing data in the transaction signature hashes:
  * P2WPKH/P2WSH hashes need the spent amount
  * P2TR hashes need all spent outputs (amount + scriptPubKey)

  Missing amounts are treated as -1 (thus leading to unexpected signature failures), while missing outputs in P2TR validation cause assertion failure. This is hard to extend for signing support, and also quite ugly in general.

  In this PR, an explicit configuration option to {Mutable,}TransactionSignatureChecker is added (MissingDataBehavior enum class) to either select ASSERT_FAIL or FAIL. Validation code passes ASSERT_FAIL (as at validation time all data should always be passed, and anything else is a serious bug in the code), while signing code uses FAIL.

  The existence of the ASSERT_FAIL option is really just an abundance of caution. Always using FAIL should be just fine, but if there were for some reason a code path in consensus code was introduced that misses certain data, I think we prefer as assertion failure over silently introducing a consensus change.

  Potentially useful follow-ups (not for this PR, in my preference):
  * Having an explicit script validation error code for missing data.
  * Having a MissingDataBehavior::SUCCEED option as well, for use in script/sign.cpp DataFromTransaction (if a signature is present in a witness, and we don't have enough data to fully validate it, we should probably treat it as valid and not touch it).

ACKs for top commit:
  sanket1729:
    reACK 725d7ae049
  Sjors:
    ACK 725d7ae049
  achow101:
    re-ACK 725d7ae049
  benthecarman:
    ACK 725d7ae049
  fjahr:
    Code review ACK 725d7ae049

Tree-SHA512: d67dc51bae9ca7ef6eb9acccefd682529f397830f77d74cd305500a081ef55aede0e9fa380648c3a8dd4857aa7eeb1ab54fe808979d79db0784ac94ceb31b657
2021-04-13 10:24:31 +08:00
..
bitcoinconsensus.cpp Make all SignatureChecker explicit about missing data 2021-03-15 17:29:39 -07:00
bitcoinconsensus.h build: test for __declspec(dllexport) in configure 2021-02-12 09:04:16 +08:00
descriptor.cpp refactor: post Optional<> removal cleanups 2021-03-17 14:56:20 +08:00
descriptor.h refactor: post Optional<> removal cleanups 2021-03-17 14:56:20 +08:00
interpreter.cpp Treat amount<0 also as missing data for P2WPKH/P2WSH 2021-03-15 17:29:39 -07:00
interpreter.h Merge #21330: Deal with missing data in signature hashes more consistently 2021-04-13 10:24:31 +08:00
keyorigin.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
script.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
script.h Implement Tapscript script validation rules (BIP 342) 2020-10-12 17:18:24 -07:00
script_error.cpp Implement Tapscript script validation rules (BIP 342) 2020-10-12 17:18:24 -07:00
script_error.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
sigcache.cpp refactor: replace Boost shared_mutex with std shared_mutex in sigcache 2021-02-02 12:38:10 +08:00
sigcache.h Make all SignatureChecker explicit about missing data 2021-03-15 17:29:39 -07:00
sign.cpp Merge #21330: Deal with missing data in signature hashes more consistently 2021-04-13 10:24:31 +08:00
sign.h Support for Schnorr signatures and integration in SignatureCheckers (BIP 340) 2020-10-12 17:15:40 -07:00
signingprovider.cpp Replace boost::variant with std::variant 2021-01-05 10:10:50 +01:00
signingprovider.h wallet: Improve LegacyScriptPubKeyMan::CanProvide script recognition 2020-02-12 11:48:30 -05:00
standard.cpp rpc: deprecate addresses and reqSigs from rpc outputs 2021-03-23 10:51:43 -04:00
standard.h rpc: deprecate addresses and reqSigs from rpc outputs 2021-03-23 10:51:43 -04:00