Class EcdsaPublicKeySpec

java.lang.Object
zeroecho.core.alg.ecdsa.EcdsaPublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class EcdsaPublicKeySpec extends Object implements AlgorithmKeySpec

ECDSA Public Key Specification

An immutable wrapper around an X.509-encoded ECDSA public key. This specification is used by EcdsaPublicKeyBuilder to import keys into the JCA PublicKey representation.

Encoding

  • Keys are stored internally in X.509 SubjectPublicKeyInfo DER format.
  • Instances are defensive: the internal byte array is cloned on construction and on every access.
  • For serialization, marshal(EcdsaPublicKeySpec) encodes the X.509 bytes in Base64 without padding.

Usage

// Construct from X.509 DER
byte[] x509 = ...; // load from certificate or key file
EcdsaPublicKeySpec spec = new EcdsaPublicKeySpec(x509);

// Import into a PublicKey
PublicKey pub = new EcdsaPublicKeyBuilder().importPublic(spec);

// Marshal/unmarshal for transport or storage
PairSeq seq = EcdsaPublicKeySpec.marshal(spec);
EcdsaPublicKeySpec restored = EcdsaPublicKeySpec.unmarshal(seq);
Since:
1.0
  • Constructor Details

    • EcdsaPublicKeySpec

      public EcdsaPublicKeySpec(byte[] x509)
      Creates a new public key specification from an X.509 encoded byte array.
      Parameters:
      x509 - X.509 SubjectPublicKeyInfo DER-encoded public key (must not be null)
      Throws:
      IllegalArgumentException - if x509 is null
  • Method Details

    • encoded

      public byte[] encoded()
      Returns a defensive copy of the encoded X.509 data.
      Returns:
      cloned X.509 byte array
    • marshal

      public static PairSeq marshal(EcdsaPublicKeySpec spec)
      Serializes this specification into a PairSeq.

      The X.509 data is Base64-encoded (without padding) and emitted with the key "x509.b64".

      Parameters:
      spec - public key spec to marshal
      Returns:
      serialized representation in key-value form
    • unmarshal

      public static EcdsaPublicKeySpec unmarshal(PairSeq p)
      Reconstructs a public key specification from a PairSeq.

      The sequence must contain a "x509.b64" field with Base64-encoded X.509 DER data. If missing, an IllegalArgumentException is thrown.

      Parameters:
      p - serialized key-value sequence
      Returns:
      reconstructed EcdsaPublicKeySpec
      Throws:
      IllegalArgumentException - if x509.b64 is absent