Class FrodoPublicKeySpec

java.lang.Object
zeroecho.core.alg.frodo.FrodoPublicKeySpec
All Implemented Interfaces:
AlgorithmKeySpec

public final class FrodoPublicKeySpec extends Object implements AlgorithmKeySpec

Specification for importing a Frodo public key

FrodoPublicKeySpec is a wrapper around an X.509-encoded FrodoKEM public key. It provides immutable access to the raw encoding and utility methods for serialization.

Encoding format

  • Keys are stored in the standard X.509 SubjectPublicKeyInfo format as produced by providers such as BouncyCastle PQC.
  • The encoding is preserved exactly as provided; no parsing or validation is performed by this class.

Usage

// Import an existing Frodo public key
byte[] encoded = Files.readAllBytes(Paths.get("frodo.pub"));
FrodoPublicKeySpec spec = new FrodoPublicKeySpec(encoded);
PublicKey pub = session.keyBuilders().asymmetric().importPublic("FrodoKEM", spec);

Thread-safety

This class is immutable; the internal byte array is cloned on construction and when accessed via x509().

Since:
1.0
  • Constructor Details

    • FrodoPublicKeySpec

      public FrodoPublicKeySpec(byte[] x509Der)
      Creates a new specification from an X.509 DER-encoded public key.
      Parameters:
      x509Der - the encoded public key bytes (will be cloned)
      Throws:
      NullPointerException - if x509Der is null
  • Method Details

    • x509

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

      public static PairSeq marshal(FrodoPublicKeySpec spec)
      Serializes this spec into a PairSeq, encoding the key in Base64 without padding.
      Parameters:
      spec - Frodo public key specification to serialize
      Returns:
      a PairSeq with type and Base64-encoded key
    • unmarshal

      public static FrodoPublicKeySpec unmarshal(PairSeq p)
      Parses a PairSeq previously produced by marshal(FrodoPublicKeySpec).
      Parameters:
      p - input sequence containing a x509.b64 entry
      Returns:
      a new public key spec initialized with the decoded bytes
      Throws:
      IllegalArgumentException - if x509.b64 entry is missing
    • toString

      public String toString()
      Returns a diagnostic string containing the encoded length.
      Overrides:
      toString in class Object
      Returns:
      string in the form FrodoPublicKeySpec[len=N]