web3j icon indicating copy to clipboard operation
web3j copied to clipboard

Improving account import

Open fraspadafora opened this issue 10 years ago • 3 comments

I saw that you are using the Java Scrypt library to calculate the derived key. I noticed that is not that fast and I found that the Bouncy Castle implementation is better. Here is the class and method that you can call.

org.bouncycastle.crypto.generators.SCrypt.generate(...)

Hope this can improve the Web3j library.

fraspadafora avatar Nov 19 '16 11:11 fraspadafora

I started off using the Bouncy Castle Scrypt implementation, however migrated to the Java Scrypt library as per the following comments in the Wallet implementation.

Note: we don't use the Bouncy Castle Scrypt implementation org.bouncycastle.crypto.generators.SCrypt, as the following parameter assertion results in failure of the Ethereum reference Scrypt test vector:

  // Only value of r that cost (as an int) could be exceeded for is 1
  if (r == 1 && N > 65536)
  {
      throw new IllegalArgumentException("Cost parameter N must be > 1 and < 65536.");
  }

conor10 avatar Nov 20 '16 23:11 conor10

Oh I didn't know that, I used Bouncy Castle and I have never received that error because my test accounts have r = 8 and N = 262144.

fraspadafora avatar Nov 21 '16 13:11 fraspadafora

Closing, as for the time being I want to ensure that web3j remains compliant with the Scrypt test vector.

conor10 avatar Nov 21 '16 21:11 conor10