Class XdhKeyGenBuilder
java.lang.Object
zeroecho.core.alg.xdh.XdhKeyGenBuilder
- All Implemented Interfaces:
AsymmetricKeyPairGenerator<XdhSpec>
KeyPair generator for XDH curves using the JCA KeyPairGenerator SPI.
This builder produces XDH key pairs (e.g., X25519, X448 depending on the
runtime provider) by instantiating a JCA KeyPairGenerator with the
algorithm name supplied by XdhSpec.kpgName().
Design and scope
- Generation only: This implementation exposes only the exact key-pair generation capability; import operations are registered separately.
- Provider resolution: The default JCA provider selection is used. If a specific provider is required, supply or register one that exposes the requested XDH algorithm name.
- Thread-safety: Instances are stateless and thread-safe.
Example
// Generate an X25519 key pair
XdhKeyGenBuilder builder = new XdhKeyGenBuilder();
KeyPair kp = builder.generateKeyPair(XdhSpec.X25519);
PublicKey pub = kp.getPublic();
PrivateKey prv = kp.getPrivate();
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateKeyPair(XdhSpec spec) Generates a new XDH key pair using the JCAKeyPairGenerator.
-
Constructor Details
-
XdhKeyGenBuilder
public XdhKeyGenBuilder()Creates a stateless XDH key-pair generator.
-
-
Method Details
-
generateKeyPair
Generates a new XDH key pair using the JCAKeyPairGenerator.The generator instance is obtained via
KeyPairGenerator.getInstance(String)withXdhSpec.kpgName()(for example,"XDH"or"X25519"). No additional initialization parameters are supplied; providers are expected to choose safe defaults for the requested curve.- Specified by:
generateKeyPairin interfaceAsymmetricKeyPairGenerator<XdhSpec>- Parameters:
spec- the XDH key specification indicating which XDH variant to use (e.g.,X25519)- Returns:
- a freshly generated
KeyPairfor the requested XDH variant - Throws:
GeneralSecurityException- if the algorithm is not available, the provider rejects the request, or key generation fails
-