| 216 | } |
| 217 | |
| 218 | bool CCryptoKeyStore::GetKey(const CKeyID& keyid, CKey& keyOut, bool isMiner) const { |
| 219 | LOCK(cs_KeyStore); |
| 220 | |
| 221 | if (isMiner) |
| 222 | return CBasicKeyStore::GetKey(keyid, keyOut, isMiner); |
| 223 | |
| 224 | if (!IsEncrypted()) |
| 225 | return CBasicKeyStore::GetKey(keyid, keyOut); |
| 226 | |
| 227 | CryptedKeyMap::const_iterator mi = mapCryptedKeys.find(keyid); |
| 228 | if (mi != mapCryptedKeys.end()) { |
| 229 | const CPubKey& vchPubKey = (*mi).second.first; |
| 230 | const vector<unsigned char>& vchCryptedSecret = (*mi).second.second; |
| 231 | CKeyingMaterial vchSecret; |
| 232 | if (!DecryptSecret(vMasterKey, vchCryptedSecret, vchPubKey.GetHash(), vchSecret)) |
| 233 | return false; |
| 234 | if (vchSecret.size() != 32) |
| 235 | return false; |
| 236 | keyOut.Set(vchSecret.begin(), vchSecret.end(), vchPubKey.IsCompressed()); |
| 237 | return true; |
| 238 | } |
| 239 | |
| 240 | return false; |
| 241 | } |
| 242 | |
| 243 | bool CCryptoKeyStore::GetPubKey(const CKeyID& keyid, CPubKey& vchPubKeyOut, bool isMiner) const { |
| 244 | LOCK(cs_KeyStore); |