Class CredentialUtils

java.lang.Object
i5.las2peer.registry.CredentialUtils

public class CredentialUtils extends Object
Wraps Credentials with convenience methods.
  • 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 file
      password - password for decrypting private key in wallet
      Returns:
      credentials object (with decrypted private key)
      Throws:
      BadEthereumCredentialsException
    • fromPrivateKey

      public static org.web3j.crypto.Credentials fromPrivateKey(String privateKey)
      Derive credentials from private key.
      Parameters:
      privateKey - private key from which public key will be derived
    • fromMnemonic

      public static org.web3j.crypto.Credentials fromMnemonic(String mnemonic, String password)
      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

      public static String 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 encrypted
      directoryPath - directory in which the file will be created
      Returns:
      full path of the newly created wallet file
      Throws:
      IOException
      org.web3j.crypto.CipherException