mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Scope the ECDSA constant sizes to CPubKey / CKey classes
This commit is contained in:
31
src/pubkey.h
31
src/pubkey.h
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user