java.lang.Object
net.i2p.crypto.elgamal.impl.ElGamalPrivateKeyImpl
- All Implemented Interfaces:
Serializable, AsymmetricKey, BinaryEncodablePREVIEW, Key, PrivateKey, DHKey, DHPrivateKey, Destroyable, ElGamalKey, ElGamalPrivateKey
Implementation of ElGamal private keys.
This class provides a concrete implementation of the ElGamalPrivateKey interface, representing the private component of an ElGamal key pair. It stores the secret exponent x and the ElGamal parameters (prime p and generator g), and supports PKCS#8 encoding for standardized key storage and transmission.
- See Also:
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNo-arg constructor.ElGamalPrivateKeyImpl(BigInteger x, ElGamalParameterSpec elSpec) Create from the private exponent and parameters.Constructor from PKCS8 key spec.Create from a DH private key.Create from a DH private key spec.Create a copy of the given ElGamal private key.Create from an ElGamal private key spec.Method Summary
All MethodsModifier and TypeMethodDescriptionThe algorithm name, "ElGamal".byte[]Return a PKCS8 representation of the key.The encoding format produced by getEncoded().The ElGamal parameters for this key.The parameters for this key.getX()The private exponent.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Destroyable
destroy, isDestroyed
Constructor Details
ElGamalPrivateKeyImpl
protected ElGamalPrivateKeyImpl()No-arg constructor.ElGamalPrivateKeyImpl
Create a copy of the given ElGamal private key.- Parameters:
key- the ElGamal private key, read for both its exponent and its parameters
ElGamalPrivateKeyImpl
Create from a DH private key.- Parameters:
key- the DH private key
ElGamalPrivateKeyImpl
Create from an ElGamal private key spec.- Parameters:
spec- the ElGamal private key spec
ElGamalPrivateKeyImpl
Create from a DH private key spec.- Parameters:
spec- the DH private key spec
ElGamalPrivateKeyImpl
Create from the private exponent and parameters.- Parameters:
x- The private exponent.elSpec- The ElGamal parameters.
ElGamalPrivateKeyImpl
Constructor from PKCS8 key spec.- Parameters:
spec- the PKCS8 key spec- Throws:
InvalidKeySpecException- always, not yet implemented
Method Details
getAlgorithm
The algorithm name, "ElGamal".- Specified by:
getAlgorithmin interfaceKey- Returns:
- the algorithm name, always "ElGamal"
getFormat
getEncoded
public byte[] getEncoded()Return a PKCS8 representation of the key. The sequence returned represents a full PrivateKeyInfo object.- Specified by:
getEncodedin interfaceKey- Returns:
- a PKCS8 representation of the key.
getParameters
The ElGamal parameters for this key.- Specified by:
getParametersin interfaceElGamalKey- Returns:
- the ElGamal group this key belongs to
getParams
The parameters for this key.- Specified by:
getParamsin interfaceAsymmetricKey- Specified by:
getParamsin interfaceDHKey- Specified by:
getParamsin interfaceDHPrivateKey- Returns:
- the ElGamal group as a DH parameter spec, discarding the ElGamal extras
getX
The private exponent.- Specified by:
getXin interfaceDHPrivateKey- Specified by:
getXin interfaceElGamalPrivateKey- Returns:
- the private exponent x