FileDocCategorySizeDatePackage
ElGamalKeyPairGenerator.javaAPI DocAzureus 3.0.3.41620Tue Jun 08 05:12:58 BST 2004org.bouncycastle.crypto.generators

ElGamalKeyPairGenerator

public class ElGamalKeyPairGenerator extends Object implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
a ElGamal key pair generator.

This generates keys consistent for use with ElGamal as described in page 164 of "Handbook of Applied Cryptography".

Fields Summary
private org.bouncycastle.crypto.params.ElGamalKeyGenerationParameters
param
Constructors Summary
Methods Summary
public org.bouncycastle.crypto.AsymmetricCipherKeyPairgenerateKeyPair()

        BigInteger           p, g, x, y;
        int                  qLength = param.getStrength() - 1;
        ElGamalParameters    elParams = param.getParameters();

        p = elParams.getP();
        g = elParams.getG();
    
        //
        // calculate the private key
        //
		x = new BigInteger(qLength, param.getRandom());

        //
        // calculate the public key.
        //
        y = g.modPow(x, p);

        return new AsymmetricCipherKeyPair(
                new ElGamalPublicKeyParameters(y, elParams),
                new ElGamalPrivateKeyParameters(x, elParams));
    
public voidinit(org.bouncycastle.crypto.KeyGenerationParameters param)

        this.param = (ElGamalKeyGenerationParameters)param;