My friend forgot the password to his electrum wallet but knows that it's a 6 digit pin. I looked into it and from what I can find electrum uses the sha256(sha256(pin)) to generate the key used to encrypt the private key with AES in CBC mode. What I'm not sure about is whether or not it is feasible to crack this and I want to be sure before I attempt it.

  • 1
    $\begingroup$ Seems pretty trivial. testing the right private key will dominate the work, but it's still insignificant. $\endgroup$ Oct 30, 2017 at 23:17
  • 2
    $\begingroup$ trivial, under a second on a modern cpu $\endgroup$ Oct 30, 2017 at 23:40
  • $\begingroup$ I can hardly believe that an implementation of the electrum wallet does something that dumb to protect the PIN. $\endgroup$
    – fgrieu
    Nov 1, 2017 at 8:58

1 Answer 1


Yes, it is possible to do this. You can just try each and every PIN, decrypt and then verify the private key; i.e. try a brute force approach. If you don't know the format, the toughest thing will be to think of a way to verify that the result is indeed the private key.

With 6 digits there is a maximum of $10^6$, i.e. a million times SHA-256, SHA-256 and then AES decrypt to try. You can just test part of the encrypted private key but with a million options I would not even bother and simply decrypt the key.

You should be able to pipe the result of CBC decryption to the Posix file utility, if it results in anything but unknown data you probably have a private key to test. Beware that the ciphertext may be prefixed with an IV, although if the salt is missing I would be surprised if it was present.

  • $\begingroup$ Note that I don't know the electrum wallet myself, this is simply an answer given by the protocol description in the question. $\endgroup$
    – Maarten Bodewes
    Oct 31, 2017 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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