public class PrivateKey extends SimpleDataStructure implements Destroyable
PrivateKey provides the decryption component of I2P's asymmetric cryptography:
Destroyable for secure cleanupSupported Algorithms:
Key Format:
Usage:
PublicKeyDestination cryptographic identitySecurity Considerations:
destroy() when no longer neededPerformance Features:
Migration Path:
Thread Safety:
| Modifier and Type | Field and Description |
|---|---|
static int |
KEYSIZE_BYTES |
_data| Constructor and Description |
|---|
PrivateKey() |
PrivateKey(byte[] data) |
PrivateKey(EncType type) |
PrivateKey(EncType type,
byte[] data) |
PrivateKey(EncType type,
byte[] data,
PublicKey pubKey) |
PrivateKey(String base64Data)
constructs from base64
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
javax.security.auth.Destroyable interface
|
boolean |
equals(Object obj)
Warning - this returns true for two different classes with the same size
and same data, e.g.
|
EncType |
getType()
Gets the encryption type of this private key.
|
int |
hashCode()
We assume the data has enough randomness in it, so use the last 4 bytes for speed.
|
boolean |
isDestroyed()
javax.security.auth.Destroyable interface
|
int |
length()
The legal length of the byte array in this data structure
|
PublicKey |
toPublic()
Derives a new PublicKey object derived from the secret contents
of this PrivateKey.
|
String |
toString() |
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytespublic PrivateKey()
public PrivateKey(byte[] data)
public PrivateKey(EncType type)
type - non-nullpublic PrivateKey(EncType type, byte[] data)
type - non-nulldata - must be non-nullpublic PrivateKey(EncType type, byte[] data, PublicKey pubKey)
type - non-nulldata - must be non-nullpubKey - corresponding pubKey to be cachedpublic PrivateKey(String base64Data) throws DataFormatException
base64Data - a string of base64 data (the output of .toBase64() called
on a prior instance of PrivateKeyDataFormatExceptionpublic void destroy()
destroy in interface Destroyablepublic boolean equals(Object obj)
SimpleDataStructureequals in class SimpleDataStructurepublic EncType getType()
public int hashCode()
hashCode in class SimpleDataStructurepublic boolean isDestroyed()
isDestroyed in interface Destroyablepublic int length()
SimpleDataStructurelength in class SimpleDataStructurepublic PublicKey toPublic()
IllegalArgumentException - on bad keypublic String toString()
toString in class SimpleDataStructure