Package net.i2p.data
Class SigningPublicKey
- java.lang.Object
-
- net.i2p.data.SimpleDataStructure
-
- net.i2p.data.SigningPublicKey
-
- All Implemented Interfaces:
DataStructure
public class SigningPublicKey extends SimpleDataStructure
Defines the SigningPublicKey as defined by the I2P data structure spec. A signing public key is by default 128 byte Integer. The public 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 (verifying signatures, not encrypting) As of release 0.9.8, keys of arbitrary length and type are supported. See SigType.- Author:
- jrandom
-
-
Field Summary
Fields Modifier and Type Field Description static int
KEYSIZE_BYTES
-
Fields inherited from class net.i2p.data.SimpleDataStructure
_data
-
-
Constructor Summary
Constructors Constructor Description SigningPublicKey()
SigningPublicKey(byte[] data)
SigningPublicKey(String base64Data)
constructs from base64SigningPublicKey(SigType type)
SigningPublicKey(SigType type, byte[] data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SigningPublicKey
blind(SigningPrivateKey alpha)
Only for SigType EdDSA_SHA512_Ed25519static void
clearCache()
static SigningPublicKey
create(byte[] data, int off)
Pull from cache or return new.static SigningPublicKey
create(InputStream in)
Pull from cache or return newboolean
equals(Object obj)
Warning - this returns true for two different classes with the same size and same data, e.g.byte[]
getPadding(KeyCertificate kcert)
Get the portion of this (type 0) SPK that is really padding based on the Key Cert type given, if anySigType
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 structureString
toString()
SigningPublicKey
toTypedKey(KeyCertificate kcert)
Up-convert this from an untyped (type 0) SPK to a typed SPK based on the Key Cert given.void
writeTruncatedBytes(OutputStream out)
Write the data up to a max of 128 bytes.-
Methods inherited from class net.i2p.data.SimpleDataStructure
calculateHash, fromBase64, fromByteArray, getData, read, readBytes, setData, toBase64, toByteArray, writeBytes
-
-
-
-
Constructor Detail
-
SigningPublicKey
public SigningPublicKey()
-
SigningPublicKey
public SigningPublicKey(SigType type)
- Parameters:
type
- if null, type is unknown- Since:
- 0.9.8
-
SigningPublicKey
public SigningPublicKey(byte[] data)
-
SigningPublicKey
public SigningPublicKey(SigType type, byte[] data)
- Parameters:
type
- if null, type is unknown- Since:
- 0.9.8
-
SigningPublicKey
public SigningPublicKey(String base64Data) throws DataFormatException
constructs from base64- Parameters:
base64Data
- a string of base64 data (the output of .toBase64() called on a prior instance of SigningPublicKey- Throws:
DataFormatException
-
-
Method Detail
-
create
public static SigningPublicKey create(byte[] data, int off)
Pull from cache or return new. Deprecated - used only by deprecated Destination.readBytes(data, off)- Throws:
ArrayIndexOutOfBoundsException
- if not enough bytes, FIXME should throw DataFormatException- Since:
- 0.8.3
-
create
public static SigningPublicKey create(InputStream in) throws IOException
Pull from cache or return new- Throws:
IOException
- Since:
- 0.8.3
-
length
public int length()
Description copied from class:SimpleDataStructure
The legal length of the byte array in this data structure- Specified by:
length
in classSimpleDataStructure
- Returns:
- if type unknown, the length of the data, or 128 if no data
-
getType
public SigType getType()
- Returns:
- null if unknown
- Since:
- 0.9.8
-
toTypedKey
public SigningPublicKey toTypedKey(KeyCertificate kcert)
Up-convert this from an untyped (type 0) SPK to a typed SPK based on the Key Cert given. The type of the returned key will be null if the kcert sigtype is null.- Throws:
IllegalArgumentException
- if this is already typed to a different type- Since:
- 0.9.12
-
getPadding
public byte[] getPadding(KeyCertificate kcert)
Get the portion of this (type 0) SPK that is really padding based on the Key Cert type given, if any- Returns:
- leading padding length > 0 or null if no padding or type is unknown
- Throws:
IllegalArgumentException
- if this is already typed to a different type- Since:
- 0.9.12
-
writeTruncatedBytes
public void writeTruncatedBytes(OutputStream out) throws DataFormatException, IOException
Write the data up to a max of 128 bytes. If longer, the rest will be written in the KeyCertificate.- Throws:
DataFormatException
IOException
- Since:
- 0.9.12
-
blind
public SigningPublicKey blind(SigningPrivateKey alpha)
Only for SigType EdDSA_SHA512_Ed25519- Parameters:
alpha
- the secret data- Throws:
UnsupportedOperationException
- unless supported- Since:
- 0.9.38
-
toString
public String toString()
- Overrides:
toString
in classSimpleDataStructure
- Since:
- 0.9.8
-
clearCache
public static void clearCache()
- Since:
- 0.9.17
-
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 classSimpleDataStructure
- 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 classSimpleDataStructure
- Since:
- 0.9.17
-
-