ethereum / eth-keyfile

Tools for handling the encrypted keyfile format used to store private keys.
MIT License
79 stars 49 forks source link

Question about Scrypt Default Parameter #39

Closed darwintree closed 11 months ago

darwintree commented 1 year ago

What was wrong?

Currently, when using scrypt as kdf, as shown in https://github.com/ethereum/eth-keyfile/blob/master/eth_keyfile/keyfile.py#L87

SCRYPT_R = 1
SCRYPT_P = 8

are used as default parameter. But is it a typo as here is the suggestion from pycryptodome

    A good choice of parameters *(N, r , p)* was suggested
    by Colin Percival in his `presentation in 2009`__:
    - *( 2¹⁴, 8, 1 )* for interactive logins (≤100ms)
    - *( 2²⁰, 8, 1 )* for file encryption (≤5s)

How can it be fixed?

Change

SCRYPT_R = 1
SCRYPT_P = 8

to

SCRYPT_R = 8
SCRYPT_P = 1
usd-yamazaki commented 1 year ago

Error: Scrypt: N must be larger than 1, a power of 2, less than 2^(128 * r / 8) and less than 2^32

Currently, due to this issue, keys encrypted with web3py cannot be decrypted with ethersjs. I'm in trouble...