X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkeystore.h;h=7dc346435f0c988c8a8f40ec517e362e589351b4;hb=e5e4c598dc43bb5e01b3a30aaeb2dfc9376bd7b4;hp=9573e3fbece1f0bd989ddbe994f99930864be78b;hpb=48564f02c4769f26295bedfc04b796246ad0d0bc;p=novacoin.git diff --git a/src/keystore.h b/src/keystore.h index 9573e3f..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; @@ -147,13 +172,12 @@ protected: // will encrypt previously unencrypted keys bool EncryptKeys(CKeyingMaterial& vMasterKeyIn); + bool DecryptKeys(const CKeyingMaterial& vMasterKeyIn); bool Unlock(const CKeyingMaterial& vMasterKeyIn); public: - CCryptoKeyStore() : fUseCrypto(false) - { - } + CCryptoKeyStore(); bool IsCrypted() const { @@ -184,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;