Class MldsaPrivateKeySpec

java.lang.Object
zeroecho.core.alg.mldsa.MldsaPrivateKeySpec
All Implemented Interfaces:
Destroyable, AlgorithmKeySpec

public final class MldsaPrivateKeySpec extends Object implements AlgorithmKeySpec, Destroyable
Encoded representation of an ML-DSA private key.

MldsaPrivateKeySpec is a destroyable value object that wraps a PKCS#8-encoded ML-DSA private key together with the JCA provider name that should be used when importing the key.

Encoding

  • The private key material is stored as a defensive copy of the provided PKCS#8 byte array.
  • Marshalling/unmarshalling uses PairSeq with Base64 encoding under "pkcs8.b64".

Provider selection

The default provider is "BC".

Since:
1.0
  • Constructor Details

    • MldsaPrivateKeySpec

      public MldsaPrivateKeySpec(byte[] encodedPkcs8)
      Creates a new specification using the default provider "BC".
      Parameters:
      encodedPkcs8 - PKCS#8-encoded ML-DSA private key bytes
      Throws:
      IllegalArgumentException - if encodedPkcs8 is null
    • MldsaPrivateKeySpec

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

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

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

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

      public void destroy()
      Specified by:
      destroy in interface Destroyable
    • isDestroyed

      public boolean isDestroyed()
      Specified by:
      isDestroyed in interface Destroyable