aboutsummaryrefslogtreecommitdiff
path: root/core/include/key.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-05-14 20:10:21 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-05-14 20:10:21 +0200
commit69d605f410c83235aa7b757445e7d0166fcfe2d9 (patch)
tree577e034f248830a2a6e118a80962286d0b0e49dd /core/include/key.h
parent2097c09a9b5dda5bfa0de1906a8c155c3c3b529b (diff)
downloadbitcoin-69d605f410c83235aa7b757445e7d0166fcfe2d9.tar.xz
integration of core bitcoin
Diffstat (limited to 'core/include/key.h')
-rw-r--r--core/include/key.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/include/key.h b/core/include/key.h
index 390602e1ef..c973d6eb82 100644
--- a/core/include/key.h
+++ b/core/include/key.h
@@ -4,6 +4,10 @@
#ifndef BITCOIN_KEY_H
#define BITCOIN_KEY_H
+#include <openssl/ec.h>
+#include <openssl/ecdsa.h>
+#include <openssl/obj_mac.h>
+
// secp160k1
// const unsigned int PRIVATE_KEY_SIZE = 192;
// const unsigned int PUBLIC_KEY_SIZE = 41;
@@ -110,7 +114,7 @@ public:
return vchPrivKey;
}
- bool SetPubKey(const vector<unsigned char>& vchPubKey)
+ bool SetPubKey(const std::vector<unsigned char>& vchPubKey)
{
const unsigned char* pbegin = &vchPubKey[0];
if (!o2i_ECPublicKey(&pkey, &pbegin, vchPubKey.size()))
@@ -119,19 +123,19 @@ public:
return true;
}
- vector<unsigned char> GetPubKey() const
+ std::vector<unsigned char> GetPubKey() const
{
unsigned int nSize = i2o_ECPublicKey(pkey, NULL);
if (!nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey failed");
- vector<unsigned char> vchPubKey(nSize, 0);
+ std::vector<unsigned char> vchPubKey(nSize, 0);
unsigned char* pbegin = &vchPubKey[0];
if (i2o_ECPublicKey(pkey, &pbegin) != nSize)
throw key_error("CKey::GetPubKey() : i2o_ECPublicKey returned unexpected size");
return vchPubKey;
}
- bool Sign(uint256 hash, vector<unsigned char>& vchSig)
+ bool Sign(uint256 hash, std::vector<unsigned char>& vchSig)
{
vchSig.clear();
unsigned char pchSig[10000];
@@ -143,7 +147,7 @@ public:
return true;
}
- bool Verify(uint256 hash, const vector<unsigned char>& vchSig)
+ bool Verify(uint256 hash, const std::vector<unsigned char>& vchSig)
{
// -1 = error, 0 = bad sig, 1 = good
if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1)
@@ -151,7 +155,7 @@ public:
return true;
}
- static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, vector<unsigned char>& vchSig)
+ static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, std::vector<unsigned char>& vchSig)
{
CKey key;
if (!key.SetPrivKey(vchPrivKey))
@@ -159,7 +163,7 @@ public:
return key.Sign(hash, vchSig);
}
- static bool Verify(const vector<unsigned char>& vchPubKey, uint256 hash, const vector<unsigned char>& vchSig)
+ static bool Verify(const std::vector<unsigned char>& vchPubKey, uint256 hash, const std::vector<unsigned char>& vchSig)
{
CKey key;
if (!key.SetPubKey(vchPubKey))