Package net.i2p.crypto.eddsa
Class EdDSAPrivateKey
java.lang.Object
net.i2p.crypto.eddsa.EdDSAPrivateKey
- All Implemented Interfaces:
Serializable,Key,PrivateKey,Destroyable,EdDSAKey
public class EdDSAPrivateKey extends Object implements EdDSAKey, PrivateKey
An EdDSA private key.
For compatibility with older releases, decoding supports both RFC 8410 and an older draft specifications.
- Since:
- 0.9.15
- Author:
- str4d
- See Also:
- RFC 8410, Older draft specification, Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description EdDSAPrivateKey(PKCS8EncodedKeySpec spec)EdDSAPrivateKey(EdDSAPrivateKeySpec spec) -
Method Summary
Modifier and Type Method Description booleanequals(Object o)byte[]geta()GroupElementgetA()byte[]getAbyte()StringgetAlgorithm()byte[]getEncoded()Returns the private key in its canonical encoding.StringgetFormat()byte[]getH()EdDSAParameterSpecgetParams()byte[]getSeed()inthashCode()
-
Constructor Details
-
EdDSAPrivateKey
-
EdDSAPrivateKey
- Throws:
InvalidKeySpecException- Since:
- 0.9.25
-
-
Method Details
-
getAlgorithm
- Specified by:
getAlgorithmin interfaceKey
-
getFormat
-
getEncoded
public byte[] getEncoded()Returns the private key in its canonical encoding.This implements the following specs:
- General encoding: https://tools.ietf.org/html/rfc8410
- Key encoding: https://tools.ietf.org/html/rfc8032
This encodes the seed. It will return null if constructed from a spec which was directly constructed from H, in which case seed is null.
For keys in older formats, decoding and then re-encoding is sufficient to migrate them to the canonical encoding.
Relevant spec quotes:
OneAsymmetricKey ::= SEQUENCE { version Version, privateKeyAlgorithm PrivateKeyAlgorithmIdentifier, privateKey PrivateKey, attributes [0] IMPLICIT Attributes OPTIONAL, ..., [[2: publicKey [1] IMPLICIT PublicKey OPTIONAL ]], ... } Version ::= INTEGER PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier PrivateKey ::= OCTET STRING PublicKey ::= BIT STRING Attributes ::= SET OF Attribute... when encoding a OneAsymmetricKey object, the private key is wrapped in a CurvePrivateKey object and wrapped by the OCTET STRING of the "privateKey" field. CurvePrivateKey ::= OCTET STRING
AlgorithmIdentifier ::= SEQUENCE { algorithm OBJECT IDENTIFIER, parameters ANY DEFINED BY algorithm OPTIONAL } For all of the OIDs, the parameters MUST be absent.id-Ed25519 OBJECT IDENTIFIER ::= { 1 3 101 112 }- Specified by:
getEncodedin interfaceKey- Returns:
- 48 bytes for Ed25519, null for other curves
- Since:
- implemented in 0.9.25
-
getParams
-
getSeed
public byte[] getSeed()- Returns:
- will be null if constructed from a spec which was directly constructed from H
-
getH
public byte[] getH()- Returns:
- the hash of the seed
-
geta
public byte[] geta()- Returns:
- the private key
-
getA
- Returns:
- the public key
-
getAbyte
public byte[] getAbyte()- Returns:
- the public key
-
hashCode
public int hashCode() -
equals
-