Skip to content

Instantly share code, notes, and snippets.

@jorpic
Created July 3, 2015 13:55
Show Gist options
  • Save jorpic/8309201f0781e703c767 to your computer and use it in GitHub Desktop.
Save jorpic/8309201f0781e703c767 to your computer and use it in GitHub Desktop.
Check password for ethereum wallet
#!/usr/bin/env python
# ref. http://bitcoin.stackexchange.com/questions/30727
# partially copy-pasted from https://github.com/ethereum/pyethsaletool
import pbkdf2 as PBKDF2
import python_sha3
import aes
import sys
import json
from bitcoin import *
def sha3(x):
return python_sha3.sha3_256(x).digest()
def pbkdf2(x):
return PBKDF2._pbkdf2(x, x, 2000)[:16]
def secure_privtopub(priv):
if len(priv) == 64:
return secure_privtopub(priv.decode('hex')).encode('hex')
if openssl:
k = openssl.CKey()
k.generate(priv)
return k.get_pubkey()
def eth_privtoaddr(priv):
pub = encode_pubkey(secure_privtopub(priv), 'bin_electrum')
return sha3(pub)[12:].encode('hex')
def ethaddr(encseed, pwd):
seed = aes.decryptData(pwd, encseed.decode('hex'))
priv = sha3(seed)
return secure_privtopub(priv.decode('hex')).encode('hex')
wallet_file = sys.argv[1]
password = sys.argv[2]
pwd_key = pbkdf2(password)
with open(wallet_file) as f:
wallet = json.load(f)
encseed = wallet['encseed']
try:
print ethaddr(encseed, pwd_key)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment