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

package org.bouncycastle.pqc.crypto.saber;

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 SABERKeyPairGenerator implements AsymmetricCipherKeyPairGenerator
{
    private SABERKeyGenerationParameters saberParams;
    private int l;
    private SecureRandom random;
    
    private void initialize(final KeyGenerationParameters keyGenerationParameters) {
        this.saberParams = (SABERKeyGenerationParameters)keyGenerationParameters;
        this.random = keyGenerationParameters.getRandom();
        this.l = this.saberParams.getParameters().getL();
    }
    
    private AsymmetricCipherKeyPair genKeyPair() {
        final SABEREngine engine = this.saberParams.getParameters().getEngine();
        final byte[] array = new byte[engine.getPrivateKeySize()];
        final byte[] array2 = new byte[engine.getPublicKeySize()];
        engine.crypto_kem_keypair(array2, array, this.random);
        return new AsymmetricCipherKeyPair(new SABERPublicKeyParameters(this.saberParams.getParameters(), array2), new SABERPrivateKeyParameters(this.saberParams.getParameters(), array));
    }
    
    @Override
    public void init(final KeyGenerationParameters keyGenerationParameters) {
        this.initialize(keyGenerationParameters);
    }
    
    @Override
    public AsymmetricCipherKeyPair generateKeyPair() {
        return this.genKeyPair();
    }
}
