Changeset View
Changeset View
Standalone View
Standalone View
src/script/sigencoding.cpp
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | return CheckTransactionSignatureEncodingImpl( | ||||
ScriptError *templateSerror) { | ScriptError *templateSerror) { | ||||
return CheckRawSchnorrSignatureEncoding(templateSig, templateFlags, | return CheckRawSchnorrSignatureEncoding(templateSig, templateFlags, | ||||
templateSerror); | templateSerror); | ||||
}); | }); | ||||
} | } | ||||
static bool IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { | static bool IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { | ||||
switch (vchPubKey.size()) { | switch (vchPubKey.size()) { | ||||
case 33: | case CPubKey::COMPRESSED_PUBLIC_KEY_SIZE: | ||||
// Compressed public key: must start with 0x02 or 0x03. | // Compressed public key: must start with 0x02 or 0x03. | ||||
return vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03; | return vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03; | ||||
case 65: | case CPubKey::PUBLIC_KEY_SIZE: | ||||
// Non-compressed public key: must start with 0x04. | // Non-compressed public key: must start with 0x04. | ||||
return vchPubKey[0] == 0x04; | return vchPubKey[0] == 0x04; | ||||
default: | default: | ||||
// Non-canonical public key: invalid size. | // Non-canonical public key: invalid size. | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
static bool IsCompressedPubKey(const valtype &vchPubKey) { | static bool IsCompressedPubKey(const valtype &vchPubKey) { | ||||
if (vchPubKey.size() != 33) { | if (vchPubKey.size() != CPubKey::COMPRESSED_PUBLIC_KEY_SIZE) { | ||||
// Non-canonical public key: invalid length for compressed key | // Non-canonical public key: invalid length for compressed key | ||||
return false; | return false; | ||||
} | } | ||||
if (vchPubKey[0] != 0x02 && vchPubKey[0] != 0x03) { | if (vchPubKey[0] != 0x02 && vchPubKey[0] != 0x03) { | ||||
// Non-canonical public key: invalid prefix for compressed key | // Non-canonical public key: invalid prefix for compressed key | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
Show All 16 Lines |