Class AbstractEncodedPublicKeyBuilder<S extends AlgorithmKeySpec>
java.lang.Object
zeroecho.core.alg.common.eddsa.AbstractEncodedPublicKeyBuilder<S>
- Type Parameters:
S- the algorithm-specific key specification carrying X.509 data
- All Implemented Interfaces:
PublicKeyImporter<S>
- Direct Known Subclasses:
Ed25519PublicKeyBuilder, Ed448PublicKeyBuilder
public abstract class AbstractEncodedPublicKeyBuilder<S extends AlgorithmKeySpec>
extends Object
implements PublicKeyImporter<S>
Abstract EdDSA Encoded Public Key Builder
Base class for reconstructing EdDSA public keys (e.g., Ed25519, Ed448) from X.509-encoded specifications.
Unlike AbstractEdDSAKeyGenBuilder, which generates new key pairs, and
AbstractEncodedPrivateKeyBuilder, which restores private keys, this
class focuses exclusively on importing existing public keys from their
encoded form. Key pair generation and private key import are intentionally
unsupported here.
Responsibilities
- Define
jcaKeyFactoryAlg()to return the canonical JCA algorithm name (e.g.,"Ed25519","Ed448"). - Define
encodedX509(AlgorithmKeySpec)to extract the raw X.509-encoded public key bytes from the given spec. - Provide an
importPublic(AlgorithmKeySpec)implementation that rebuilds aPublicKeyusingKeyFactoryand the encoded X.509 material.
Thread-safety
Stateless and safe for concurrent use. Each call toimportPublic(AlgorithmKeySpec) creates a new KeyFactory.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a stateless encoded-public-key importer base. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]encodedX509(S spec) Extracts the raw X.509-encoded public key bytes from the given spec.importPublic(S spec) Imports an EdDSA public key from its X.509-encoded form.protected abstract StringReturns the canonical JCA algorithm identifier used byKeyFactory.getInstance(String).
-
Constructor Details
-
AbstractEncodedPublicKeyBuilder
public AbstractEncodedPublicKeyBuilder()Creates a stateless encoded-public-key importer base.
-
-
Method Details
-
jcaKeyFactoryAlg
Returns the canonical JCA algorithm identifier used byKeyFactory.getInstance(String).Must be one of the algorithm names recognized by the JDK (e.g.,
"Ed25519","Ed448").- Returns:
- the JCA algorithm identifier string
-
encodedX509
Extracts the raw X.509-encoded public key bytes from the given spec.Subclasses must implement this to pull the encoded material from their
AlgorithmKeySpecrepresentation.- Parameters:
spec- algorithm-specific key specification- Returns:
- X.509-encoded public key bytes
-
importPublic
Imports an EdDSA public key from its X.509-encoded form.This method uses
KeyFactoryinitialized with the algorithm returned byjcaKeyFactoryAlg()to parse the bytes provided byencodedX509(AlgorithmKeySpec).- Specified by:
importPublicin interfacePublicKeyImporter<S extends AlgorithmKeySpec>- Parameters:
spec- algorithm-specific key specification containing X.509 bytes- Returns:
- a reconstructed
PublicKeyinstance - Throws:
GeneralSecurityException- if the key material is invalid or the JCA provider does not support the algorithm
-