// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.pqc.crypto.frodo;

import org.bouncycastle.crypto.params.AsymmetricKeyParameter;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.KeyGenerationParameters;
import java.security.SecureRandom;
import org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator;

public class FrodoKeyPairGenerator implements AsymmetricCipherKeyPairGenerator
{
    private FrodoKeyGenerationParameters frodoParams;
    private int n;
    private int D;
    private int B;
    private SecureRandom random;
    
    private void initialize(final KeyGenerationParameters keyGenerationParameters) {
        this.frodoParams = (FrodoKeyGenerationParameters)keyGenerationParameters;
        this.random = keyGenerationParameters.getRandom();
        this.n = this.frodoParams.getParameters().getN();
        this.D = this.frodoParams.getParameters().getD();
        this.B = this.frodoParams.getParameters().getB();
    }
    
    private AsymmetricCipherKeyPair genKeyPair() {
        final FrodoEngine engine = this.frodoParams.getParameters().getEngine();
        final byte[] array = new byte[engine.getPrivateKeySize()];
        final byte[] array2 = new byte[engine.getPublicKeySize()];
        engine.kem_keypair(array2, array, this.random);
        return new AsymmetricCipherKeyPair(new FrodoPublicKeyParameters(this.frodoParams.getParameters(), array2), new FrodoPrivateKeyParameters(this.frodoParams.getParameters(), array));
    }
    
    @Override
    public void init(final KeyGenerationParameters keyGenerationParameters) {
        this.initialize(keyGenerationParameters);
    }
    
    @Override
    public AsymmetricCipherKeyPair generateKeyPair() {
        return this.genKeyPair();
    }
}
