Class SphincsPlusPublicKeySpec
java.lang.Object
zeroecho.core.alg.sphincsplus.SphincsPlusPublicKeySpec
- All Implemented Interfaces:
AlgorithmKeySpec
Encoded representation of a SPHINCS+ public key.
SphincsPlusPublicKeySpec wraps an X.509-encoded SPHINCS+ public key
along with the provider name that should be used for import. It is a simple
immutable holder designed for use with SphincsPlusPublicKeyBuilder.
Encoding
- The key is stored as a defensive copy of the provided X.509 byte array.
- Marshalling and unmarshalling methods convert between this object and a
PairSeqrepresentation using Base64 encoding. - The
providerNamedefaults to"BC"(Bouncy Castle provider) if not explicitly supplied.
Thread-safety
Instances are immutable and can be shared safely across threads. Defensive copies are returned for all sensitive material.Example
// Wrap an X.509-encoded public key
byte[] x509 = ...;
SphincsPlusPublicKeySpec spec = new SphincsPlusPublicKeySpec(x509);
// Import the key via the builder
PublicKey pub = new SphincsPlusPublicKeyBuilder().importPublic(spec);
// Serialize to PairSeq for transport or persistence
PairSeq seq = SphincsPlusPublicKeySpec.marshal(spec);
// Reconstruct from PairSeq
SphincsPlusPublicKeySpec restored = SphincsPlusPublicKeySpec.unmarshal(seq);
- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSphincsPlusPublicKeySpec(byte[] encodedX509) Constructs a new specification with the default provider"BC".SphincsPlusPublicKeySpec(byte[] encodedX509, String providerName) Constructs a new specification with the given provider. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]encoded()Returns a defensive copy of the X.509-encoded public key.static PairSeqSerializes this specification into aPairSeq.Returns the provider name associated with this specification.static SphincsPlusPublicKeySpecDeserializes aSphincsPlusPublicKeySpecfrom aPairSeq.
-
Constructor Details
-
SphincsPlusPublicKeySpec
public SphincsPlusPublicKeySpec(byte[] encodedX509) Constructs a new specification with the default provider"BC".- Parameters:
encodedX509- X.509-encoded SPHINCS+ public key bytes- Throws:
IllegalArgumentException- ifencodedX509isnull
-
SphincsPlusPublicKeySpec
Constructs a new specification with the given provider.- Parameters:
encodedX509- X.509-encoded SPHINCS+ public key bytesproviderName- JCA provider to use for import; ifnull, defaults to"BC"- Throws:
IllegalArgumentException- ifencodedX509isnullor the provider is legacy"BCPQC"
-
-
Method Details
-
encoded
public byte[] encoded()Returns a defensive copy of the X.509-encoded public key.- Returns:
- clone of the encoded key bytes
-
providerName
Returns the provider name associated with this specification.- Returns:
- provider name, never
null
-
marshal
-
unmarshal
Deserializes aSphincsPlusPublicKeySpecfrom aPairSeq.Expects keys
"x509.b64"(required, Base64 string) and"provider"(optional, defaults to"BC").- Parameters:
p- serialized input- Returns:
- a reconstructed public key spec
- Throws:
IllegalArgumentException- if the encoded key is missing, malformed Base64, or the provider is legacy"BCPQC"
-