Changeset View
Changeset View
Standalone View
Standalone View
src/pubkey.h
Show All 30 Lines | |||||
class CKeyID : public uint160 { | class CKeyID : public uint160 { | ||||
public: | public: | ||||
CKeyID() : uint160() {} | CKeyID() : uint160() {} | ||||
explicit CKeyID(const uint160 &in) : uint160(in) {} | explicit CKeyID(const uint160 &in) : uint160(in) {} | ||||
}; | }; | ||||
typedef uint256 ChainCode; | typedef uint256 ChainCode; | ||||
/** An encapsulated public key. */ | /** An encapsulated secp256k1 public key. */ | ||||
class CPubKey { | class CPubKey { | ||||
private: | private: | ||||
/** | /** | ||||
* Just store the serialized data. | * Just store the serialized data. | ||||
* Its length can very cheaply be computed from the first byte. | * Its length can very cheaply be computed from the first byte. | ||||
*/ | */ | ||||
uint8_t vch[65]; | uint8_t vch[65]; | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | public: | ||||
//! fully validate whether this is a valid public key (more expensive than | //! fully validate whether this is a valid public key (more expensive than | ||||
//! IsValid()) | //! IsValid()) | ||||
bool IsFullyValid() const; | bool IsFullyValid() const; | ||||
//! Check whether this is a compressed public key. | //! Check whether this is a compressed public key. | ||||
bool IsCompressed() const { return size() == 33; } | bool IsCompressed() const { return size() == 33; } | ||||
/** | /** | ||||
* Verify a DER signature (~72 bytes). | * Verify a DER-serialized ECDSA 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 VerifyECDSA(const uint256 &hash, | ||||
const std::vector<uint8_t> &vchSig) const; | |||||
/** | /** | ||||
* Check whether a signature is normalized (lower-S). | * Check whether a DER-serialized ECDSA signature is normalized (lower-S). | ||||
*/ | */ | ||||
static bool | static bool | ||||
CheckLowS(const boost::sliced_range<const std::vector<uint8_t>> &vchSig); | CheckLowS(const boost::sliced_range<const std::vector<uint8_t>> &vchSig); | ||||
static bool CheckLowS(const std::vector<uint8_t> &vchSig) { | static bool CheckLowS(const std::vector<uint8_t> &vchSig) { | ||||
return CheckLowS(vchSig | boost::adaptors::sliced(0, vchSig.size())); | return CheckLowS(vchSig | boost::adaptors::sliced(0, vchSig.size())); | ||||
} | } | ||||
//! Recover a public key from a compact signature. | //! Recover a public key from a compact ECDSA 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(); | ||||
//! Derive BIP32 child pubkey. | //! Derive BIP32 child pubkey. | ||||
bool Derive(CPubKey &pubkeyChild, ChainCode &ccChild, unsigned int nChild, | bool Derive(CPubKey &pubkeyChild, ChainCode &ccChild, unsigned int nChild, | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |