question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keystore generated by ethers.js takes time to unlock vs Parity keystore is quick

See original GitHub issue

Also raised #11571 in openethereum.

Keystore generated by parity account new:

Parity Keystore
{"id":"d24503a6-8847-199e-fa5e-cf2859e48bb6","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"88decf833914efe2897083b3b2400ab0"},"ciphertext":"472d8a51e054374463d016c682102649d8cf56dfbd6cbfa4f04e849e9e30f5d2","kdf":"pbkdf2","kdfparams":{"c":10240,"dklen":32,"prf":"hmac-sha256","salt":"3923cf5f23f653b79ca71134fd974a001bb6adf608fa7020c1f9f345f741c26d"},"mac":"4789351f22f0d74f937699b7579e4786890fdb5b89884583ca8dd2d56bb969dc"},"address":"36560493644fbb79f1c38d12ff096f7ec5d333b7","name":"","meta":"{}"}

Keystore generated using ethers.js library:

Custom keystore (generated using ethers.js):
{"id":"f786d469-b7ef-4dce-9a19-d67437c1f4dc","version":3,"crypto":{"cipher":"aes-128-ctr","cipherparams":{"iv":"88c0756012bb0e104a19472e1dfebd13"},"ciphertext":"6e1df9d2866b8e2fe126f45d0f371035facebee8e7c1d06605b3d7bb81403144","kdf":"scrypt","kdfparams":{"dklen":32,"p":1,"n":131072,"r":8,"salt":"9b63e8032242bf78c9a0aeaabd2f05fb75a34851472056a46b20352ca57516ef"},"mac":"0928b53c317cca2252ff4b60c7ef2b6b2a3d9a47783e5c33beecdb56d7862aca"},"address":"c8e1f3b9a0cdfcef9ffd2343b943989a22517b26","name":"","meta":"{}"}

The password for both keystores is “12” exclusive of inverted commas. If you try unlocking both keystores, the parity keystore is unlocked quickly while Ethers.js keystore takes lot of time to get unlocked.

When I load the custom keystore in the keys folder, and start parity with unlock flag followed by wallet address (0xc8e1f3b9a0cdfcef9ffd2343b943989a22517b26) it takes a while for parity to first load up

2020-03-16 10:14:36 UTC Starting Parity-Ethereum/v2.7.2-unstable-55c90d401-20200205/x86_64-unknown-linux-gnu/rustc1.39.0
2020-03-16 10:14:36 UTC Keys path /tmp/parity0/keys/Era_Swap_Network
2020-03-16 10:14:36 UTC DB path /tmp/parity0/chains/Era_Swap_Network/db/54aabb10bc00d84f
2020-03-16 10:14:36 UTC State DB configuration: fast
2020-03-16 10:14:36 UTC Operating mode: active
2020-03-16 10:15:21 UTC Not preparing block; cannot sign.

You can see about 45 seconds to unlock the keystore.

But when I use a keystore generated by parity account new (0x36560493644fbb79f1c38d12ff096f7ec5d333b7), the unlock is very quick…

Starting Parity-Ethereum/v2.7.2-unstable-55c90d401-20200205/x86_64-unknown-linux-gnu/rustc1.39.0
2020-03-16 10:16:01 UTC Keys path /tmp/parity0/keys/Era_Swap_Network
2020-03-16 10:16:01 UTC DB path /tmp/parity0/chains/Era_Swap_Network/db/54aabb10bc00d84f
2020-03-16 10:16:01 UTC State DB configuration: fast
2020-03-16 10:16:01 UTC Operating mode: active
2020-03-16 10:16:01 UTC Not preparing block; cannot sign.

Due to the time taken for unlocking the keystore, the node wasn’t able to author any block using the slow keystore. And it gets stuck on the block which has it’s turn to author.

I tried hard to spot the difference in both keystores, only saw that the quick keystore had the kdfparams including c property while the slower one didn’t have.

Is there a way to generate a fast unlocking keystore like the one parity generates?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
zemsecommented, Mar 22, 2020

Opps! my bad…

> await checkTime(64);
Object { encrypting: 0.072, decrypting: 0.599 }

It’s a quick keystore. I’ll make sure that it has a very difficult password when using this, since in my use case password won’t be entered again and again.

0reactions
ricmoocommented, Mar 22, 2020

You aren’t changing the N; look more closely at the example, { scrypt: { N: 64 } }. You are using { N: 64 }. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Ethers.js
By timing how long the code took to execute, they now know whether garbage collection occured and therefore whether the simple or complex...
Read more >
Accounts — ethers.js 4.0.0 documentation
HOME, '.ethereum', 'keystore'); // Parity (use the name of your chain for chainDirectory, such as "homestead") //var dirname = path.join(process.env.
Read more >
How to unlock all accounts or unlock an account forever under ...
I want to use an account to make some transactions at the same time. So I need to unlock this account each time...
Read more >
Ethereum - Security and wallets - Thomas Clowes
MyEtherWallet does not generate a key store file for usage with Mist or Parity (I am not sure why..) and as such I...
Read more >
Getting Started as an Ethereum Web Developer - Medium
The X (i.e. whatever web3 API function you want) can be found here. Step 3: Write some smart contracts. I'll save you some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found