Class MldsaPublicKeySpec

java.lang.Object
zeroecho.core.alg.mldsa.MldsaPublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class MldsaPublicKeySpec extends Object implements AlgorithmKeySpec
Encoded representation of an ML-DSA public key.

MldsaPublicKeySpec is an immutable value object that wraps an X.509 (SubjectPublicKeyInfo) encoded ML-DSA public key together with the JCA provider name that should be used when importing the key.

Encoding

  • The public key bytes are stored as a defensive copy of the provided X.509 byte array.
  • Marshalling/unmarshalling uses PairSeq with Base64 encoding under "x509.b64".

Provider selection

The default provider is "BC".

Since:
1.0
  • Constructor Details

    • MldsaPublicKeySpec

      public MldsaPublicKeySpec(byte[] encodedX509)
      Creates a new specification using the default provider "BC".
      Parameters:
      encodedX509 - X.509-encoded ML-DSA public key bytes
      Throws:
      IllegalArgumentException - if encodedX509 is null
    • MldsaPublicKeySpec

      public MldsaPublicKeySpec(byte[] encodedX509, String providerName)
      Creates a new specification using the supplied provider.
      Parameters:
      encodedX509 - X.509-encoded ML-DSA public key bytes
      providerName - JCA provider name to use for import; may 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:
      a copy of the encoded public key
    • providerName

      public String providerName()
      Returns the provider name associated with this specification.
      Returns:
      provider name, never null
    • marshal

      public static PairSeq marshal(MldsaPublicKeySpec spec)
      Serializes the given spec into a PairSeq.
      Parameters:
      spec - the public key specification to serialize
      Returns:
      serialized representation
      Throws:
      NullPointerException - if spec is null
    • unmarshal

      public static MldsaPublicKeySpec unmarshal(PairSeq p)
      Deserializes a MldsaPublicKeySpec from a PairSeq.
      Parameters:
      p - serialized input
      Returns:
      reconstructed public key specification
      Throws:
      IllegalArgumentException - if "x509.b64" is missing
      NullPointerException - if p is null