Description
New algorithm: Ethereum Scrypt
Use: Currently in use by Ethereum wallets to secure the wallet encryption password.
The algorithm design is explained very well here: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
The page does not go quite into the same detail regarding the Scrypt variant, however it is almost identical to the PBKDF2 variant, with Scrypt in place for the initial password hashing.
To summarize, the password is hashed with Scrypt, then the "second leftmost 16 bytes" of the derived hash are concatenated with the ciphertext, which is then hashed with SHA3-256. The SHA3-256 hash is then directly compared to the "mac" value to verify whether or not the password is correct. If the SHA3 hashes match, the password is correct and the decryption of the ciphertext/wallet proceeds.
The page linked above includes this example of a valid wallet:password pair:
Test Vectors
Details:
- Address:
008aeeda4d805471df9b2a5b0f38a0c3bcba786b
- ICAP:
XE542A5PZHH8PYIZUBEJEO0MFWRAPPIL67
- UUID:
3198bc9c-6672-5ab3-d9954942343ae5b6
- Password:
testpassword
- Secret:
7a28b5ba57c53603b0b07b56bba752f7784bf506fa95edc395f5cf6c7514fe9d
Scrypt
Test vector using AES-128-CTR and Scrypt:
{
"crypto" : {
"cipher" : "aes-128-ctr",
"cipherparams" : {
"iv" : "83dbcc02d8ccb40e466191a123791e0e"
},
"ciphertext" : "d172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c",
"kdf" : "scrypt",
"kdfparams" : {
"dklen" : 32,
"n" : 262144,
"r" : 1,
"p" : 8,
"salt" : "ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19"
},
"mac" : "2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097"
},
"id" : "3198bc9c-6672-5ab3-d995-4942343ae5b6",
"version" : 3
}
Intermediates:
- Derived key:
fac192ceb5fd772906bea3e118a69e8bbb5cc24229e20d8766fd298291bba6bd
- MAC Body
bb5cc24229e20d8766fd298291bba6bdd172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c
- MAC:
2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097
- Cipher key:
fac192ceb5fd772906bea3e118a69e8b
I have written ether2hashcat to extract the relevant information from the json blobs and present it in a proposed hash format for hashcat. The proposed format would be as follows:
$ethereum$s*n*r*p*salt*mac*ciphertext
Using the example data from the test wallet above, we would get the following hash:
$ethereum$s*262144*1*8*ab0c7876052600dd703518d6fc3fe8984592145b591fc8fb5c6d43190334ba19*2103ac29920d71da29f15d75b4a16dbe95cfd7ff8faea1056c33131d846e3097*d172bf743a674da9cdad04534d56926ef8358534d458fffccd4e6ad2fbde479c
This would be cracked as testpassword
Because there are multiple KDF variations, one using PBKDF2 and one using Scrypt, the format includes a P or S to denote the different versions. The PBKDF2 variant is addressed in a separate issue, as it is technically a different algorithm.
Both algorithms were previously discussed on this forum thread and example code for cracking both algorithms was written by @philsmd
This was previously requested in issue #262, however that issue/request did not seem to be completed with the required information.
The sister algorithm request for the PBKDF2 variant is issue #1227
Activity
ethtester commentedon Apr 28, 2017
Hello Chick3nman, does this also work with Mist created keystores?
Chick3nman commentedon Apr 29, 2017
@ethtester from what I can find regarding MIST wallets, the keystore seemingly shares the same format as Geth wallets and therefore both this algorithm as well as my extract script should work on MIST wallets as well. If you have a MIST wallet on hand that I could look at that would be helpful as I do not have one and can't seem to confirm 100% what the format of the JSON is and if it's compatible with ether2hashcat.
kholia commentedon Apr 30, 2017
@Chick3nman
The first asterisk character in the output hash
$ether$*s*262144*...
is a mistake and should be removed. This historical mistake started with mypdf2john
output hash format. Instead the output hash should be$ether$s*262144*...
(no starting stray asterisk character).I would like to use the full name
ethereum
instead ofether
in the output hash format. I don't see any advantages of using the potentially ambiguous short name.ethtester commentedon May 1, 2017
Hello Chick3nman,
Here are a couple of test wallets generated from Mist 0.3.9 and myetherwallet. I'm currently using a password cracker called ethcracker. https://github.com/lexansoft/ethcracker This tool can only test 2 passwords per second on Mist created wallets, but will do about 180 plus passwords per second on myetherwallet.com created wallets. I think it has some to do with the "n" iterations value being much higher in Mist. Would be great if we could leverage hashcat to speed things up. Thank You.
Test wallet passwords = password123
testkeys.zip
Chick3nman commentedon May 1, 2017
@kholia I was simply following the format of other extracted hashes however I do agree with the change. I will edit my extract script and both issues to reflect the corrected format.
@ethtester those wallets look directly compatible as they follow the same format.
kholia commentedon May 1, 2017
@Chick3nman Thank you! My hash extraction script can be seen at openwall/john#2525.
Chick3nman commentedon May 1, 2017
@kholia awesome, would you like me to push yours as the main extract script instead of https://github.com/Chick3nman/ether2hashcat.py/blob/master/ether2hashcat.py ? Mine is a lot less clean than yours, plus no error handling.
kholia commentedon May 1, 2017
@Chick3nman Sure. I think that having one "standard" extraction script is a better option overall. Thanks.
Chick3nman commentedon May 1, 2017
Perfect, I'll edit both issues to refer to your script and will use it as the extract script from now on
ethtester commentedon May 2, 2017
Hello Chick3nman,
Correct me if I'm wrong, hashcat will require an update to add a new hash mode before we can use the hash format you listed above, right?
Chick3nman commentedon May 2, 2017
@ethtester Correct, hashcat will need to have the modes written and added to use them, this is simply a request to have them added.
ethtester commentedon May 12, 2017
How long does it usually take for new modes to be coded after the initial request?
32 remaining items