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_BYTESDefault key size in bytes (256 for ElGamal). |
_data| Constructor and Description |
|---|
PrivateKey()no-arg constructor, uses default type |
PrivateKey(byte[] data)Construct from raw key data. |
PrivateKey(EncType type)Constructor with type. |
PrivateKey(EncType type,
byte[] data)Constructor with type and data. |
PrivateKey(EncType type,
byte[] data,
PublicKey pubKey)Constructor with type, data, and cached public key. |
PrivateKey(String base64Data)Constructs from base64. |
| Modifier and Type | Method and Description |
|---|---|
void | destroy()javax.security.auth.Destroyable interface |
boolean | equals(Object obj)Compares this private key with another object for equality. |
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()Key length in bytes, determined by the encryption type. |
PublicKey | toPublic()Derives a new PublicKey object derived from the secret contents
of this PrivateKey. |
String | toString()Returns a string representation of this data structure. |
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytespublic static final int KEYSIZE_BYTES
public PrivateKey()
public PrivateKey(byte[] data)
data - key datapublic 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 PrivateKeyDataFormatException - if the data is not validpublic void destroy()
destroy in interface Destroyablepublic boolean equals(Object obj)
equals in class SimpleDataStructureobj - the object to comparepublic EncType getType()
public int hashCode()
hashCode in class SimpleDataStructurepublic boolean isDestroyed()
isDestroyed in interface Destroyablepublic int length()
length in class SimpleDataStructurepublic PublicKey toPublic()
IllegalArgumentException - on bad keypublic String toString()
SimpleDataStructuretoString in class SimpleDataStructure