Class AbstractPrivateKey

  • Direct Known Subclasses:
    Ed25519PrivateKey, Secp256k1PrivateKey

    public abstract class AbstractPrivateKey
    extends java.lang.Object
    Abstract class for needed shared functionalities
    Since:
    0.1.0
    • Constructor Detail

      • AbstractPrivateKey

        public AbstractPrivateKey()
      • AbstractPrivateKey

        public AbstractPrivateKey​(byte[] key)
    • Method Detail

      • loadPrivateKey

        public abstract void loadPrivateKey​(byte[] privateKey)
                                     throws java.io.IOException
        Loads a private key from a byte array
        Parameters:
        privateKey - the private key bytes
        Throws:
        java.io.IOException
      • readPrivateKey

        public final void readPrivateKey​(java.lang.String filename)
                                  throws java.io.IOException
        Reads the private key from a file
        Parameters:
        filename - the source filename
        Throws:
        java.io.IOException - thrown if an error occurs reading the file
      • readPrivateKey

        public abstract void readPrivateKey​(java.io.Reader reader)
                                     throws java.io.IOException
        Reads the private key from a stream
        Parameters:
        reader - the source of the private key
        Throws:
        java.io.IOException - thrown if an error occurs reading the file
      • writePrivateKey

        public final void writePrivateKey​(java.lang.String filename)
                                   throws java.io.IOException
        Writes the private key to a file
        Parameters:
        filename - the target filename
        Throws:
        java.io.IOException - thrown if an error occurs writing the file
      • writePrivateKey

        public abstract void writePrivateKey​(java.io.Writer writer)
                                      throws java.io.IOException
        Writes the private key to a file
        Parameters:
        writer - the target writer
        Throws:
        java.io.IOException - thrown if an error occurs writing the file
      • sign

        public abstract byte[] sign​(byte[] message)
                             throws java.security.GeneralSecurityException
        Signs a message with the loaded key
        Parameters:
        message - message to sign
        Returns:
        signed message
        Throws:
        java.security.GeneralSecurityException - thrown if an error occurs processing message or signature
      • getKey

        public byte[] getKey()
      • setKey

        public void setKey​(byte[] key)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • canEqual

        protected boolean canEqual​(java.lang.Object other)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object