1

I'm used ./geth command line for create address with command

./geth account new

and put password.

and after that system create keystore file.

  1. how to decrypt keystore file with my password for get privacy key with linux command line.
  2. i don't want to use myetherwallet.com

thank you for advanced.

user179549
  • 31
  • 2

1 Answers1

1

This can be done with web3py in python.

with open('path to you keyfile') as keyfile:
    encrypted_key = keyfile.read()
    private_key = web3.Account.decrypt(encrypted_key, 'your keyfile password')

Hope this helps

Jaime
  • 8,340
  • 1
  • 12
  • 20
  • 1
    Today, in year 2022: 'web3py' is 'web3'. Still, with corresponding corrections, "AttributeError: module 'web3.eth' has no attribute 'account'". Apparently, web3py is not quite web3. – Van Jone May 05 '22 at 17:53
  • @VanJone I've edited the answer now... probably 500ish days too late – import-antigravity Oct 17 '23 at 23:07
  • @import-antigravity Interesting. Back in 2022, I had to create an under-the-hood implementation dealing directly with hashes, keccak, AES, MAC checks and other crypto niceties using corresponding Py modules. It took lots of trial-n-error debugging before I've made sure that the raw key extracted from my real life ETH hash really works and is accepted by the network. Today I've tried again your corrected web3 way and am surprised it gave me different outcome to the same file and same pw. I see it checks MAC too, so does decrypt but now I cannot understand what the type of result it produces??? – Van Jone Oct 21 '23 at 14:40
  • @VanJone Are you sure you are inputting a keystore v3 JSON? Cabn you compare the contents to the list in this example: https://web3js.readthedocs.io/en/v1.2.11/web3-eth-accounts.html#decrypt – import-antigravity Oct 24 '23 at 09:23