aboutsummaryrefslogtreecommitdiff
path: root/src/key.h
diff options
context:
space:
mode:
authorJack Grigg <jack@z.cash>2017-10-04 14:41:40 +0100
committerJack Grigg <jack@z.cash>2017-10-04 14:41:40 +0100
commit63179d028347bf3e32c7ea61386df4c44307b4a7 (patch)
tree13f96bb1dc55d166f3a9ec3a43aca14e3e923313 /src/key.h
parent1ce9f0a952a3d5d9442ad8251da898d96209c16c (diff)
Scope the ECDSA constant sizes to CPubKey / CKey classes
Diffstat (limited to 'src/key.h')
-rw-r--r--src/key.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/key.h b/src/key.h
index dc7b941f42..14024e6ec0 100644
--- a/src/key.h
+++ b/src/key.h
@@ -17,16 +17,6 @@
/**
- * secp256k1:
- */
-const unsigned int PRIVATE_KEY_SIZE = 279;
-const unsigned int COMPRESSED_PRIVATE_KEY_SIZE = 214;
-/**
- * see www.keylength.com
- * script supports up to 75 for single byte push
- */
-
-/**
* secure_allocator is defined in allocators.h
* CPrivKey is a serialized private key, with all parameters included
* (PRIVATE_KEY_SIZE bytes)
@@ -36,6 +26,20 @@ typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;
/** An encapsulated private key. */
class CKey
{
+public:
+ /**
+ * secp256k1:
+ */
+ static const unsigned int PRIVATE_KEY_SIZE = 279;
+ static const unsigned int COMPRESSED_PRIVATE_KEY_SIZE = 214;
+ /**
+ * see www.keylength.com
+ * script supports up to 75 for single byte push
+ */
+ static_assert(
+ PRIVATE_KEY_SIZE >= COMPRESSED_PRIVATE_KEY_SIZE,
+ "COMPRESSED_PRIVATE_KEY_SIZE is larger than PRIVATE_KEY_SIZE");
+
private:
//! Whether this private key is valid. We check for correctness when modifying the key
//! data, so fValid should always correspond to the actual state.