X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkeystore.h;h=7dc346435f0c988c8a8f40ec517e362e589351b4;hb=e5e4c598dc43bb5e01b3a30aaeb2dfc9376bd7b4;hp=32d7783bb9af516c8a13c8b1b5cf2fed1b025647;hpb=b032c4a33e27deebe9210347048998ecc4624ee4;p=novacoin.git diff --git a/src/keystore.h b/src/keystore.h index 32d7783..7dc3464 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -64,11 +64,15 @@ public: vchSecret = key.GetSecret(fCompressed); return true; } + + virtual bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const =0; + virtual bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const =0; }; typedef std::map > KeyMap; typedef std::map ScriptMap; typedef std::set WatchOnlySet; +typedef std::pair MalleableKeyPair; /** Basic key store, that keeps keys in an address->secret map */ class CBasicKeyStore : public CKeyStore @@ -77,6 +81,7 @@ protected: KeyMap mapKeys; ScriptMap mapScripts; WatchOnlySet setWatchOnly; + MalleableKeyPair malleableKeyPair; public: bool AddKey(const CKey& key); @@ -124,6 +129,26 @@ public: virtual bool RemoveWatchOnly(const CScript &dest); virtual bool HaveWatchOnly(const CScript &dest) const; virtual bool HaveWatchOnly() const; + + bool CheckOwnership(const CPubKey &pubKeyVariant, const CPubKey &R) const + { + bool result; + { + LOCK(cs_KeyStore); + result = const_cast(this)->malleableKeyPair.first.CheckKeyVariant(R, pubKeyVariant); + } + return result; + } + + bool CreatePrivKey(const CPubKey &pubKeyVariant, const CPubKey &R, CKey &privKey) const + { + bool result; + { + LOCK(cs_KeyStore); + result = const_cast(this)->malleableKeyPair.second.CheckKeyVariant(R, pubKeyVariant, privKey); + } + return result; + } }; typedef std::map > > CryptedKeyMap; @@ -152,9 +177,7 @@ protected: bool Unlock(const CKeyingMaterial& vMasterKeyIn); public: - CCryptoKeyStore() : fUseCrypto(false) - { - } + CCryptoKeyStore(); bool IsCrypted() const { @@ -185,7 +208,6 @@ public: return CBasicKeyStore::HaveKey(address); return mapCryptedKeys.count(address) > 0; } - return false; } bool GetKey(const CKeyID &address, CKey& keyOut) const; bool GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const;