X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkey.h;h=8b033a029f017e74f979721d85f9cc20709a3742;hb=4664aae3fe2eba4eec84d20f1e7e701ceeeb49bd;hp=c0fce18bf3c5e62a15b1554c701ae9ba4b1393e9;hpb=acd6501610817eee0bd1c8ea9c591f043affbaec;p=novacoin.git diff --git a/src/key.h b/src/key.h index c0fce18..8b033a0 100644 --- a/src/key.h +++ b/src/key.h @@ -1,13 +1,21 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_KEY_H #define BITCOIN_KEY_H +#include +#include + #include #include #include +#include "serialize.h" +#include "uint256.h" +#include "base58.h" + // secp160k1 // const unsigned int PRIVATE_KEY_SIZE = 192; // const unsigned int PUBLIC_KEY_SIZE = 41; @@ -221,20 +229,20 @@ public: return true; } - static bool Sign(const CPrivKey& vchPrivKey, uint256 hash, std::vector& vchSig) + CBitcoinAddress GetAddress() const { - CKey key; - if (!key.SetPrivKey(vchPrivKey)) - return false; - return key.Sign(hash, vchSig); + return CBitcoinAddress(GetPubKey()); } - static bool Verify(const std::vector& vchPubKey, uint256 hash, const std::vector& vchSig) + bool IsValid() { - CKey key; - if (!key.SetPubKey(vchPubKey)) + if (!fSet) return false; - return key.Verify(hash, vchSig); + + CSecret secret = GetSecret(); + CKey key2; + key2.SetSecret(secret); + return GetPubKey() == key2.GetPubKey(); } };