Changeset View
Changeset View
Standalone View
Standalone View
src/script/sigencoding.h
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Copyright (c) 2017-2018 The Bitcoin developers | // Copyright (c) 2017-2018 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_SCRIPT_SIGENCODING_H | #ifndef BITCOIN_SCRIPT_SIGENCODING_H | ||||
#define BITCOIN_SCRIPT_SIGENCODING_H | #define BITCOIN_SCRIPT_SIGENCODING_H | ||||
#include "script_error.h" | #include "script_error.h" | ||||
#include "script_flags.h" | |||||
#include "sighashtype.h" | #include "sighashtype.h" | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <vector> | #include <vector> | ||||
typedef std::vector<uint8_t> valtype; | typedef std::vector<uint8_t> valtype; | ||||
namespace { | namespace { | ||||
inline SigHashType GetHashType(const valtype &vchSig) { | inline SigHashType GetHashType(const valtype &vchSig) { | ||||
if (vchSig.size() == 0) { | if (vchSig.size() == 0) { | ||||
return SigHashType(0); | return SigHashType(0); | ||||
} | } | ||||
return SigHashType(vchSig[vchSig.size() - 1]); | return SigHashType(vchSig[vchSig.size() - 1]); | ||||
} | } | ||||
} // namespace | } // namespace | ||||
/* | |||||
* Test whether a given signature (without its hashtype byte) should be | |||||
* classified as a Schnorr signature. | |||||
*/ | |||||
inline bool IsSchnorrSignature(const valtype &vchSig, uint32_t flags) { | |||||
return (flags & SCRIPT_ENABLE_SCHNORR) && (vchSig.size() == 64); | |||||
} | |||||
/** | /** | ||||
* Check that the signature provided on some data is properly encoded. | * Check that the signature provided on some data is properly encoded. | ||||
* Signatures passed to OP_CHECKDATASIG and its verify variant must be checked | * Signatures passed to OP_CHECKDATASIG and its verify variant must be checked | ||||
* using this function. | * using this function. | ||||
*/ | */ | ||||
bool CheckDataSignatureEncoding(const valtype &vchSig, uint32_t flags, | bool CheckDataSignatureEncoding(const valtype &vchSig, uint32_t flags, | ||||
ScriptError *serror); | ScriptError *serror); | ||||
Show All 15 Lines |