Scope the ECDSA constant sizes to CPubKey / CKey classes

This commit is contained in:
Jack Grigg
2017-10-04 14:41:40 +01:00
parent 1ce9f0a952
commit 63179d0283
4 changed files with 43 additions and 41 deletions

View File

@@ -14,18 +14,6 @@
#include <stdexcept>
#include <vector>
/**
* secp256k1:
*/
const unsigned int PUBLIC_KEY_SIZE = 65;
const unsigned int COMPRESSED_PUBLIC_KEY_SIZE = 33;
const unsigned int SIGNATURE_SIZE = 72;
const unsigned int COMPACT_SIGNATURE_SIZE = 65;
/**
* see www.keylength.com
* script supports up to 75 for single byte push
*/
const unsigned int BIP32_EXTKEY_SIZE = 74;
/** A reference to a CKey: the Hash160 of its serialized public key */
@@ -41,6 +29,22 @@ typedef uint256 ChainCode;
/** An encapsulated public key. */
class CPubKey
{
public:
/**
* secp256k1:
*/
static const unsigned int PUBLIC_KEY_SIZE = 65;
static const unsigned int COMPRESSED_PUBLIC_KEY_SIZE = 33;
static const unsigned int SIGNATURE_SIZE = 72;
static const 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");
private:
/**
@@ -48,9 +52,6 @@ private:
* Its length can very cheaply be computed from the first byte.
*/
unsigned char vch[PUBLIC_KEY_SIZE];
static_assert(
PUBLIC_KEY_SIZE >= COMPRESSED_PUBLIC_KEY_SIZE,
"COMPRESSED_PUBLIC_KEY_SIZE is larger than PUBLIC_KEY_SIZE");
//! Compute the length of a pubkey with a given first byte.
unsigned int static GetLen(unsigned char chHeader)