mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Introduce a no sighash byte signature check flag for blocks and other sig modes
This commit is contained in:
parent
cc7cbb6c48
commit
0108dacf56
2 changed files with 12 additions and 0 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue