package org.bouncycastle.crypto.params;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public final class Ed25519PublicKeyParameters extends org.bouncycastle.crypto.params.AsymmetricKeyParameter {
    private final org.bouncycastle.math.ec.rfc8032.Ed25519.PublicPoint b;

    public Ed25519PublicKeyParameters(org.bouncycastle.math.ec.rfc8032.Ed25519.PublicPoint publicPoint) {
        super(false);
        if (publicPoint == null) {
            throw new java.lang.NullPointerException("'publicPoint' cannot be null");
        }
        this.b = publicPoint;
    }

    private static org.bouncycastle.math.ec.rfc8032.Ed25519.PublicPoint h(byte[] bArr, int i) {
        org.bouncycastle.math.ec.rfc8032.Ed25519.PublicPoint publicPointS = org.bouncycastle.math.ec.rfc8032.Ed25519.S(bArr, i);
        if (publicPointS != null) {
            return publicPointS;
        }
        throw new java.lang.IllegalArgumentException("invalid public key");
    }

    private static byte[] i(byte[] bArr) {
        if (bArr.length == 32) {
            return bArr;
        }
        throw new java.lang.IllegalArgumentException("'buf' must have length 32");
    }

    public void g(byte[] bArr, int i) {
        org.bouncycastle.math.ec.rfc8032.Ed25519.l(this.b, bArr, i);
    }

    public byte[] getEncoded() {
        byte[] bArr = new byte[32];
        g(bArr, 0);
        return bArr;
    }

    public boolean j(int i, byte[] bArr, byte[] bArr2, int i2, int i3, byte[] bArr3, int i4) {
        if (i == 0) {
            if (bArr == null) {
                return org.bouncycastle.math.ec.rfc8032.Ed25519.T(bArr3, i4, this.b, bArr2, i2, i3);
            }
            throw new java.lang.IllegalArgumentException("ctx");
        }
        if (i == 1) {
            if (bArr == null) {
                throw new java.lang.NullPointerException("'ctx' cannot be null");
            }
            if (bArr.length <= 255) {
                return org.bouncycastle.math.ec.rfc8032.Ed25519.U(bArr3, i4, this.b, bArr, bArr2, i2, i3);
            }
            throw new java.lang.IllegalArgumentException("ctx");
        }
        if (i != 2) {
            throw new java.lang.IllegalArgumentException("algorithm");
        }
        if (bArr == null) {
            throw new java.lang.NullPointerException("'ctx' cannot be null");
        }
        if (bArr.length > 255) {
            throw new java.lang.IllegalArgumentException("ctx");
        }
        if (64 == i3) {
            return org.bouncycastle.math.ec.rfc8032.Ed25519.V(bArr3, i4, this.b, bArr, bArr2, i2);
        }
        throw new java.lang.IllegalArgumentException("msgLen");
    }

    public Ed25519PublicKeyParameters(byte[] bArr) {
        this(i(bArr), 0);
    }

    public Ed25519PublicKeyParameters(byte[] bArr, int i) {
        super(false);
        this.b = h(bArr, i);
    }
}
