12#include <boost/range/adaptor/sliced.hpp>
40 if (
sig.size() < 8 ||
sig.size() > 72) {
57 if (
sig[1] !=
sig.size() - 2) {
71 const uint32_t lenR =
sig[3];
91 if (lenR > (
sig.size() - 7)) {
101 if (lenR > 1 && (
sig[4] == 0x00) && !(
sig[5] & 0x80)) {
115 const uint32_t startS = lenR + 4;
118 if (
sig[startS] != 0x02) {
123 const uint32_t lenS =
sig[startS + 1];
131 if (
sig[startS + 2] & 0x80) {
139 if (
size_t(startS + lenS + 2) !=
sig.size()) {
149 if (lenS > 1 && (
sig[startS + 2] == 0x00) && !(
sig[startS + 3] & 0x80)) {
157 return sig.size() == 64;
206 if (vchSig.size() == 0) {
211 vchSig | boost::adaptors::sliced(0, vchSig.size()),
flags, serror);
217 if (!GetHashType(vchSig).isDefined()) {
221 bool usesForkId = GetHashType(vchSig).hasForkId();
223 if (!forkIdEnabled && usesForkId) {
227 if (forkIdEnabled && !usesForkId) {
241 if (vchSig.size() == 0) {
245 if (!fun(vchSig | boost::adaptors::sliced(0, vchSig.size() - 1),
flags,
257 vchSig,
flags, serror,
269 vchSig,
flags, serror,
281 vchSig,
flags, serror,
290 switch (vchPubKey.size()) {
293 return vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03;
297 return vchPubKey[0] == 0x04;
static constexpr unsigned int COMPRESSED_SIZE
static constexpr unsigned int SIZE
secp256k1:
static bool CheckLowS(const boost::sliced_range< const std::vector< uint8_t > > &vchSig)
Check whether a DER-serialized ECDSA signature is normalized (lower-S).
@ SCRIPT_VERIFY_STRICTENC
@ SCRIPT_ENABLE_SIGHASH_FORKID
bool CheckTransactionSchnorrSignatureEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
Check that the signature provided to authentify a transaction is properly encoded Schnorr signature (...
bool CheckDataSignatureEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
Check that the signature provided on some data is properly encoded.
static bool CheckTransactionSignatureEncodingImpl(const valtype &vchSig, uint32_t flags, ScriptError *serror, F fun)
static bool CheckRawSignatureEncoding(const slicedvaltype &sig, uint32_t flags, ScriptError *serror)
bool CheckTransactionECDSASignatureEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
Check that the signature provided to authentify a transaction is properly encoded ECDSA signature.
static bool IsValidDERSignatureEncoding(const slicedvaltype &sig)
A canonical signature exists of: <30> <total len> <02> <len R> <R> <02> <len S> , where R and S are n...
static bool CheckRawECDSASignatureEncoding(const slicedvaltype &sig, uint32_t flags, ScriptError *serror)
static bool IsCompressedOrUncompressedPubKey(const valtype &vchPubKey)
static bool IsSchnorrSig(const slicedvaltype &sig)
bool CheckTransactionSignatureEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
Check that the signature provided to authentify a transaction is properly encoded.
static bool CheckSighashEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
bool CheckPubKeyEncoding(const valtype &vchPubKey, uint32_t flags, ScriptError *serror)
Check that a public key is encoded properly.
boost::sliced_range< const valtype > slicedvaltype
static bool CheckRawSchnorrSignatureEncoding(const slicedvaltype &sig, uint32_t flags, ScriptError *serror)
std::vector< uint8_t > valtype