Class Ed25519PrivateKeySpec
java.lang.Object
zeroecho.core.alg.ed25519.Ed25519PrivateKeySpec
- All Implemented Interfaces:
Destroyable, AlgorithmKeySpec
Specification for Ed25519 private keys
AlgorithmKeySpec representing an Ed25519 private
key in its encoded PKCS#8 form.
This spec is used by Ed25519PrivateKeyBuilder and related APIs to
import and wrap Ed25519 private keys. The encoding is expected to conform to
the PKCS#8 standard as produced by standard JCA key factories or external
tooling.
Responsibilities
- Encapsulates the PKCS#8-encoded private key bytes.
- Provides safe cloning to avoid exposing mutable internal state.
- Supports serialization to and from a compact base64-based
PairSeqrepresentation viamarshal(Ed25519PrivateKeySpec)andunmarshal(PairSeq).
Usage example
// Wrap PKCS#8 bytes in a spec
Ed25519PrivateKeySpec spec = new Ed25519PrivateKeySpec(pkcs8Bytes);
// Import into a PrivateKey using ZeroEcho
PrivateKey priv = session.keyBuilders().asymmetric().importPrivate("Ed25519", spec);
// Serialize to PairSeq (e.g., for configuration or transport)
PairSeq seq = Ed25519PrivateKeySpec.marshal(spec);
// Reconstruct from serialized form
Ed25519PrivateKeySpec restored = Ed25519PrivateKeySpec.unmarshal(seq);
Thread-safety
Access and destruction are synchronized. The internal key bytes are defensively copied on construction and retrieval.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionEd25519PrivateKeySpec(byte[] encodedPkcs8) Creates a new Ed25519 private key specification from its PKCS#8 encoding. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()byte[]encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.booleanstatic PairSeqmarshal(Ed25519PrivateKeySpec spec) Serializes the given private key spec to a base64-encodedPairSeq.static Ed25519PrivateKeySpecReconstructs a private key spec from a base64-encodedPairSeq.
-
Constructor Details
-
Ed25519PrivateKeySpec
public Ed25519PrivateKeySpec(byte[] encodedPkcs8) Creates a new Ed25519 private key specification from its PKCS#8 encoding.- Parameters:
encodedPkcs8- PKCS#8-encoded private key bytes; must not be null- Throws:
IllegalArgumentException- ifencodedPkcs8is null
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the PKCS#8-encoded private key bytes.- Returns:
- clone of the PKCS#8 encoding
-
marshal
-
unmarshal
Reconstructs a private key spec from a base64-encodedPairSeq.The sequence must contain the field
"pkcs8.b64"with the base64 encoding of the PKCS#8 key.- Parameters:
p- serialized key data- Returns:
- a new
Ed25519PrivateKeySpecinstance - Throws:
IllegalArgumentException- if the sequence does not contain"pkcs8.b64"
-
destroy
public void destroy()- Specified by:
destroyin interfaceDestroyable
-
isDestroyed
public boolean isDestroyed()- Specified by:
isDestroyedin interfaceDestroyable
-