mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Dynafed blocks must have sighash byte
It is not included in the signature hash. The sighash byte MUST be SIGHASH_ALL to avoid malleability.
This commit is contained in:
parent
4afb69f994
commit
8d043f37af
5 changed files with 46 additions and 18 deletions
|
|
@ -21,12 +21,15 @@ bool CheckChallenge(const CBlockHeader& block, const CBlockIndex& indexLast, con
|
|||
|
||||
static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_block_signature_size, const CScript& challenge, const CScript& scriptSig, const CScriptWitness& witness)
|
||||
{
|
||||
// scriptSig or witness will be nonempty, but not both, so just compare both limits
|
||||
if (scriptSig.size() > max_block_signature_size) {
|
||||
return false;
|
||||
}
|
||||
// Legacy blocks have empty witness, dynafed blocks have empty scriptSig
|
||||
bool is_dyna = !witness.stack.empty();
|
||||
|
||||
if (witness.GetSerializedSize() > max_block_signature_size) {
|
||||
// Check signature limits for blocks
|
||||
if (scriptSig.size() > max_block_signature_size) {
|
||||
assert(!is_dyna);
|
||||
return false;
|
||||
} else if (witness.GetSerializedSize() > max_block_signature_size) {
|
||||
assert(is_dyna);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +43,7 @@ static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_bloc
|
|||
| SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only
|
||||
| SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling
|
||||
| SCRIPT_VERIFY_WITNESS // Witness and to enforce cleanstack
|
||||
| SCRIPT_NO_SIGHASH_BYTE; // non-Check(Multi)Sig signatures will not have sighash byte
|
||||
| (is_dyna ? 0 : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
|
||||
return GenericVerifyScript(scriptSig, witness, challenge, proof_flags, block);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue