简体   繁体   中英

Web3J - Creation of Light Wallet takes too long

I am creating the wallet in my Android app, using the library Web3j: https://web3j.io/

See the code:

String seed = UUID.randomUUID().toString();
ECKeyPair exKey = Keys.createEcKeyPair();

WalletFile wallet = Wallet.createLight(seed,exKey);

It is creating the Wallet properly, the problem is that the process takes long time, around 10 minutes.

Am I doing something wrong?

Is there another way to make it faster?

You should be creating a wallet this way:

try {
    ECKeyPair ecKeyPair = Keys.createEcKeyPair();
    BigInteger privateKeyInDec = ecKeyPair.getPrivateKey();
    String sPrivatekeyInHex = privateKeyInDec.toString(16);

    WalletFile aWallet = Wallet.createLight(UUID.randomUUID().toString(), ecKeyPair);
    String sAddress = aWallet.getAddress();
} catch (CipherException e | InvalidAlgorithmParameterException e | NoSuchAlgorithmException e | NoSuchProviderException e) {
    //
}

To generate the wallet I change the method:

WalletFile wallet = Wallet.createLight(String seed, ECKeyPair exKey);

For the following method:

WalletFile wallet = Wallet.create(String seed,ECKeyPair exKey, int n, int p);

Which is much more faster than the createLight (It was 10 minutes, and now is few second).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM