From 223bda1946df2c059714fb357092261e43b4f8bf Mon Sep 17 00:00:00 2001 From: furszy Date: Thu, 16 Sep 2021 20:09:00 -0300 Subject: [PATCH] key.cpp: Use PubKey constant size. --- src/key.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index 6f424c4eebeaa..afd533c9667dd 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -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 @@ -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); @@ -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)