Class AbstractPublicKey

  • Direct Known Subclasses:
    Ed25519PublicKey, Secp256k1PublicKey

    public abstract class AbstractPublicKey
    extends java.lang.Object
    Abstract class for needed shared functionalities
    Since:
    0.1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected boolean canEqual​(java.lang.Object other)  
      boolean equals​(java.lang.Object o)  
      byte[] getKey()  
      int hashCode()  
      abstract void loadPublicKey​(byte[] publicKey)
      Loads a public key from a byte array
      abstract void readPublicKey​(java.io.Reader reader)
      Reads the public key from a file
      void readPublicKey​(java.lang.String filename)
      Reads the public key from a file
      void setKey​(byte[] key)  
      java.lang.String toString()  
      abstract java.lang.Boolean verify​(byte[] message, byte[] signature)
      Verifies message with given signature
      abstract void writePublicKey​(java.io.Writer writer)
      Writes the public key to a file
      void writePublicKey​(java.lang.String filename)
      Writes the public key to a file
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractPublicKey

        public AbstractPublicKey()
      • AbstractPublicKey

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

      • loadPublicKey

        public abstract void loadPublicKey​(byte[] publicKey)
                                    throws java.io.IOException
        Loads a public key from a byte array
        Parameters:
        publicKey - the public key bytes
        Throws:
        java.io.IOException
      • readPublicKey

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

        public abstract void readPublicKey​(java.io.Reader reader)
                                    throws java.io.IOException
        Reads the public key from a file
        Parameters:
        reader - the source filename
        Throws:
        java.io.IOException - thrown if an error occurs reading the file
      • writePublicKey

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

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

        public abstract java.lang.Boolean verify​(byte[] message,
                                                 byte[] signature)
                                          throws java.security.GeneralSecurityException
        Verifies message with given signature
        Parameters:
        message - the signed message
        signature - the signature to check against
        Returns:
        true if matches, false otherwise
        Throws:
        java.security.GeneralSecurityException - thrown if an error occurs processing message and 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