Class KeyWallet

  • All Implemented Interfaces:
    Wallet

    public class KeyWallet
    extends java.lang.Object
    implements Wallet
    An implementation of Wallet which uses of the key pair.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static KeyWallet create()
      Creates a new KeyWallet with generating a new key pair.
      Address getAddress()
      Gets the address corresponding the key of the wallet
      Bytes getPrivateKey()
      Gets the private key
      Bytes getPublicKey()  
      static KeyWallet load​(Bytes privateKey)
      Loads a key wallet from the private key
      static KeyWallet load​(java.lang.String password, java.io.File file)
      Loads a key wallet from the KeyStore file
      byte[] sign​(byte[] data)
      Signs the data to generate a signature
      static java.lang.String store​(KeyWallet wallet, java.lang.String password, java.io.File destinationDirectory)
      Stores the KeyWallet as a KeyStore
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • load

        public static KeyWallet load​(Bytes privateKey)
        Loads a key wallet from the private key
        Parameters:
        privateKey - the private key to load
        Returns:
        KeyWallet
      • create

        public static KeyWallet create()
                                throws java.security.InvalidAlgorithmParameterException,
                                       java.security.NoSuchAlgorithmException,
                                       java.security.NoSuchProviderException
        Creates a new KeyWallet with generating a new key pair.
        Returns:
        new KeyWallet
        Throws:
        java.security.InvalidAlgorithmParameterException
        java.security.NoSuchAlgorithmException
        java.security.NoSuchProviderException
      • load

        public static KeyWallet load​(java.lang.String password,
                                     java.io.File file)
                              throws java.io.IOException,
                                     KeystoreException
        Loads a key wallet from the KeyStore file
        Parameters:
        password - the password of KeyStore
        file - the KeyStore file
        Returns:
        KeyWallet
        Throws:
        java.io.IOException
        KeystoreException
      • store

        public static java.lang.String store​(KeyWallet wallet,
                                             java.lang.String password,
                                             java.io.File destinationDirectory)
                                      throws KeystoreException,
                                             java.io.IOException
        Stores the KeyWallet as a KeyStore
        Parameters:
        wallet - the wallet to store
        password - the password of KeyStore
        destinationDirectory - the KeyStore file is stored at.
        Returns:
        name of the KeyStore file
        Throws:
        KeystoreException
        java.io.IOException
      • sign

        public byte[] sign​(byte[] data)
        Description copied from interface: Wallet
        Signs the data to generate a signature
        Specified by:
        sign in interface Wallet
        Parameters:
        data - to sign
        Returns:
        signature
        See Also:
        Wallet.sign(byte[])
      • getPrivateKey

        public Bytes getPrivateKey()
        Gets the private key
        Returns:
        private key
      • getPublicKey

        public Bytes getPublicKey()