Class Ed25519PublicKeySpec

java.lang.Object
zeroecho.core.alg.ed25519.Ed25519PublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class Ed25519PublicKeySpec extends Object implements 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

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 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 - if encodedX509 is 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

      public static PairSeq marshal(Ed25519PublicKeySpec spec)
      Serializes the given public key spec to a base64-encoded PairSeq.

      The output includes a type marker ("Ed25519-PUB") and the field "x509.b64" containing the base64 representation of the key.

      Parameters:
      spec - public key spec to marshal
      Returns:
      serialized representation as a PairSeq
    • unmarshal

      public static Ed25519PublicKeySpec unmarshal(PairSeq p)
      Reconstructs a public key spec from a base64-encoded PairSeq.

      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 Ed25519PublicKeySpec instance
      Throws:
      IllegalArgumentException - if the sequence does not contain "x509.b64"