Skip to content

Commit

Permalink
key.cpp: Use PubKey constant size.
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Sep 16, 2021
1 parent 0c6f95d commit 223bda1
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ void CKey::MakeNewKey(bool fCompressedIn)
uint256 CKey::GetPrivKey_256()
{
void* key = keydata.data();
uint256* key_256 = (uint256*)key;

return *key_256;
return *(uint256*)key;
}

CPrivKey CKey::GetPrivKey() const
Expand All @@ -189,8 +187,8 @@ CPubKey CKey::GetPubKey() const
{
assert(fValid);
secp256k1_pubkey pubkey;
size_t clen = CPubKey::PUBLIC_KEY_SIZE;
CPubKey result;
size_t clen = 65;
int ret = secp256k1_ec_pubkey_create(secp256k1_context_sign, &pubkey, begin());
assert(ret);
secp256k1_ec_pubkey_serialize(secp256k1_context_sign, (unsigned char*)result.begin(), &clen, &pubkey, fCompressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);
Expand Down Expand Up @@ -280,13 +278,13 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
return ret;
}

bool CExtKey::Derive(CExtKey& out, unsigned int nChild) const
bool CExtKey::Derive(CExtKey& out, unsigned int _nChild) const
{
out.nDepth = nDepth + 1;
CKeyID id = key.GetPubKey().GetID();
memcpy(&out.vchFingerprint[0], &id, 4);
out.nChild = nChild;
return key.Derive(out.key, out.chaincode, nChild, chaincode);
out.nChild = _nChild;
return key.Derive(out.key, out.chaincode, _nChild, chaincode);
}

void CExtKey::SetSeed(const unsigned char* seed, unsigned int nSeedLen)
Expand Down

0 comments on commit 223bda1

Please sign in to comment.