ethereum / aleth

Aleth – Ethereum C++ client, tools and libraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Race condition in key manager

tzubcic-tolar opened this issue · comments

KeyPair KeyManager::newKeyPair(KeyManager::NewKeyType _type)

There are multiple issues with this method:

  • KeyPair p = KeyPair::create(); -- this value is completely ignored
  • If NewKeyType::NoVanity is set, starting threads is pointless and a waste of resources, the p mentioned above can be simply returned immediately.
  • Last, but most important: this is not thread safe. You can end up returning an invalid KeyPair (i.e. where public key does not match private key).

Until this is fixed, I suggest using KeyPair::create() directly instead of KeyManager::newKeyPair.

Personally, I would not use the key related code for anything. This is barely maintained for long time.
We can integrate a fix if you want to propose one.