Class SntruPrimePublicKeySpec
java.lang.Object
zeroecho.core.alg.ntruprime.SntruPrimePublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Specification wrapper for an encoded SNTRU Prime public key in X.509 format.
SntruPrimePublicKeySpec provides a type-safe holder for X.509
SubjectPublicKeyInfo bytes belonging to the SNTRU Prime KEM. It is immutable
and defensive copies are made on construction and retrieval.
Usage
Instances are typically created after parsing or receiving encoded key data, and passed to an algorithm’s key builder to import a usablePublicKey.
// Wrap existing encoded public key
byte[] der = Files.readAllBytes(Paths.get("sntru-public.spki"));
SntruPrimePublicKeySpec spec = new SntruPrimePublicKeySpec(der);
// Import via CryptoAlgorithms
PublicKey pub = session.keyBuilders().asymmetric().importPublic("SNTRUPrime", spec);
Serialization
A lightweight marshaling format is supported viaPairSeq:
marshal(SntruPrimePublicKeySpec)produces a base64 string under the key"x509.b64".unmarshal(PairSeq)reconstructs a new spec instance from such a sequence.
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSntruPrimePublicKeySpec(byte[] x509Der) Constructs a new public key specification from an X.509-encoded byte array. -
Method Summary
Modifier and TypeMethodDescriptionstatic PairSeqSerializes this specification into aPairSeq.toString()Returns a diagnostic string identifying this specification.static SntruPrimePublicKeySpecReconstructs a public key specification from aPairSeq.byte[]x509()Returns a clone of the X.509-encoded public key bytes.
-
Constructor Details
-
SntruPrimePublicKeySpec
public SntruPrimePublicKeySpec(byte[] x509Der) Constructs a new public key specification from an X.509-encoded byte array.A defensive copy is made; the input array may be reused or modified without affecting this instance.
- Parameters:
x509Der- X.509 SubjectPublicKeyInfo bytes- Throws:
NullPointerException- ifx509Deris null
-
-
Method Details
-
x509
public byte[] x509()Returns a clone of the X.509-encoded public key bytes.- Returns:
- copy of the encoded public key
-
marshal
Serializes this specification into aPairSeq.The result contains:
type = "SntruPrimePublicKeySpec"x509.b64 = ...base64-encoded key
- Parameters:
spec- specification to marshal- Returns:
- serialized representation containing the base64-encoded key
-
unmarshal
Reconstructs a public key specification from aPairSeq.The sequence must contain an
x509.b64entry; otherwise anIllegalArgumentExceptionis thrown.- Parameters:
p- serialized pair sequence produced bymarshal(SntruPrimePublicKeySpec)- Returns:
- a new specification with the decoded X.509 bytes
- Throws:
IllegalArgumentException- if the required field is missing
-
toString
-