Class AbstractEncodedPrivateKeyBuilder<S extends AlgorithmKeySpec>
java.lang.Object
zeroecho.core.alg.common.eddsa.AbstractEncodedPrivateKeyBuilder<S>
- Type Parameters:
S- the algorithm-specific key specification carrying PKCS#8 data
- All Implemented Interfaces:
PrivateKeyImporter<S>
- Direct Known Subclasses:
Ed25519PrivateKeyBuilder, Ed448PrivateKeyBuilder
public abstract class AbstractEncodedPrivateKeyBuilder<S extends AlgorithmKeySpec>
extends Object
implements PrivateKeyImporter<S>
Abstract EdDSA Encoded Private Key Builder
Base class for reconstructing EdDSA private keys (e.g., Ed25519, Ed448) from PKCS#8-encoded specifications.
Unlike AbstractEdDSAKeyGenBuilder, which is responsible for
generating fresh key pairs, this class focuses on importing existing
private keys from their encoded representation. Public key import and key
pair generation are deliberately unsupported here.
Responsibilities
- Define
jcaKeyFactoryAlg()to specify the canonical JCA algorithm name (e.g.,"Ed25519"or"Ed448"). - Define
encodedPkcs8(AlgorithmKeySpec)to extract the raw PKCS#8-encoded private key material from the given spec. - Provide an
importPrivate(AlgorithmKeySpec)implementation that rebuilds aPrivateKeyusingKeyFactoryand the PKCS#8-encoded material.
Thread-safety
Stateless and safe for concurrent use. Each import operation creates a newKeyFactory instance internally.- Since:
- 1.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a stateless encoded-private-key importer base. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte[]encodedPkcs8(S spec) Extracts the raw PKCS#8-encoded private key bytes from the given spec.importPrivate(S spec) Imports an EdDSA private key from its PKCS#8-encoded form.protected abstract StringReturns the canonical JCA algorithm identifier used byKeyFactory.getInstance(String).
-
Constructor Details
-
AbstractEncodedPrivateKeyBuilder
public AbstractEncodedPrivateKeyBuilder()Creates a stateless encoded-private-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
-
encodedPkcs8
Extracts the raw PKCS#8-encoded private 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:
- PKCS#8-encoded private key bytes
-
importPrivate
Imports an EdDSA private key from its PKCS#8-encoded form.This method uses
KeyFactoryinitialized with the algorithm returned byjcaKeyFactoryAlg()to parse the bytes provided byencodedPkcs8(AlgorithmKeySpec).- Specified by:
importPrivatein interfacePrivateKeyImporter<S extends AlgorithmKeySpec>- Parameters:
spec- algorithm-specific key specification containing PKCS#8 bytes- Returns:
- a reconstructed
PrivateKeyinstance - Throws:
GeneralSecurityException- if the key material is invalid or the JCA provider does not support the algorithm
-