aboutsummaryrefslogtreecommitdiff
path: root/src/key.cpp
diff options
context:
space:
mode:
authorgeekwisdom <[email protected]>2021-05-20 07:24:54 -0300
committerRoss Nicoll <[email protected]>2021-07-25 19:32:23 +0100
commitc7a1b7c90cd6981321924991d7bd05f77a3cc7db (patch)
tree4154255d908aea27914c24f6b0e2a67abca7f21e /src/key.cpp
parentMerge pull request #1941 from elybin/fixing-indonesian-translation (diff)
downloaddiscoin-c7a1b7c90cd6981321924991d7bd05f77a3cc7db.tar.xz
discoin-c7a1b7c90cd6981321924991d7bd05f77a3cc7db.zip
Trivial: Fix Magic Numbers in key and pubkey - fixes #1968
Diffstat (limited to 'src/key.cpp')
-rw-r--r--src/key.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/key.cpp b/src/key.cpp
index 36ed4abb1..48c885c76 100644
--- a/src/key.cpp
+++ b/src/key.cpp
@@ -86,7 +86,7 @@ static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *pr
memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin);
memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
- pubkeylen = 33;
+ pubkeylen = CPubKey::COMPRESSED_SIZE;
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRESSED);
ptr += pubkeylen;
*privkeylen = ptr - privkey;
@@ -111,7 +111,7 @@ static int ec_privkey_export_der(const secp256k1_context *ctx, unsigned char *pr
memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin);
memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
- pubkeylen = 65;
+ pubkeylen = CPubKey::SIZE;
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMPRESSED);
ptr += pubkeylen;
*privkeylen = ptr - privkey;
@@ -155,7 +155,7 @@ CPrivKey CKey::GetPrivKey() const {
CPubKey CKey::GetPubKey() const {
assert(fValid);
secp256k1_pubkey pubkey;
- size_t clen = 65;
+ size_t clen = CPubKey::SIZE;
CPubKey result;
int ret = secp256k1_ec_pubkey_create(secp256k1_context_sign, &pubkey, begin());
assert(ret);
@@ -227,7 +227,7 @@ bool CKey::Derive(CKey& keyChild, ChainCode &ccChild, unsigned int nChild, const
std::vector<unsigned char, secure_allocator<unsigned char>> vout(64);
if ((nChild >> 31) == 0) {
CPubKey pubkey = GetPubKey();
- assert(pubkey.begin() + 33 == pubkey.end());
+ assert(pubkey.begin() + CPubKey::COMPRESSED_SIZE == pubkey.end());
BIP32Hash(cc, nChild, *pubkey.begin(), pubkey.begin()+1, vout.data());
} else {
assert(begin() + 32 == end());