MCPcopy Create free account
hub / github.com/Bitcoin-ABC/bitcoin-abc / CheckRawECDSASignatureEncoding

Function CheckRawECDSASignatureEncoding

src/script/sigencoding.cpp:160–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160static bool CheckRawECDSASignatureEncoding(const slicedvaltype &sig,
161 uint32_t flags,
162 ScriptError *serror) {
163 if (IsSchnorrSig(sig)) {
164 // In an ECDSA-only context, 64-byte signatures are forbidden.
165 return set_error(serror, ScriptError::SIG_BADLENGTH);
166 }
167 // https://bitcoin.stackexchange.com/a/12556:
168 if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S |
169 SCRIPT_VERIFY_STRICTENC)) &&
170 !IsValidDERSignatureEncoding(sig)) {
171 return set_error(serror, ScriptError::SIG_DER);
172 }
173 // If the S value is above the order of the curve divided by two, its
174 // complement modulo the order could have been used instead, which is
175 // one byte shorter when encoded correctly.
176 if ((flags & SCRIPT_VERIFY_LOW_S) && !CPubKey::CheckLowS(sig)) {
177 return set_error(serror, ScriptError::SIG_HIGH_S);
178 }
179
180 return true;
181}
182
183static bool CheckRawSchnorrSignatureEncoding(const slicedvaltype &sig,
184 uint32_t flags,

Calls 3

IsSchnorrSigFunction · 0.85
set_errorFunction · 0.70

Tested by

no test coverage detected