Package i5.las2peer.registry
Class CredentialUtils
java.lang.Object
i5.las2peer.registry.CredentialUtils
Wraps
Credentials
with convenience methods.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Create new BIP39 mnemonic string using secure randomness.static String
createWallet
(String password, String directoryPath) Create wallet file and return its path.static org.web3j.crypto.Credentials
fromMnemonic
(String mnemonic, String password) Derive credentials from BIP39 mnemonic and password.static org.web3j.crypto.Credentials
fromPrivateKey
(String privateKey) Derive credentials from private key.static org.web3j.crypto.Credentials
fromWallet
(String walletFilePath, String password) Derive credentials from password-protected wallet file.
-
Constructor Details
-
CredentialUtils
public CredentialUtils()
-
-
Method Details
-
fromWallet
public static org.web3j.crypto.Credentials fromWallet(String walletFilePath, String password) throws BadEthereumCredentialsException Derive credentials from password-protected wallet file.- Parameters:
walletFilePath
- path to standard JSON Ethereum wallet filepassword
- password for decrypting private key in wallet- Returns:
- credentials object (with decrypted private key)
- Throws:
BadEthereumCredentialsException
-
fromPrivateKey
Derive credentials from private key.- Parameters:
privateKey
- private key from which public key will be derived
-
fromMnemonic
Derive credentials from BIP39 mnemonic and password.- Parameters:
mnemonic
- string of words. As defined in BIP-0039, this wallet seed determines a key pair.password
- password added to the key generation process- Returns:
- credentials object (with decrypted private key)
- See Also:
-
createMnemonic
Create new BIP39 mnemonic string using secure randomness.- Returns:
- string of words. Can be used to deterministically generate a key pair.
-
createWallet
public static String createWallet(String password, String directoryPath) throws IOException, org.web3j.crypto.CipherException Create wallet file and return its path.- Parameters:
password
- password with which the private key is encrypteddirectoryPath
- directory in which the file will be created- Returns:
- full path of the newly created wallet file
- Throws:
IOException
org.web3j.crypto.CipherException
-