Changeset View
Changeset View
Standalone View
Standalone View
src/pubkey.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 | ||||
// 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_PUBKEY_H | #ifndef BITCOIN_PUBKEY_H | ||||
#define BITCOIN_PUBKEY_H | #define BITCOIN_PUBKEY_H | ||||
#include "hash.h" | #include "hash.h" | ||||
#include "serialize.h" | #include "serialize.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include <boost/range/adaptor/sliced.hpp> | |||||
#include <stdexcept> | #include <stdexcept> | ||||
#include <vector> | #include <vector> | ||||
/** | /** | ||||
* secp256k1: | * secp256k1: | ||||
* const unsigned int PRIVATE_KEY_SIZE = 279; | * const unsigned int PRIVATE_KEY_SIZE = 279; | ||||
* const unsigned int PUBLIC_KEY_SIZE = 65; | * const unsigned int PUBLIC_KEY_SIZE = 65; | ||||
* const unsigned int SIGNATURE_SIZE = 72; | * const unsigned int SIGNATURE_SIZE = 72; | ||||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Lines | public: | ||||
* Verify a DER signature (~72 bytes). | * Verify a DER signature (~72 bytes). | ||||
* If this public key is not fully valid, the return value will be false. | * If this public key is not fully valid, the return value will be false. | ||||
*/ | */ | ||||
bool Verify(const uint256 &hash, const std::vector<uint8_t> &vchSig) const; | bool Verify(const uint256 &hash, const std::vector<uint8_t> &vchSig) const; | ||||
/** | /** | ||||
* Check whether a signature is normalized (lower-S). | * Check whether a signature is normalized (lower-S). | ||||
*/ | */ | ||||
static bool CheckLowS(const std::vector<uint8_t> &vchSig); | static bool | ||||
CheckLowS(const boost::sliced_range<const std::vector<uint8_t>> &vchSig); | |||||
static bool CheckLowS(const std::vector<uint8_t> &vchSig) { | |||||
return CheckLowS(vchSig | boost::adaptors::sliced(0, vchSig.size())); | |||||
} | |||||
//! Recover a public key from a compact signature. | //! Recover a public key from a compact signature. | ||||
bool RecoverCompact(const uint256 &hash, | bool RecoverCompact(const uint256 &hash, | ||||
const std::vector<uint8_t> &vchSig); | const std::vector<uint8_t> &vchSig); | ||||
//! Turn this public key into an uncompressed public key. | //! Turn this public key into an uncompressed public key. | ||||
bool Decompress(); | bool Decompress(); | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |