Package net.i2p.data
Class SigningPrivateKey
java.lang.Object
net.i2p.data.SimpleDataStructure
net.i2p.data.SigningPrivateKey
- All Implemented Interfaces:
Destroyable,DataStructure
- Direct Known Subclasses:
RSASigningPrivateCrtKey
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
-
Field Summary
FieldsFields inherited from class net.i2p.data.SimpleDataStructure
_data -
Constructor Summary
ConstructorsConstructorDescriptionSigningPrivateKey(byte[] data) SigningPrivateKey(String base64Data) constructs from base64SigningPrivateKey(SigType type) SigningPrivateKey(SigType type, byte[] data) -
Method Summary
Modifier and TypeMethodDescriptionblind(SigningPrivateKey alpha) Only for SigType EdDSA_SHA512_Ed25519voiddestroy()javax.security.auth.Destroyable interfacebooleanWarning - this returns true for two different classes with the same size and same data, e.g.getType()inthashCode()We assume the data has enough randomness in it, so use the first 4 bytes for speed.booleanjavax.security.auth.Destroyable interfacebooleanConstant timeintlength()The legal length of the byte array in this data structuretoPublic()Converts this signing private key to its public equivalent.toString()Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytes
-
Field Details
-
KEYSIZE_BYTES
public static final int KEYSIZE_BYTES
-
-
Constructor Details
-
SigningPrivateKey
public SigningPrivateKey() -
SigningPrivateKey
- Since:
- 0.9.8
-
SigningPrivateKey
public SigningPrivateKey(byte[] data) -
SigningPrivateKey
- Since:
- 0.9.8
-
SigningPrivateKey
constructs from base64- Parameters:
base64Data- a string of base64 data (the output of .toBase64() called on a prior instance of SigningPrivateKey- Throws:
DataFormatException
-
-
Method Details
-
length
public int length()Description copied from class:SimpleDataStructureThe legal length of the byte array in this data structure- Specified by:
lengthin classSimpleDataStructure
-
getType
- Since:
- 0.9.8
-
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
-
blind
Only for SigType EdDSA_SHA512_Ed25519- Parameters:
alpha- the secret data- Throws:
UnsupportedOperationException- unless supported- Since:
- 0.9.38
-
isOffline
public boolean isOffline()Constant time- Returns:
- true if all zeros
- Since:
- 0.9.39 moved from PrivateKeyFile
-
destroy
public void destroy()javax.security.auth.Destroyable interface- Specified by:
destroyin interfaceDestroyable- Since:
- 0.9.40
-
isDestroyed
public boolean isDestroyed()javax.security.auth.Destroyable interface- Specified by:
isDestroyedin interfaceDestroyable- Since:
- 0.9.40
-
toString
- Overrides:
toStringin classSimpleDataStructure- Since:
- 0.9.8
-
hashCode
public int hashCode()Description copied from class:SimpleDataStructureWe 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:
hashCodein classSimpleDataStructure- Since:
- 0.9.17
-
equals
Description copied from class:SimpleDataStructureWarning - 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:
equalsin classSimpleDataStructure- Since:
- 0.9.17
-