0 and 128 were previously accepted as standard hash type.
Note that this function is not active in the current verification code.
0 and 128 were previously accepted as standard hash type.
Note that this function is not active in the current verification code.
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/87b83f97f3c3293ee1950fa646d3857426625cb4 for binaries and test log.
Is the specification of the format signatures follow easily available? I assume it's an RFC or the like somewhere, (as well as whatever defines ASN-encoding) but what one? It'd be helpful if IsCanonicalSignature() had a comment directing people to what standard (and part of the standard) we're trying to try to check against. The forum link goes into more detail of course, but it's still not clear as to what standard exactly we're talking about.
I mean, normally it's fine leaving this stuff as "to be understood", but script.cpp is one of the most important things defining what is or isn't Bitcoin, and I'm sure there are a lot of people reading it and trying to understand it in detail. Making that easier to do doesn't hurt.
0 and 128 were previously accepted as standard hash type.
Note that this function is not active in the current verification
code.
277 | @@ -278,7 +278,8 @@ bool IsCanonicalSignature(const valtype &vchSig) { 278 | return error("Non-canonical signature: too short"); 279 | if (vchSig.size() > 73) 280 | return error("Non-canonical signature: too long"); 281 | - if (vchSig[vchSig.size() - 1] & 0x7C) 282 | + unsigned char nHashType = vchSig[vchSig.size() - 1] & 0x7F; 283 | + if (nHashType < 1 || nHashType > 3)
Nit: how about: if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE)
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/bffc744444c19e25c60c8df999beb83192f96a8a for binaries and test log.
@petertodd Good idea. I'll try to add some references in comments soon.