Search in sources :

Example 1 with ElGamalPublicKeyImpl

use of net.i2p.crypto.elgamal.impl.ElGamalPublicKeyImpl in project i2p.i2p by i2p.

the class KeyPairGenerator method generateKeyPair.

public KeyPair generateKeyPair() {
    if (!initialized)
        initialize(DEFAULT_STRENGTH, RandomSource.getInstance());
    KeyGenerator kg = KeyGenerator.getInstance();
    SimpleDataStructure[] keys = kg.generatePKIKeys();
    PublicKey pubKey = (PublicKey) keys[0];
    PrivateKey privKey = (PrivateKey) keys[1];
    ElGamalPublicKey epubKey = new ElGamalPublicKeyImpl(new NativeBigInteger(1, pubKey.getData()), elgParams);
    ElGamalPrivateKey eprivKey = new ElGamalPrivateKeyImpl(new NativeBigInteger(1, privKey.getData()), elgParams);
    return new KeyPair(epubKey, eprivKey);
}
Also used : KeyPair(java.security.KeyPair) PrivateKey(net.i2p.data.PrivateKey) ElGamalPublicKeyImpl(net.i2p.crypto.elgamal.impl.ElGamalPublicKeyImpl) NativeBigInteger(net.i2p.util.NativeBigInteger) ElGamalPrivateKeyImpl(net.i2p.crypto.elgamal.impl.ElGamalPrivateKeyImpl) PublicKey(net.i2p.data.PublicKey) KeyGenerator(net.i2p.crypto.KeyGenerator) SimpleDataStructure(net.i2p.data.SimpleDataStructure)

Aggregations

KeyPair (java.security.KeyPair)1 KeyGenerator (net.i2p.crypto.KeyGenerator)1 ElGamalPrivateKeyImpl (net.i2p.crypto.elgamal.impl.ElGamalPrivateKeyImpl)1 ElGamalPublicKeyImpl (net.i2p.crypto.elgamal.impl.ElGamalPublicKeyImpl)1 PrivateKey (net.i2p.data.PrivateKey)1 PublicKey (net.i2p.data.PublicKey)1 SimpleDataStructure (net.i2p.data.SimpleDataStructure)1 NativeBigInteger (net.i2p.util.NativeBigInteger)1