Example #1
0
        public virtual AsymmetricCipherKeyPair GenerateKeyPair()
        {
            DHKeyGeneratorHelper helper = DHKeyGeneratorHelper.Instance;
            DHParameters         dhp    = param.Parameters;

            BigInteger x = helper.CalculatePrivate(dhp, param.Random);
            BigInteger y = helper.CalculatePublic(dhp, x);

            return(new AsymmetricCipherKeyPair(
                       new DHPublicKeyParameters(y, dhp),
                       new DHPrivateKeyParameters(x, dhp)));
        }
Example #2
0
        public AsymmetricCipherKeyPair GenerateKeyPair()
        {
            DHKeyGeneratorHelper helper = DHKeyGeneratorHelper.Instance;
            ElGamalParameters    egp    = param.Parameters;
            DHParameters         dhp    = new DHParameters(egp.P, egp.G, null, 0, egp.L);

            BigInteger x = helper.CalculatePrivate(dhp, param.Random);
            BigInteger y = helper.CalculatePublic(dhp, x);

            return(new AsymmetricCipherKeyPair(
                       new ElGamalPublicKeyParameters(y, egp),
                       new ElGamalPrivateKeyParameters(x, egp)));
        }