Merge #12461: scripted-diff: Rename key size consts to be relative to their class

0580f86bb4 Fixup whitespace (Ben Woosley)
47101bbb27 scripted-diff: Rename CPubKey and CKey::*_KEY_SIZE and COMPRESSED_*_KEY_SIZE (Ben Woosley)

Pull request description:

  ~~And introduce CPubKeySig to host code relative to key sigs.~~

ACKs for top commit:
  meshcollider:
    utACK 0580f86bb4

Tree-SHA512: 29aa0be54912358b138e391b9db78639786f56580493e590ec9f773c0e1b421740133d05a79be247c7ee57e71c9c9e41b9cb54088cb3c0e3f813f74f0895287b
This commit is contained in:
Wladimir J. van der Laan
2019-11-20 12:30:33 +01:00
8 changed files with 45 additions and 45 deletions

View File

@@ -33,17 +33,17 @@ public:
/**
* secp256k1:
*/
static constexpr unsigned int PUBLIC_KEY_SIZE = 65;
static constexpr unsigned int COMPRESSED_PUBLIC_KEY_SIZE = 33;
static constexpr unsigned int SIGNATURE_SIZE = 72;
static constexpr unsigned int COMPACT_SIGNATURE_SIZE = 65;
static constexpr unsigned int SIZE = 65;
static constexpr unsigned int COMPRESSED_SIZE = 33;
static constexpr unsigned int SIGNATURE_SIZE = 72;
static constexpr unsigned int COMPACT_SIGNATURE_SIZE = 65;
/**
* see www.keylength.com
* script supports up to 75 for single byte push
*/
static_assert(
PUBLIC_KEY_SIZE >= COMPRESSED_PUBLIC_KEY_SIZE,
"COMPRESSED_PUBLIC_KEY_SIZE is larger than PUBLIC_KEY_SIZE");
SIZE >= COMPRESSED_SIZE,
"COMPRESSED_SIZE is larger than SIZE");
private:
@@ -51,15 +51,15 @@ private:
* Just store the serialized data.
* Its length can very cheaply be computed from the first byte.
*/
unsigned char vch[PUBLIC_KEY_SIZE];
unsigned char vch[SIZE];
//! Compute the length of a pubkey with a given first byte.
unsigned int static GetLen(unsigned char chHeader)
{
if (chHeader == 2 || chHeader == 3)
return COMPRESSED_PUBLIC_KEY_SIZE;
return COMPRESSED_SIZE;
if (chHeader == 4 || chHeader == 6 || chHeader == 7)
return PUBLIC_KEY_SIZE;
return SIZE;
return 0;
}
@@ -140,7 +140,7 @@ public:
void Unserialize(Stream& s)
{
unsigned int len = ::ReadCompactSize(s);
if (len <= PUBLIC_KEY_SIZE) {
if (len <= SIZE) {
s.read((char*)vch, len);
} else {
// invalid pubkey, skip available data
@@ -179,7 +179,7 @@ public:
//! Check whether this is a compressed public key.
bool IsCompressed() const
{
return size() == COMPRESSED_PUBLIC_KEY_SIZE;
return size() == COMPRESSED_SIZE;
}
/**