Class Ed25519PublicKeySpec
java.lang.Object
zeroecho.core.alg.ed25519.Ed25519PublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Specification for Ed25519 public keys
AlgorithmKeySpec representing an Ed25519 public
key in its encoded X.509 form.
This spec is used by Ed25519PublicKeyBuilder and related APIs to
import and wrap Ed25519 public keys. The encoding is expected to conform to
the X.509 SubjectPublicKeyInfo structure as produced by standard JCA key
factories or external tooling.
Responsibilities
- Encapsulates the X.509-encoded public key bytes.
- Provides safe cloning to avoid exposing mutable internal state.
- Supports serialization to and from a compact base64-based
PairSeqrepresentation viamarshal(Ed25519PublicKeySpec)andunmarshal(PairSeq).
Usage example
// Wrap X.509 bytes in a spec
Ed25519PublicKeySpec spec = new Ed25519PublicKeySpec(x509Bytes);
// Import into a PublicKey using ZeroEcho
PublicKey pub = session.keyBuilders().asymmetric().importPublic("Ed25519", spec);
// Serialize to PairSeq (e.g., for configuration or transport)
PairSeq seq = Ed25519PublicKeySpec.marshal(spec);
// Reconstruct from serialized form
Ed25519PublicKeySpec restored = Ed25519PublicKeySpec.unmarshal(seq);
Thread-safety
Instances are immutable. The internal key bytes are defensively copied on construction and retrieval, making this class safe to share across threads.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionEd25519PublicKeySpec(byte[] encodedX509) Creates a new Ed25519 public key specification from its X.509 encoding. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encoded()Returns a defensive copy of the X.509-encoded public key bytes.static PairSeqmarshal(Ed25519PublicKeySpec spec) Serializes the given public key spec to a base64-encodedPairSeq.static Ed25519PublicKeySpecReconstructs a public key spec from a base64-encodedPairSeq.
-
Constructor Details
-
Ed25519PublicKeySpec
public Ed25519PublicKeySpec(byte[] encodedX509) Creates a new Ed25519 public key specification from its X.509 encoding.- Parameters:
encodedX509- X.509-encoded public key bytes; must not be null- Throws:
IllegalArgumentException- ifencodedX509is null
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the X.509-encoded public key bytes.- Returns:
- clone of the X.509 encoding
-
marshal
-
unmarshal
Reconstructs a public key spec from a base64-encodedPairSeq.The sequence must contain the field
"x509.b64"with the base64 encoding of the X.509 key.- Parameters:
p- serialized key data- Returns:
- a new
Ed25519PublicKeySpecinstance - Throws:
IllegalArgumentException- if the sequence does not contain"x509.b64"
-