Introduce a no sighash byte signature check flag for blocks and other sig modes

This commit is contained in:
Gregory Sanders 2018-10-29 14:39:13 -04:00
parent cc7cbb6c48
commit 0108dacf56
2 changed files with 12 additions and 0 deletions

View file

@ -203,6 +203,14 @@ bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned i
if (vchSig.size() == 0) {
return true;
}
bool no_hash_byte = (flags & SCRIPT_NO_SIGHASH_BYTE) == SCRIPT_NO_SIGHASH_BYTE;
std::vector<unsigned char> vchSigCopy(vchSig.begin(), vchSig.begin() + vchSig.size());
// Push a dummy sighash byte to pass checks
if (no_hash_byte) {
vchSigCopy.push_back(SIGHASH_ALL);
}
if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC)) != 0 && !IsValidSignatureEncoding(vchSig)) {
return set_error(serror, SCRIPT_ERR_SIG_DER);
} else if ((flags & SCRIPT_VERIFY_LOW_S) != 0 && !IsLowDERSignature(vchSig, serror)) {

View file

@ -115,6 +115,10 @@ enum
// Making OP_CODESEPARATOR and FindAndDelete fail any non-segwit scripts
//
SCRIPT_VERIFY_CONST_SCRIPTCODE = (1U << 16),
// Signature checking assumes no sighash byte after the DER signature
//
SCRIPT_NO_SIGHASH_BYTE = (1U << 17),
};
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror);