Class Ed448PublicKeySpec

java.lang.Object
zeroecho.core.alg.ed448.Ed448PublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class Ed448PublicKeySpec extends Object implements AlgorithmKeySpec

Ed448 Public Key Specification

Immutable specification for an Ed448 public key in X.509 encoding.

This class acts as a typed carrier for encoded public key material, typically used with Ed448PublicKeyBuilder to reconstruct a usable PublicKey. It also provides marshal/unmarshal helpers to serialize the key into a portable PairSeq representation.

Encoding

  • The byte array is expected to contain a valid X.509-encoded Ed448 public key.
  • The constructor defensively clones the provided array, and encoded() returns a fresh copy on each call.
  • The marshal(Ed448PublicKeySpec) and unmarshal(PairSeq) methods wrap and unwrap the X.509 bytes using base64 without padding.

Usage

// Wrap existing X.509-encoded bytes
Ed448PublicKeySpec spec = new Ed448PublicKeySpec(x509Bytes);

// Import into JCA PublicKey via builder
PublicKey key = new Ed448PublicKeyBuilder().importPublic(spec);

// Serialize to PairSeq (e.g., for transport)
PairSeq p = Ed448PublicKeySpec.marshal(spec);

// Deserialize from PairSeq
Ed448PublicKeySpec restored = Ed448PublicKeySpec.unmarshal(p);

Thread-safety

Instances are immutable and safe to share across threads.
Since:
1.0
  • Constructor Details

    • Ed448PublicKeySpec

      public Ed448PublicKeySpec(byte[] encodedX509)
      Constructs a new Ed448 public key spec from the given X.509-encoded bytes.
      Parameters:
      encodedX509 - X.509-encoded Ed448 public key (non-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:
      cloned X.509-encoded key bytes
    • marshal

      public static PairSeq marshal(Ed448PublicKeySpec spec)
      Serializes this key spec into a PairSeq record.

      The encoding is base64 without padding. The type field is set to "Ed448-PUB", and the X.509 bytes are stored under the key "x509.b64".

      Parameters:
      spec - the key spec to serialize
      Returns:
      a PairSeq containing the type and base64 data
    • unmarshal

      public static Ed448PublicKeySpec unmarshal(PairSeq p)
      Deserializes a PairSeq into a new Ed448PublicKeySpec.

      Expects a field "x509.b64" containing the base64-encoded X.509 public key bytes. Other fields are ignored.

      Parameters:
      p - the serialized pair sequence
      Returns:
      a reconstructed Ed448PublicKeySpec
      Throws:
      IllegalArgumentException - if x509.b64 is missing