Package com.syntifi.crypto.key
Class AbstractPublicKey
- java.lang.Object
-
- com.syntifi.crypto.key.AbstractPublicKey
-
- Direct Known Subclasses:
Ed25519PublicKey,Secp256k1PublicKey
public abstract class AbstractPublicKey extends java.lang.ObjectAbstract class for needed shared functionalities- Since:
- 0.1.0
-
-
Constructor Summary
Constructors Constructor Description AbstractPublicKey()AbstractPublicKey(byte[] key)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)booleanequals(java.lang.Object o)byte[]getKey()inthashCode()abstract voidloadPublicKey(byte[] publicKey)Loads a public key from a byte arrayabstract voidreadPublicKey(java.io.Reader reader)Reads the public key from a filevoidreadPublicKey(java.lang.String filename)Reads the public key from a filevoidsetKey(byte[] key)java.lang.StringtoString()abstract java.lang.Booleanverify(byte[] message, byte[] signature)Verifies message with given signatureabstract voidwritePublicKey(java.io.Writer writer)Writes the public key to a filevoidwritePublicKey(java.lang.String filename)Writes the public key to a file
-
-
-
Method Detail
-
loadPublicKey
public abstract void loadPublicKey(byte[] publicKey) throws java.io.IOExceptionLoads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionWrites 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.IOExceptionWrites 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.GeneralSecurityExceptionVerifies message with given signature- Parameters:
message- the signed messagesignature- 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:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-