Class Ed448PrivateKeySpec

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

public final class Ed448PrivateKeySpec extends Object implements AlgorithmKeySpec

Ed448 Private Key Specification

Immutable specification for an Ed448 private key in PKCS#8 encoding.

This class acts as a typed carrier for encoded private key material, typically used with Ed448PrivateKeyBuilder to reconstruct a usable PrivateKey. 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 PKCS#8-encoded Ed448 private key.
  • Internally, the array is defensively cloned on construction and when returned by encoded().
  • The marshal(Ed448PrivateKeySpec) and unmarshal(PairSeq) methods wrap and unwrap the PKCS#8 bytes using base64 without padding.

Usage


 // Wrap existing PKCS#8-encoded bytes
 Ed448PrivateKeySpec spec = new Ed448PrivateKeySpec(pkcs8Bytes);

 // Import into JCA PrivateKey via builder
 PrivateKey key = new Ed448PrivateKeyBuilder().importPrivate(spec);

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

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

Thread-safety

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

    • Ed448PrivateKeySpec

      public Ed448PrivateKeySpec(byte[] encodedPkcs8)
      Constructs a new Ed448 private key spec from the given PKCS#8-encoded bytes.
      Parameters:
      encodedPkcs8 - PKCS#8-encoded Ed448 private key (non-null)
      Throws:
      IllegalArgumentException - if encodedPkcs8 is null
  • Method Details

    • encoded

      public byte[] encoded()
      Returns a defensive copy of the PKCS#8-encoded private key bytes.
      Returns:
      cloned PKCS#8-encoded key bytes
    • marshal

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

      The encoding is base64 without padding. The type field is set to "Ed448-PRIV", and the PKCS#8 bytes are stored under the key "pkcs8.b64".

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

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

      Expects a field "pkcs8.b64" containing the base64-encoded PKCS#8 private key bytes. Other fields are ignored.

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