Class SaberPublicKeySpec

java.lang.Object
zeroecho.core.alg.saber.SaberPublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class SaberPublicKeySpec extends Object implements AlgorithmKeySpec
Encoded public key specification for the SABER post-quantum KEM algorithm.

A SaberPublicKeySpec wraps a SABER public key in standard X.509 SubjectPublicKeyInfo format. It provides safe accessors for cloning, along with serialization helpers to marshal and unmarshal from a compact PairSeq representation.

Immutability

The internal X.509 encoding is defensively copied on construction and when returned by x509(). Instances are therefore immutable and safe to share across threads.

Usage example

// Import SABER public key from encoded form
byte[] x509Bytes = ...;
SaberPublicKeySpec spec = new SaberPublicKeySpec(x509Bytes);
PublicKey key = session.keyBuilders().asymmetric().importPublic("SABER", spec);
  • Constructor Details

    • SaberPublicKeySpec

      public SaberPublicKeySpec(byte[] x509Der)
      Constructs a public key specification from an X.509-encoded SABER public key.
      Parameters:
      x509Der - the X.509 SubjectPublicKeyInfo bytes
      Throws:
      NullPointerException - if x509Der is null
  • Method Details

    • x509

      public byte[] x509()
      Returns a defensive copy of the X.509-encoded public key.
      Returns:
      cloned byte array containing the X.509 encoding
    • marshal

      public static PairSeq marshal(SaberPublicKeySpec spec)
      Serializes this specification into a compact PairSeq form.

      The encoding includes:

      • type = SaberPublicKeySpec
      • x509.b64 = Base64 encoding of the X.509 bytes (no padding)
      Parameters:
      spec - the public key specification to serialize
      Returns:
      a PairSeq containing the encoded data
      Throws:
      NullPointerException - if spec is null
    • unmarshal

      public static SaberPublicKeySpec unmarshal(PairSeq p)
      Deserializes a SaberPublicKeySpec from its PairSeq form.

      The sequence must contain a field x509.b64 with the Base64-encoded X.509 public key bytes. If the field is missing, an exception is thrown.

      Parameters:
      p - the pair sequence to parse
      Returns:
      a reconstructed SaberPublicKeySpec
      Throws:
      IllegalArgumentException - if the x509.b64 field is missing
    • toString

      public String toString()
      Returns a diagnostic string showing the length of the encoded key.

      This string does not expose the key material itself and is safe for logs.

      Overrides:
      toString in class Object
      Returns:
      string representation of this spec, including encoded length