Package com.syntifi.crypto.key
Class AbstractPrivateKey
- java.lang.Object
-
- com.syntifi.crypto.key.AbstractPrivateKey
-
- Direct Known Subclasses:
Ed25519PrivateKey,Secp256k1PrivateKey
public abstract class AbstractPrivateKey extends java.lang.ObjectAbstract class for needed shared functionalities- Since:
- 0.1.0
-
-
Constructor Summary
Constructors Constructor Description AbstractPrivateKey()AbstractPrivateKey(byte[] key)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)abstract AbstractPublicKeyderivePublicKey()Derives the public key from the loaded private keybooleanequals(java.lang.Object o)byte[]getKey()inthashCode()abstract voidloadPrivateKey(byte[] privateKey)Loads a private key from a byte arrayabstract voidreadPrivateKey(java.io.Reader reader)Reads the private key from a streamvoidreadPrivateKey(java.lang.String filename)Reads the private key from a filevoidsetKey(byte[] key)abstract byte[]sign(byte[] message)Signs a message with the loaded keyjava.lang.StringtoString()abstract voidwritePrivateKey(java.io.Writer writer)Writes the private key to a filevoidwritePrivateKey(java.lang.String filename)Writes the private key to a file
-
-
-
Method Detail
-
loadPrivateKey
public abstract void loadPrivateKey(byte[] privateKey) throws java.io.IOExceptionLoads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionWrites 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.IOExceptionWrites 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.GeneralSecurityExceptionSigns 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
-
derivePublicKey
public abstract AbstractPublicKey derivePublicKey()
Derives the public key from the loaded private key- Returns:
- the derived
AbstractPublicKey
-
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
-
-