MCPcopy Create free account
hub / github.com/ElementsProject/elements / CheckSignatureEncoding

Function CheckSignatureEncoding

src/script/interpreter.cpp:288–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror) {
289 // Empty signature. Not strictly DER encoded, but allowed to provide a
290 // compact way to provide an invalid signature for use with CHECK(MULTI)SIG
291 if (vchSig.size() == 0) {
292 return true;
293 }
294
295 bool no_hash_byte = (flags & SCRIPT_NO_SIGHASH_BYTE) == SCRIPT_NO_SIGHASH_BYTE;
296 std::vector<unsigned char> vchSigCopy(vchSig.begin(), vchSig.begin() + vchSig.size());
297 // Push a dummy sighash byte to pass checks
298 if (no_hash_byte) {
299 vchSigCopy.push_back(SIGHASH_ALL);
300 }
301
302 if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC)) != 0 && !IsValidSignatureEncoding(vchSigCopy)) {
303 return set_error(serror, SCRIPT_ERR_SIG_DER);
304 } else if ((flags & SCRIPT_VERIFY_LOW_S) != 0 && !IsLowDERSignature(vchSigCopy, serror)) {
305 // serror is set
306 return false;
307 } else if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsDefinedHashtypeSignature(vchSigCopy, flags)) {
308 return set_error(serror, SCRIPT_ERR_SIG_HASHTYPE);
309 }
310 return true;
311}
312
313bool static CheckPubKeyEncoding(const valtype &vchPubKey, unsigned int flags, const SigVersion &sigversion, ScriptError* serror) {
314 if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsCompressedOrUncompressedPubKey(vchPubKey)) {

Callers 3

ScriptToAsmStrFunction · 0.85
EvalChecksigPreTapscriptFunction · 0.85
EvalScriptFunction · 0.85

Calls 7

IsValidSignatureEncodingFunction · 0.85
IsLowDERSignatureFunction · 0.85
set_errorFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected