public class EdPrivateKey extends AbstractECPrivateKey implements EdKey
PublicKeyInfo which makes it suitable for use in X.509 certificates.
Ed based algorithms use byte arrays as secret keys and extract secret scalars from this array. In the case of the ECDH variants, the scalar is directly extract from the array. For EdDSA, the seed is first expanded to an array twice the size, where the lower half is used to extract the secret scalar.
PKCS#8 [2] defines a syntax for encapsulating private key information:
PrivateKeyInfo ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] Attributes OPTIONAL
}
For Ed private keys the syntax for the privateKey field is
defined by [1]:
PrivateKey ::= OCTET STRINGNote that [1] requires
attributes to be absent.
References:
[1] Algorithm Identifiers for Ed25519, Ed448, X25519 and X448 for use in the Internet X.409 Public Key Infrastructure. S. Josefsson and J. Schaad. https://tools.ietf.org/html/draft-ietf-curdle-pkix-04
[2] An RSA Laboratories Technical Note. 1993. PKCS #8: Private-Key Information Syntax Standard v2.1
EdKey,
EdPrivateKey,
EdPublicKeySpec,
X448KeyPairGenerator,
X25519KeyPairGenerator,
EdPrivateKeySpec,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
seed_ |
encodedPrivateKey_, params_, s_, w_serialVersionUID| Constructor and Description |
|---|
EdPrivateKey(byte[] encoded)
Constructs a new
EdPrivateKey from an encoded ASN.1 structure. |
EdPrivateKey(EdParameterSpec params,
byte[] s)
Constructs a new
EdPrivateKey from a set of curve parameters and a
secret integer s. |
EdPrivateKey(EdParameterSpec params,
byte[] seed,
BigInteger s,
ECPoint publicKey)
Creates a new private key with the specified parameters.
|
EdPrivateKey(EdPrivateKeySpec keySpec)
Constructs a new
EdPrivateKey from an IAIK EdPrivateKeySpec
object. |
| Modifier and Type | Method and Description |
|---|---|
protected ECPoint |
computeOrGetW()
Check if public point is set and return it.
|
static BigInteger |
computeS(EdParameterSpec params,
byte[] seed)
Extract scalar from seed.
|
protected void |
createEncodedPrivateKey()
Creates the ASN.1 private key structure.
|
protected void |
decode(byte[] privateKey) |
protected void |
finalize() |
String |
getAlgorithm() |
int |
getKeyLength()
Returns the key length of this
ECKey. |
EdParameterSpec |
getParams()
Returns the domain parameters of the associated elliptic curve.
|
EdPublicKey |
getPublicKey()
Returns the corresponding
AbstractECPublicKey. |
byte[] |
getSeed()
Return the secret seed.
|
String |
toString() |
encode, equals, getS, hashCodeclone, createPrivateKeyInfo, decode, getAlgorithmID, getAttributes, getEncoded, getFormat, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPrivateKey, getPubKey, setAttributes, setPubKey, toASN1Object, writeTogetEncoded, getFormatdestroy, isDestroyedpublic EdPrivateKey(byte[] encoded)
throws InvalidKeyException
EdPrivateKey from an encoded ASN.1 structure.encoded - the byte[] holding the ASN.1 structureInvalidKeyException - thrown if the given encoded key could not be decodedpublic EdPrivateKey(EdPrivateKeySpec keySpec)
EdPrivateKey from an IAIK EdPrivateKeySpec
object.keySpec - the private key specpublic EdPrivateKey(EdParameterSpec params, byte[] s)
EdPrivateKey from a set of curve parameters and a
secret integer s.params - the curve parameterss - the private keypublic EdPrivateKey(EdParameterSpec params, byte[] seed, BigInteger s, ECPoint publicKey)
params - the domain parametersseed - the private keys - the private scalarpublicKey - the corresponding public key (may be null)public byte[] getSeed()
protected void decode(byte[] privateKey)
throws InvalidKeyException
decode in class iaik.pkcs.pkcs8.PrivateKeyInfoInvalidKeyExceptionprotected void createEncodedPrivateKey()
AbstractECPrivateKeycreateEncodedPrivateKey in class AbstractECPrivateKeypublic static BigInteger computeS(EdParameterSpec params, byte[] seed)
params - domain parametersseed - seedprotected void finalize()
throws Throwable
finalize in class AbstractECPrivateKeyThrowablepublic int getKeyLength()
ECKeyECKey.public EdPublicKey getPublicKey()
AbstractECPrivateKeyAbstractECPublicKey.getPublicKey in class AbstractECPrivateKeyAbstractECPublicKeypublic EdParameterSpec getParams()
ECKeypublic String getAlgorithm()
getAlgorithm in interface KeygetAlgorithm in class iaik.pkcs.pkcs8.PrivateKeyInfopublic String toString()
toString in class iaik.pkcs.pkcs8.PrivateKeyInfoprotected ECPoint computeOrGetW()
Copyright © 2011–2022 Stiftung SIC. All rights reserved.