net.i2p.data
Class PrivateKey
java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.SimpleDataStructure
net.i2p.data.PrivateKey
- All Implemented Interfaces:
- DataStructure
public class PrivateKey
- extends SimpleDataStructure
Defines the PrivateKey as defined by the I2P data structure spec.
A private key is 256byte Integer. The private key represents only the
exponent, not the primes, which are constant and defined in the crypto spec.
Note that we use short exponents, so all but the last 28.25 bytes are zero.
See http://www.i2p2.i2p/how_cryptography for details.
- Author:
- jrandom
Method Summary |
boolean |
equals(Object obj)
Warning - this returns true for two different classes with the same size
and same data, e.g. |
int |
hashCode()
We assume the data has enough randomness in it, so use the last 4 bytes for speed. |
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 |
KEYSIZE_BYTES
public static final int KEYSIZE_BYTES
- See Also:
- Constant Field Values
PrivateKey
public PrivateKey()
PrivateKey
public PrivateKey(byte[] data)
PrivateKey
public PrivateKey(String base64Data)
throws DataFormatException
- constructs from base64
- Parameters:
base64Data
- a string of base64 data (the output of .toBase64() called
on a prior instance of PrivateKey
- Throws:
DataFormatException
length
public int length()
- Description copied from class:
SimpleDataStructure
- The legal length of the byte array in this data structure
- Specified by:
length
in class SimpleDataStructure
toPublic
public PublicKey toPublic()
- derives a new PublicKey object derived from the secret contents
of this PrivateKey
- Returns:
- a PublicKey object
hashCode
public int hashCode()
- We assume the data has enough randomness in it, so use the last 4 bytes for speed.
Overridden since we use short exponents, so the first 227 bytes are all zero.
Not that we are storing PrivateKeys in any Sets or Maps anywhere.
- Overrides:
hashCode
in class SimpleDataStructure
equals
public boolean equals(Object obj)
- Description copied from class:
SimpleDataStructure
- Warning - this returns true for two different classes with the same size
and same data, e.g. SessionKey and SessionTag, but you wouldn't
put them in the same Set, would you?
- Overrides:
equals
in class SimpleDataStructure