package org.bouncycastle.crypto.generators;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class ECKeyPairGenerator implements org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator, org.bouncycastle.math.ec.ECConstants {
    private final java.lang.String g;
    org.bouncycastle.crypto.params.ECDomainParameters h;
    java.security.SecureRandom i;

    public ECKeyPairGenerator() {
        this("ECKeyGen");
    }

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public org.bouncycastle.crypto.AsymmetricCipherKeyPair a() {
        java.math.BigInteger bigIntegerE = this.h.e();
        int iBitLength = bigIntegerE.bitLength();
        int i = iBitLength >>> 2;
        while (true) {
            java.math.BigInteger bigIntegerF = org.bouncycastle.util.BigIntegers.f(iBitLength, this.i);
            if (!d(bigIntegerF, bigIntegerE) && org.bouncycastle.math.ec.WNafUtil.h(bigIntegerF) >= i) {
                return new org.bouncycastle.crypto.AsymmetricCipherKeyPair(new org.bouncycastle.crypto.params.ECPublicKeyParameters(c().a(this.h.b(), bigIntegerF), this.h), new org.bouncycastle.crypto.params.ECPrivateKeyParameters(bigIntegerF, this.h));
            }
        }
    }

    @Override // org.bouncycastle.crypto.AsymmetricCipherKeyPairGenerator
    public void b(org.bouncycastle.crypto.KeyGenerationParameters keyGenerationParameters) {
        org.bouncycastle.crypto.params.ECKeyGenerationParameters eCKeyGenerationParameters = (org.bouncycastle.crypto.params.ECKeyGenerationParameters) keyGenerationParameters;
        this.i = eCKeyGenerationParameters.a();
        org.bouncycastle.crypto.params.ECDomainParameters eCDomainParametersC = eCKeyGenerationParameters.c();
        this.h = eCDomainParametersC;
        org.bouncycastle.crypto.CryptoServicesRegistrar.a(new org.bouncycastle.crypto.constraints.DefaultServiceProperties(this.g, org.bouncycastle.crypto.constraints.ConstraintUtils.b(eCDomainParametersC.a()), eCKeyGenerationParameters.c(), org.bouncycastle.crypto.CryptoServicePurpose.KEYGEN));
    }

    protected org.bouncycastle.math.ec.ECMultiplier c() {
        return new org.bouncycastle.math.ec.FixedPointCombMultiplier();
    }

    protected boolean d(java.math.BigInteger bigInteger, java.math.BigInteger bigInteger2) {
        return bigInteger.compareTo(org.bouncycastle.math.ec.ECConstants.b) < 0 || bigInteger.compareTo(bigInteger2) >= 0;
    }

    protected ECKeyPairGenerator(java.lang.String str) {
        this.g = str;
    }
}
