net.i2p.data
Class SigningPrivateKey

java.lang.Object
  extended by net.i2p.data.DataStructureImpl
      extended by net.i2p.data.SimpleDataStructure
          extended by net.i2p.data.SigningPrivateKey
All Implemented Interfaces:
Serializable, DataStructure

public class SigningPrivateKey
extends SimpleDataStructure

Defines the SigningPrivateKey as defined by the I2P data structure spec. A signing private key is by default a 20 byte Integer. The private key represents only the exponent, not the primes, which are constant and defined in the crypto spec. This key varies from the PrivateKey in its usage (signing, not decrypting) As of release 0.9.8, keys of arbitrary length and type are supported. See SigType.

Author:
jrandom
See Also:
Serialized Form

Field Summary
static int KEYSIZE_BYTES
           
 
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
 
Constructor Summary
SigningPrivateKey()
           
SigningPrivateKey(byte[] data)
           
SigningPrivateKey(SigType type)
           
SigningPrivateKey(SigType type, byte[] data)
           
SigningPrivateKey(String base64Data)
          constructs from base64
 
Method Summary
 boolean equals(Object obj)
          Warning - this returns true for two different classes with the same size and same data, e.g.
 SigType getType()
           
 int hashCode()
          We assume the data has enough randomness in it, so use the first 4 bytes for speed.
 int length()
          The legal length of the byte array in this data structure
 SigningPublicKey toPublic()
          Converts this signing private key to its public equivalent.
 String toString()
           
 
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, readBytes, setData, toBase64, toByteArray, writeBytes
 
Methods inherited from class net.i2p.data.DataStructureImpl
read
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KEYSIZE_BYTES

public static final int KEYSIZE_BYTES
Constructor Detail

SigningPrivateKey

public SigningPrivateKey()

SigningPrivateKey

public SigningPrivateKey(SigType type)
Since:
0.9.8

SigningPrivateKey

public SigningPrivateKey(byte[] data)

SigningPrivateKey

public SigningPrivateKey(SigType type,
                         byte[] data)
Since:
0.9.8

SigningPrivateKey

public SigningPrivateKey(String base64Data)
                  throws DataFormatException
constructs from base64

Parameters:
base64Data - a string of base64 data (the output of .toBase64() called on a prior instance of SigningPrivateKey
Throws:
DataFormatException
Method Detail

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

getType

public SigType getType()
Since:
0.9.8

toPublic

public SigningPublicKey toPublic()
Converts this signing private key to its public equivalent. As of 0.9.16, supports all key types.

Returns:
a SigningPublicKey object derived from this private key
Throws:
IllegalArgumentException - on bad key or unknown or unsupported type

toString

public String toString()
Overrides:
toString in class SimpleDataStructure
Since:
0.9.8

hashCode

public int hashCode()
Description copied from class: SimpleDataStructure
We assume the data has enough randomness in it, so use the first 4 bytes for speed. If this is not the case, override in the extending class.

Overrides:
hashCode in class SimpleDataStructure
Since:
0.9.17

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
Since:
0.9.17