I'm trying to debug an app that at some point needs to create a password protected account. When I reach that point in my code using pycharm's debugger it takes forever to generate an account protected by a four character password.

The code is:

new_account = accounts.Account.new(password, priv_key, path)

where all fields are not None. Is there a way to debug faster?

  • Have you tried other clients? geth, parity? – Afr Jun 14 '16 at 13:16
  • 2
    I'm limited to using pyethapp because at the moment it is the only client supporting programmable hooks (I need to make a syscall once a transaction has been confirmed) – Sebi Jun 14 '16 at 13:22
  • @Sebi: What platform/OS are you running on? – jimkberry Jun 16 '16 at 14:10
  • @jimkberry Debian 8.3, Jessie, x64 – Sebi Jun 16 '16 at 19:25

Account generation is slow by design.

Part of the account generation process involves scrypt or pbkdf2, password hashing algorithms that are designed to be slow in order to mitigate brute force attacks on your private keys.

If you look here in the pyethereum source you can see the parameters that are used for each of these hash functions. Both use a work factor/iteration count of 262114 or 2**18 which should translate to something between 1-3 seconds of hashing depending on how old your hardware is.

  • In python it's more like 3 or 4 minutes, perhaps even more. Even so, once an attacker has your account only strong (60+ random & non-ASCII character) passwords will keep it safe, regardless of the hashing algorithms involved (at least in practical scenarios). This approach is uselessly slow, at least in my opinion. – Sebi Jun 16 '16 at 21:06
  • Have you profiled the code and why it's so slow. I suspect that the slowness of the hashing algorithms isn't what your seeing but rather something different. Possibly your IDE is doing something that's adding significant overhead to the process? – Piper Merriam Jun 16 '16 at 21:14
  • Yes, too many rounds of hmac-sha256. I've run it both inside the IDE (pycharm) and also, separately, from bash. The latter is faster but not by much (at least 2 or 3 minutes per account generation). – Sebi Jun 16 '16 at 21:26
  • can you try this code and see how long it takes? from ethereum import keys; keys.make_keystore_json(keys.sha3('cow'), 'abcd'). I'm seeing 22 second generation times. – Piper Merriam Jun 16 '16 at 22:52
  • It take ~4 minutes per run. I have rebuild pyethereum and decreased the constant 1000 times. – Sebi Jun 17 '16 at 9:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.