java.lang.Object
java.security.KeyPairGeneratorSpi
net.i2p.crypto.eddsa.KeyPairGenerator
- Direct Known Subclasses:
RedKeyPairGenerator
Key pair generator for EdDSA (Edwards-curve Digital Signature Algorithm) keys.
This implementation generates EdDSA key pairs with a default key size of 256 bits using the Ed25519 curve, which provides strong security with excellent performance characteristics. EdDSA is the recommended signature algorithm for new I2P applications.
Generated keys are suitable for:
- Digital signatures and verification
- I2P destination keys
- Router identity and communication
- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intKey size in bits used when initialize() supplies no strength.private static final Map<Integer, AlgorithmParameterSpec> Parameter specs for the supported curves, built once in the static initializerprotected EdDSAParameterSpecEdDSA parameter specification, set by initialize().protected booleanWhether the generator has been initialized.protected SecureRandomThe random number source, set by initialize().Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionprotected EdDSANamedCurveSpeccreateNamedCurveSpec(String curveName) Create an EdDSANamedCurveSpec from the provided curve name.Generate a new EdDSA key pair.voidinitialize(int keysize, SecureRandom random) Initialize with the given key size.voidinitialize(AlgorithmParameterSpec params, SecureRandom random) Initialize with the given parameter spec.
Field Details
DEFAULT_KEYSIZE
protected static final int DEFAULT_KEYSIZEKey size in bits used when initialize() supplies no strength.- See Also:
edParams
EdDSA parameter specification, set by initialize().random
The random number source, set by initialize().initialized
protected boolean initializedWhether the generator has been initialized.edParameters
Parameter specs for the supported curves, built once in the static initializer
Constructor Details
KeyPairGenerator
public KeyPairGenerator()Constructor. The JCA framework callsinitialize(int, SecureRandom)with the strength and randomness source, so the instance starts uninitialized and empty.
Method Details
initialize
Initialize with the given key size.- Specified by:
initializein classKeyPairGeneratorSpi
initialize
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException Initialize with the given parameter spec.- Overrides:
initializein classKeyPairGeneratorSpi- Throws:
InvalidAlgorithmParameterException
generateKeyPair
Generate a new EdDSA key pair.- Specified by:
generateKeyPairin classKeyPairGeneratorSpi- Returns:
- the generated key pair
createNamedCurveSpec
protected EdDSANamedCurveSpec createNamedCurveSpec(String curveName) throws InvalidAlgorithmParameterException Create an EdDSANamedCurveSpec from the provided curve name. The current implementation fetches the pre-created curve spec from a table.- Parameters:
curveName- the EdDSA named curve.- Returns:
- the specification for the named curve.
- Throws:
InvalidAlgorithmParameterException- if the named curve is unknown.