package com.google.android.gms.internal.ads;

import java.lang.reflect.Array;
import java.math.BigInteger;

/* JADX INFO: loaded from: classes2.dex */
public abstract class qz1 {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final long[] f15907a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static final long[] f15908b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static final long[] f15909c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static final nz1[][] f15910d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public static final nz1[] f15911e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public static final BigInteger f15912f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public static final BigInteger f15913g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public static final BigInteger f15914h;

    static {
        BigInteger bigIntegerSubtract = BigInteger.valueOf(2L).pow(255).subtract(BigInteger.valueOf(19L));
        f15912f = bigIntegerSubtract;
        BigInteger bigIntegerMod = BigInteger.valueOf(-121665L).multiply(BigInteger.valueOf(121666L).modInverse(bigIntegerSubtract)).mod(bigIntegerSubtract);
        f15913g = bigIntegerMod;
        BigInteger bigIntegerMod2 = BigInteger.valueOf(2L).multiply(bigIntegerMod).mod(bigIntegerSubtract);
        f15914h = bigIntegerMod2;
        BigInteger bigIntegerValueOf = BigInteger.valueOf(2L);
        BigInteger bigInteger = BigInteger.ONE;
        BigInteger bigIntegerModPow = bigIntegerValueOf.modPow(bigIntegerSubtract.subtract(bigInteger).divide(BigInteger.valueOf(4L)), bigIntegerSubtract);
        uz0 uz0Var = new uz0(12, (Object) null);
        BigInteger bigIntegerMod3 = BigInteger.valueOf(4L).multiply(BigInteger.valueOf(5L).modInverse(bigIntegerSubtract)).mod(bigIntegerSubtract);
        uz0Var.f17460b = bigIntegerMod3;
        BigInteger bigIntegerMultiply = bigIntegerMod3.pow(2).subtract(bigInteger).multiply(bigIntegerMod.multiply(bigIntegerMod3.pow(2)).add(bigInteger).modInverse(bigIntegerSubtract));
        BigInteger bigIntegerModPow2 = bigIntegerMultiply.modPow(bigIntegerSubtract.add(BigInteger.valueOf(3L)).divide(BigInteger.valueOf(8L)), bigIntegerSubtract);
        if (!bigIntegerModPow2.pow(2).subtract(bigIntegerMultiply).mod(bigIntegerSubtract).equals(BigInteger.ZERO)) {
            bigIntegerModPow2 = bigIntegerModPow2.multiply(bigIntegerModPow).mod(bigIntegerSubtract);
        }
        if (bigIntegerModPow2.testBit(0)) {
            bigIntegerModPow2 = bigIntegerSubtract.subtract(bigIntegerModPow2);
        }
        uz0Var.f17461c = bigIntegerModPow2;
        f15907a = vj1.q(b(bigIntegerMod));
        f15908b = vj1.q(b(bigIntegerMod2));
        f15909c = vj1.q(b(bigIntegerModPow));
        f15910d = (nz1[][]) Array.newInstance((Class<?>) nz1.class, 32, 8);
        uz0 uz0VarA = uz0Var;
        for (int i10 = 0; i10 < 32; i10++) {
            uz0 uz0VarA2 = uz0VarA;
            for (int i11 = 0; i11 < 8; i11++) {
                f15910d[i10][i11] = c(uz0VarA2);
                uz0VarA2 = a(uz0VarA2, uz0VarA);
            }
            for (int i12 = 0; i12 < 8; i12++) {
                uz0VarA = a(uz0VarA, uz0VarA);
            }
        }
        uz0 uz0VarA3 = a(uz0Var, uz0Var);
        f15911e = new nz1[8];
        for (int i13 = 0; i13 < 8; i13++) {
            f15911e[i13] = c(uz0Var);
            uz0Var = a(uz0Var, uz0VarA3);
        }
    }

    public static uz0 a(uz0 uz0Var, uz0 uz0Var2) {
        uz0 uz0Var3 = new uz0(12, (Object) null);
        BigInteger bigIntegerMultiply = f15913g.multiply(((BigInteger) uz0Var.f17461c).multiply((BigInteger) uz0Var2.f17461c).multiply((BigInteger) uz0Var.f17460b).multiply((BigInteger) uz0Var2.f17460b));
        BigInteger bigInteger = f15912f;
        BigInteger bigIntegerMod = bigIntegerMultiply.mod(bigInteger);
        BigInteger bigIntegerAdd = ((BigInteger) uz0Var.f17461c).multiply((BigInteger) uz0Var2.f17460b).add(((BigInteger) uz0Var2.f17461c).multiply((BigInteger) uz0Var.f17460b));
        BigInteger bigInteger2 = BigInteger.ONE;
        uz0Var3.f17461c = bigIntegerAdd.multiply(bigInteger2.add(bigIntegerMod).modInverse(bigInteger)).mod(bigInteger);
        uz0Var3.f17460b = ((BigInteger) uz0Var.f17460b).multiply((BigInteger) uz0Var2.f17460b).add(((BigInteger) uz0Var.f17461c).multiply((BigInteger) uz0Var2.f17461c)).multiply(bigInteger2.subtract(bigIntegerMod).modInverse(bigInteger)).mod(bigInteger);
        return uz0Var3;
    }

    public static byte[] b(BigInteger bigInteger) {
        byte[] bArr = new byte[32];
        byte[] byteArray = bigInteger.toByteArray();
        int length = byteArray.length;
        System.arraycopy(byteArray, 0, bArr, 32 - length, length);
        for (int i10 = 0; i10 < 16; i10++) {
            byte b10 = bArr[i10];
            int i11 = 31 - i10;
            bArr[i10] = bArr[i11];
            bArr[i11] = b10;
        }
        return bArr;
    }

    public static nz1 c(uz0 uz0Var) {
        BigInteger bigIntegerAdd = ((BigInteger) uz0Var.f17460b).add((BigInteger) uz0Var.f17461c);
        BigInteger bigInteger = f15912f;
        return new nz1(vj1.q(b(bigIntegerAdd.mod(bigInteger))), vj1.q(b(((BigInteger) uz0Var.f17460b).subtract((BigInteger) uz0Var.f17461c).mod(bigInteger))), vj1.q(b(f15914h.multiply((BigInteger) uz0Var.f17461c).multiply((BigInteger) uz0Var.f17460b).mod(bigInteger))));
    }
}
