Package org.web3j.crypto
Class Wallet
- java.lang.Object
-
- org.web3j.crypto.Wallet
-
public class Wallet extends java.lang.Object
Ethereum wallet file management. For reference, refer to Web3 Secret Storage Definition or the Go Ethereum client implementation.Note: the Bouncy Castle Scrypt implementation
SCrypt
, fails to comply with the following Ethereum reference Scrypt test vector:// Only value of r that cost (as an int) could be exceeded for is 1 if (r == 1 && N_STANDARD > 65536) { throw new IllegalArgumentException("Cost parameter N_STANDARD must be > 1 and < 65536."); }
-
-
Constructor Summary
Constructors Constructor Description Wallet()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static WalletFile
create(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair, int n, int p)
Creates a walletstatic WalletFile
createLight(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair)
Creates a light walletstatic WalletFile
createStandard(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair)
Creates a standard walletstatic org.web3j.crypto.ECKeyPair
decrypt(java.lang.String password, WalletFile walletFile)
Decrypts a wallet file
-
-
-
Method Detail
-
create
public static WalletFile create(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair, int n, int p) throws org.web3j.crypto.CipherException
Creates a wallet- Parameters:
password
- Will be used for both wallet encryption and passphrase for BIP-39 seedecKeyPair
- Elliptic Curve SECP-256k1 generated key pair- Returns:
- A wallet
- Throws:
org.web3j.crypto.CipherException
- if the underlying cipher is not available
-
createStandard
public static WalletFile createStandard(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair) throws org.web3j.crypto.CipherException
Creates a standard wallet- Parameters:
password
- Will be used for both wallet encryption and passphrase for BIP-39 seedecKeyPair
- Elliptic Curve SECP-256k1 generated key pair- Returns:
- A standard wallet
- Throws:
org.web3j.crypto.CipherException
- if the underlying cipher is not available
-
createLight
public static WalletFile createLight(java.lang.String password, org.web3j.crypto.ECKeyPair ecKeyPair) throws org.web3j.crypto.CipherException
Creates a light wallet- Parameters:
password
- Will be used for both wallet encryption and passphrase for BIP-39 seedecKeyPair
- Elliptic Curve SECP-256k1 generated key pair- Returns:
- A light wallet
- Throws:
org.web3j.crypto.CipherException
- if the underlying cipher is not available
-
decrypt
public static org.web3j.crypto.ECKeyPair decrypt(java.lang.String password, WalletFile walletFile) throws org.web3j.crypto.CipherException
Decrypts a wallet file- Parameters:
password
- Wallet passwordwalletFile
- Wallet to decript- Returns:
- Elliptic Curve SECP-256k1 generated key pair
- Throws:
org.web3j.crypto.CipherException
- if the underlying cipher is not available
-
-