Class SlhDsaPublicKeySpec

java.lang.Object
zeroecho.core.alg.slhdsa.SlhDsaPublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class SlhDsaPublicKeySpec extends Object implements AlgorithmKeySpec
Encoded representation of an SLH-DSA public key.

SlhDsaPublicKeySpec is an immutable value object that wraps an X.509 (SubjectPublicKeyInfo) encoded SLH-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" because SLH-DSA is registered by the Bouncy Castle core provider.

Thread-safety

Instances are immutable and can be safely shared across threads.

Since:
1.0
  • Constructor Details

    • SlhDsaPublicKeySpec

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

      public SlhDsaPublicKeySpec(byte[] encodedX509, String providerName)
      Creates a new specification using the supplied provider.

      If providerName is null, the default provider "BC" is used.

      Parameters:
      encodedX509 - X.509-encoded SLH-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(SlhDsaPublicKeySpec spec)
      Serializes the given spec into a PairSeq.

      The encoded key is stored as Base64 without padding under "x509.b64". The provider is stored under "provider".

      Parameters:
      spec - the public key specification to serialize
      Returns:
      serialized representation
      Throws:
      NullPointerException - if spec is null
    • unmarshal

      public static SlhDsaPublicKeySpec unmarshal(PairSeq p)
      Deserializes a SlhDsaPublicKeySpec from a PairSeq.

      Expects key "x509.b64" (required) and "provider" (optional; defaults to "BC").

      Parameters:
      p - serialized input
      Returns:
      reconstructed public key specification
      Throws:
      IllegalArgumentException - if "x509.b64" is missing
      NullPointerException - if p is null