 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
26 if (!
key.Verify(hash, vchSig))
34 if (vchSig.size() != 65)
36 int recid = (vchSig[0] - 27) & 3;
37 bool fComp = ((vchSig[0] - 27) & 4) != 0;
42 assert((
int)
size() == pubkeylen);
45 if (!
key.Recover(hash, &vchSig[1], recid))
47 std::vector<unsigned char> pubkey;
49 Set(pubkey.begin(), pubkey.end());
59 if (!secp256k1_ecdsa_pubkey_verify(
begin(),
size()))
75 int ret = secp256k1_ecdsa_pubkey_decompress((
unsigned char*)
begin(), &clen);
77 assert(clen == (
int)
size());
82 std::vector<unsigned char> pubkey;
84 Set(pubkey.begin(), pubkey.end());
89 bool CPubKey::Derive(
CPubKey& pubkeyChild,
unsigned char ccChild[32],
unsigned int nChild,
const unsigned char cc[32])
const
92 assert((nChild >> 31) == 0);
94 unsigned char out[64];
96 memcpy(ccChild, out + 32, 32);
99 bool ret = secp256k1_ecdsa_pubkey_tweak_add((
unsigned char*)pubkeyChild.
begin(), pubkeyChild.
size(), out);
103 ret &=
key.TweakPublic(out);
104 std::vector<unsigned char> pubkey;
106 pubkeyChild.
Set(pubkey.begin(), pubkey.end());
115 code[5] = (
nChild >> 24) & 0xFF;
116 code[6] = (
nChild >> 16) & 0xFF;
117 code[7] = (
nChild >> 8) & 0xFF;
118 code[8] = (
nChild >> 0) & 0xFF;
128 nChild = (code[5] << 24) | (code[6] << 16) | (code[7] << 8) | code[8];
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
unsigned int size() const
void * memcpy(void *a, const void *b, size_t c)
bool Decompress()
Turn this public key into an uncompressed public key.
A reference to a CKey: the Hash160 of its serialized public key.
bool Derive(CExtPubKey &out, unsigned int nChild) const
const unsigned char * begin() const
SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover_compact(const unsigned char *msg, int msglen, const unsigned char *sig64, unsigned char *pubkey, int *pubkeylen, int compressed, int recid) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5)
Recover an ECDSA public key from a compact signature.
RAII Wrapper around OpenSSL's EC_KEY.
unsigned char vchFingerprint[4]
bool Verify(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
Verify a DER signature (~72 bytes).
const unsigned char * end() const
unsigned char vchChainCode[32]
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
256-bit unsigned big integer.
SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const unsigned char *msg, int msglen, const unsigned char *sig, int siglen, const unsigned char *pubkey, int pubkeylen) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(5)
Verify an ECDSA signature.
CPubKey GetPubKey() const
Compute the public key from a private key.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
bool Derive(CPubKey &pubkeyChild, unsigned char ccChild[32], unsigned int nChild, const unsigned char cc[32]) const
Derive BIP32 child pubkey.
void Decode(const unsigned char code[74])
void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
An encapsulated public key.
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
void Encode(unsigned char code[74]) const