686 lines
26 KiB
Java
686 lines
26 KiB
Java
|
package org.bouncycastle.math.raw;
|
||
|
|
||
|
import java.math.BigInteger;
|
||
|
import org.bouncycastle.asn1.cmp.PKIFailureInfo;
|
||
|
import org.bouncycastle.util.Pack;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public abstract class Nat160 {
|
||
|
private static final long M = 4294967295L;
|
||
|
|
||
|
public static void zero(int[] iArr) {
|
||
|
iArr[0] = 0;
|
||
|
iArr[1] = 0;
|
||
|
iArr[2] = 0;
|
||
|
iArr[3] = 0;
|
||
|
iArr[4] = 0;
|
||
|
}
|
||
|
|
||
|
public static BigInteger toBigInteger(int[] iArr) {
|
||
|
byte[] bArr = new byte[20];
|
||
|
for (int i = 0; i < 5; i++) {
|
||
|
int i2 = iArr[i];
|
||
|
if (i2 != 0) {
|
||
|
Pack.intToBigEndian(i2, bArr, (4 - i) << 2);
|
||
|
}
|
||
|
}
|
||
|
return new BigInteger(1, bArr);
|
||
|
}
|
||
|
|
||
|
public static int subFrom(int[] iArr, int[] iArr2) {
|
||
|
long j = (iArr2[0] & 4294967295L) - (iArr[0] & 4294967295L);
|
||
|
iArr2[0] = (int) j;
|
||
|
long j2 = (j >> 32) + ((iArr2[1] & 4294967295L) - (iArr[1] & 4294967295L));
|
||
|
iArr2[1] = (int) j2;
|
||
|
long j3 = (j2 >> 32) + ((iArr2[2] & 4294967295L) - (iArr[2] & 4294967295L));
|
||
|
iArr2[2] = (int) j3;
|
||
|
long j4 = (j3 >> 32) + ((iArr2[3] & 4294967295L) - (iArr[3] & 4294967295L));
|
||
|
iArr2[3] = (int) j4;
|
||
|
long j5 = (j4 >> 32) + ((iArr2[4] & 4294967295L) - (4294967295L & iArr[4]));
|
||
|
iArr2[4] = (int) j5;
|
||
|
return (int) (j5 >> 32);
|
||
|
}
|
||
|
|
||
|
public static int subFrom(int[] iArr, int i, int[] iArr2, int i2) {
|
||
|
long j = (iArr2[i2] & 4294967295L) - (iArr[i] & 4294967295L);
|
||
|
iArr2[i2] = (int) j;
|
||
|
long j2 = (j >> 32) + ((iArr2[r4] & 4294967295L) - (iArr[i + 1] & 4294967295L));
|
||
|
iArr2[i2 + 1] = (int) j2;
|
||
|
long j3 = (j2 >> 32) + ((iArr2[r4] & 4294967295L) - (iArr[i + 2] & 4294967295L));
|
||
|
iArr2[i2 + 2] = (int) j3;
|
||
|
long j4 = (j3 >> 32) + ((iArr2[r4] & 4294967295L) - (iArr[i + 3] & 4294967295L));
|
||
|
iArr2[i2 + 3] = (int) j4;
|
||
|
long j5 = (j4 >> 32) + ((iArr2[r13] & 4294967295L) - (iArr[i + 4] & 4294967295L));
|
||
|
iArr2[i2 + 4] = (int) j5;
|
||
|
return (int) (j5 >> 32);
|
||
|
}
|
||
|
|
||
|
public static int subBothFrom(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
long j = ((iArr3[0] & 4294967295L) - (iArr[0] & 4294967295L)) - (iArr2[0] & 4294967295L);
|
||
|
iArr3[0] = (int) j;
|
||
|
long j2 = (j >> 32) + (((iArr3[1] & 4294967295L) - (iArr[1] & 4294967295L)) - (iArr2[1] & 4294967295L));
|
||
|
iArr3[1] = (int) j2;
|
||
|
long j3 = (j2 >> 32) + (((iArr3[2] & 4294967295L) - (iArr[2] & 4294967295L)) - (iArr2[2] & 4294967295L));
|
||
|
iArr3[2] = (int) j3;
|
||
|
long j4 = (j3 >> 32) + (((iArr3[3] & 4294967295L) - (iArr[3] & 4294967295L)) - (iArr2[3] & 4294967295L));
|
||
|
iArr3[3] = (int) j4;
|
||
|
long j5 = (j4 >> 32) + (((iArr3[4] & 4294967295L) - (iArr[4] & 4294967295L)) - (iArr2[4] & 4294967295L));
|
||
|
iArr3[4] = (int) j5;
|
||
|
return (int) (j5 >> 32);
|
||
|
}
|
||
|
|
||
|
public static int sub(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
long j = (iArr[0] & 4294967295L) - (iArr2[0] & 4294967295L);
|
||
|
iArr3[0] = (int) j;
|
||
|
long j2 = (j >> 32) + ((iArr[1] & 4294967295L) - (iArr2[1] & 4294967295L));
|
||
|
iArr3[1] = (int) j2;
|
||
|
long j3 = (j2 >> 32) + ((iArr[2] & 4294967295L) - (iArr2[2] & 4294967295L));
|
||
|
iArr3[2] = (int) j3;
|
||
|
long j4 = (j3 >> 32) + ((iArr[3] & 4294967295L) - (iArr2[3] & 4294967295L));
|
||
|
iArr3[3] = (int) j4;
|
||
|
long j5 = (j4 >> 32) + ((iArr[4] & 4294967295L) - (iArr2[4] & 4294967295L));
|
||
|
iArr3[4] = (int) j5;
|
||
|
return (int) (j5 >> 32);
|
||
|
}
|
||
|
|
||
|
public static int sub(int[] iArr, int i, int[] iArr2, int i2, int[] iArr3, int i3) {
|
||
|
long j = (iArr[i] & 4294967295L) - (iArr2[i2] & 4294967295L);
|
||
|
iArr3[i3] = (int) j;
|
||
|
long j2 = (j >> 32) + ((iArr[i + 1] & 4294967295L) - (iArr2[i2 + 1] & 4294967295L));
|
||
|
iArr3[i3 + 1] = (int) j2;
|
||
|
long j3 = (j2 >> 32) + ((iArr[i + 2] & 4294967295L) - (iArr2[i2 + 2] & 4294967295L));
|
||
|
iArr3[i3 + 2] = (int) j3;
|
||
|
long j4 = (j3 >> 32) + ((iArr[i + 3] & 4294967295L) - (iArr2[i2 + 3] & 4294967295L));
|
||
|
iArr3[i3 + 3] = (int) j4;
|
||
|
long j5 = (j4 >> 32) + ((iArr[i + 4] & 4294967295L) - (iArr2[i2 + 4] & 4294967295L));
|
||
|
iArr3[i3 + 4] = (int) j5;
|
||
|
return (int) (j5 >> 32);
|
||
|
}
|
||
|
|
||
|
public static void square(int[] iArr, int[] iArr2) {
|
||
|
long j = iArr[0] & 4294967295L;
|
||
|
int i = 10;
|
||
|
int i2 = 0;
|
||
|
int i3 = 4;
|
||
|
while (true) {
|
||
|
int i4 = i3 - 1;
|
||
|
long j2 = iArr[i3] & 4294967295L;
|
||
|
long j3 = j2 * j2;
|
||
|
iArr2[i - 1] = (i2 << 31) | ((int) (j3 >>> 33));
|
||
|
i -= 2;
|
||
|
iArr2[i] = (int) (j3 >>> 1);
|
||
|
i2 = (int) j3;
|
||
|
if (i4 <= 0) {
|
||
|
long j4 = j * j;
|
||
|
iArr2[0] = (int) j4;
|
||
|
int i5 = (int) (j4 >>> 32);
|
||
|
long j5 = iArr[1] & 4294967295L;
|
||
|
long j6 = iArr2[2];
|
||
|
long j7 = ((j4 >>> 33) | ((i2 << 31) & 4294967295L)) + (j5 * j);
|
||
|
int i6 = (int) j7;
|
||
|
iArr2[1] = (i5 & 1) | (i6 << 1);
|
||
|
long j8 = iArr[2] & 4294967295L;
|
||
|
long j9 = iArr2[3];
|
||
|
long j10 = iArr2[4];
|
||
|
long j11 = (j6 & 4294967295L) + (j7 >>> 32) + (j8 * j);
|
||
|
int i7 = (int) j11;
|
||
|
iArr2[2] = (i7 << 1) | (i6 >>> 31);
|
||
|
long j12 = (j9 & 4294967295L) + (j11 >>> 32) + (j8 * j5);
|
||
|
long j13 = iArr[3] & 4294967295L;
|
||
|
long j14 = iArr2[5];
|
||
|
long j15 = iArr2[6];
|
||
|
long j16 = (j12 & 4294967295L) + (j13 * j);
|
||
|
int i8 = (int) j16;
|
||
|
iArr2[3] = (i8 << 1) | (i7 >>> 31);
|
||
|
long j17 = (j10 & 4294967295L) + (j12 >>> 32) + (j16 >>> 32) + (j13 * j5);
|
||
|
long j18 = (j14 & 4294967295L) + (j17 >>> 32) + (j13 * j8);
|
||
|
long j19 = iArr[4] & 4294967295L;
|
||
|
long j20 = iArr2[7];
|
||
|
long j21 = iArr2[8];
|
||
|
long j22 = (j17 & 4294967295L) + (j * j19);
|
||
|
int i9 = (int) j22;
|
||
|
iArr2[4] = (i8 >>> 31) | (i9 << 1);
|
||
|
long j23 = (j18 & 4294967295L) + (j22 >>> 32) + (j5 * j19);
|
||
|
long j24 = (j15 & 4294967295L) + (j18 >>> 32) + (j23 >>> 32) + (j8 * j19);
|
||
|
long j25 = (j20 & 4294967295L) + (j24 >>> 32) + (j19 * j13);
|
||
|
long j26 = (j21 & 4294967295L) + (j25 >>> 32);
|
||
|
int i10 = (int) j23;
|
||
|
iArr2[5] = (i9 >>> 31) | (i10 << 1);
|
||
|
int i11 = (int) j24;
|
||
|
iArr2[6] = (i10 >>> 31) | (i11 << 1);
|
||
|
int i12 = (int) j25;
|
||
|
iArr2[7] = (i11 >>> 31) | (i12 << 1);
|
||
|
int i13 = (int) j26;
|
||
|
iArr2[8] = (i12 >>> 31) | (i13 << 1);
|
||
|
iArr2[9] = (i13 >>> 31) | ((iArr2[9] + ((int) (j26 >> 32))) << 1);
|
||
|
return;
|
||
|
}
|
||
|
i3 = i4;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void square(int[] iArr, int i, int[] iArr2, int i2) {
|
||
|
long j = iArr[i] & 4294967295L;
|
||
|
int i3 = 0;
|
||
|
int i4 = 10;
|
||
|
int i5 = 4;
|
||
|
while (true) {
|
||
|
int i6 = i5 - 1;
|
||
|
long j2 = iArr[i + i5] & 4294967295L;
|
||
|
long j3 = j2 * j2;
|
||
|
iArr2[i2 + (i4 - 1)] = (i3 << 31) | ((int) (j3 >>> 33));
|
||
|
i4 -= 2;
|
||
|
iArr2[i2 + i4] = (int) (j3 >>> 1);
|
||
|
i3 = (int) j3;
|
||
|
if (i6 <= 0) {
|
||
|
long j4 = j * j;
|
||
|
iArr2[i2] = (int) j4;
|
||
|
int i7 = (int) (j4 >>> 32);
|
||
|
long j5 = iArr[i + 1] & 4294967295L;
|
||
|
int i8 = i2 + 2;
|
||
|
long j6 = iArr2[i8];
|
||
|
long j7 = (((i3 << 31) & 4294967295L) | (j4 >>> 33)) + (j5 * j);
|
||
|
int i9 = (int) j7;
|
||
|
iArr2[i2 + 1] = (i9 << 1) | (i7 & 1);
|
||
|
long j8 = iArr[i + 2] & 4294967295L;
|
||
|
int i10 = i2 + 3;
|
||
|
long j9 = iArr2[i10];
|
||
|
int i11 = i2 + 4;
|
||
|
long j10 = iArr2[i11];
|
||
|
long j11 = (j6 & 4294967295L) + (j7 >>> 32) + (j8 * j);
|
||
|
int i12 = (int) j11;
|
||
|
iArr2[i8] = (i12 << 1) | (i9 >>> 31);
|
||
|
long j12 = (j9 & 4294967295L) + (j11 >>> 32) + (j8 * j5);
|
||
|
long j13 = iArr[i + 3] & 4294967295L;
|
||
|
int i13 = i2 + 5;
|
||
|
long j14 = iArr2[i13];
|
||
|
int i14 = i2 + 6;
|
||
|
long j15 = iArr2[i14];
|
||
|
long j16 = (j12 & 4294967295L) + (j13 * j);
|
||
|
int i15 = (int) j16;
|
||
|
iArr2[i10] = (i15 << 1) | (i12 >>> 31);
|
||
|
long j17 = (j10 & 4294967295L) + (j12 >>> 32) + (j16 >>> 32) + (j13 * j5);
|
||
|
long j18 = (j14 & 4294967295L) + (j17 >>> 32) + (j13 * j8);
|
||
|
long j19 = iArr[i + 4] & 4294967295L;
|
||
|
int i16 = i2 + 7;
|
||
|
long j20 = iArr2[i16];
|
||
|
int i17 = i2 + 8;
|
||
|
long j21 = iArr2[i17];
|
||
|
long j22 = (j17 & 4294967295L) + (j * j19);
|
||
|
int i18 = (int) j22;
|
||
|
iArr2[i11] = (i18 << 1) | (i15 >>> 31);
|
||
|
long j23 = (j18 & 4294967295L) + (j22 >>> 32) + (j5 * j19);
|
||
|
long j24 = (j15 & 4294967295L) + (j18 >>> 32) + (j23 >>> 32) + (j19 * j8);
|
||
|
long j25 = (j20 & 4294967295L) + (j24 >>> 32) + (j19 * j13);
|
||
|
long j26 = (j21 & 4294967295L) + (j25 >>> 32);
|
||
|
int i19 = (int) j23;
|
||
|
iArr2[i13] = (i18 >>> 31) | (i19 << 1);
|
||
|
int i20 = (int) j24;
|
||
|
iArr2[i14] = (i19 >>> 31) | (i20 << 1);
|
||
|
int i21 = (int) j25;
|
||
|
iArr2[i16] = (i20 >>> 31) | (i21 << 1);
|
||
|
int i22 = (int) j26;
|
||
|
iArr2[i17] = (i21 >>> 31) | (i22 << 1);
|
||
|
int i23 = i2 + 9;
|
||
|
iArr2[i23] = (i22 >>> 31) | ((iArr2[i23] + ((int) (j26 >> 32))) << 1);
|
||
|
return;
|
||
|
}
|
||
|
i5 = i6;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static int mulWordsAdd(int i, int i2, int[] iArr, int i3) {
|
||
|
long j = ((i2 & 4294967295L) * (i & 4294967295L)) + (iArr[i3] & 4294967295L);
|
||
|
iArr[i3] = (int) j;
|
||
|
long j2 = (j >>> 32) + (4294967295L & iArr[r0]);
|
||
|
iArr[i3 + 1] = (int) j2;
|
||
|
if ((j2 >>> 32) == 0) {
|
||
|
return 0;
|
||
|
}
|
||
|
return Nat.incAt(5, iArr, i3, 2);
|
||
|
}
|
||
|
|
||
|
public static int mulWordDwordAdd(int i, long j, int[] iArr, int i2) {
|
||
|
long j2 = i & 4294967295L;
|
||
|
long j3 = ((j & 4294967295L) * j2) + (iArr[i2] & 4294967295L);
|
||
|
iArr[i2] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + (j2 * (j >>> 32)) + (iArr[r8] & 4294967295L);
|
||
|
iArr[i2 + 1] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (iArr[r8] & 4294967295L);
|
||
|
iArr[i2 + 2] = (int) j5;
|
||
|
if ((j5 >>> 32) == 0) {
|
||
|
return 0;
|
||
|
}
|
||
|
return Nat.incAt(5, iArr, i2, 3);
|
||
|
}
|
||
|
|
||
|
public static int mulWordAddExt(int i, int[] iArr, int i2, int[] iArr2, int i3) {
|
||
|
long j = i & 4294967295L;
|
||
|
long j2 = ((iArr[i2] & 4294967295L) * j) + (iArr2[i3] & 4294967295L);
|
||
|
iArr2[i3] = (int) j2;
|
||
|
long j3 = (j2 >>> 32) + ((iArr[i2 + 1] & 4294967295L) * j) + (iArr2[r11] & 4294967295L);
|
||
|
iArr2[i3 + 1] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + ((iArr[i2 + 2] & 4294967295L) * j) + (iArr2[r11] & 4294967295L);
|
||
|
iArr2[i3 + 2] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + ((iArr[i2 + 3] & 4294967295L) * j) + (iArr2[r11] & 4294967295L);
|
||
|
iArr2[i3 + 3] = (int) j5;
|
||
|
long j6 = (j5 >>> 32) + (j * (iArr[i2 + 4] & 4294967295L)) + (iArr2[r15] & 4294967295L);
|
||
|
iArr2[i3 + 4] = (int) j6;
|
||
|
return (int) (j6 >>> 32);
|
||
|
}
|
||
|
|
||
|
public static int mulWord(int i, int[] iArr, int[] iArr2, int i2) {
|
||
|
long j = i;
|
||
|
long j2 = 0;
|
||
|
int i3 = 0;
|
||
|
do {
|
||
|
long j3 = j2 + ((iArr[i3] & 4294967295L) * (4294967295L & j));
|
||
|
iArr2[i2 + i3] = (int) j3;
|
||
|
j2 = j3 >>> 32;
|
||
|
i3++;
|
||
|
} while (i3 < 5);
|
||
|
return (int) j2;
|
||
|
}
|
||
|
|
||
|
public static int mulAddTo(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
int i = 0;
|
||
|
long j = iArr2[0] & 4294967295L;
|
||
|
long j2 = iArr2[1] & 4294967295L;
|
||
|
long j3 = iArr2[2];
|
||
|
long j4 = iArr2[3];
|
||
|
long j5 = iArr2[4];
|
||
|
long j6 = 0;
|
||
|
while (i < 5) {
|
||
|
long j7 = j6;
|
||
|
long j8 = iArr[i] & 4294967295L;
|
||
|
long j9 = j;
|
||
|
long j10 = (j8 * j) + (iArr3[i] & 4294967295L);
|
||
|
iArr3[i] = (int) j10;
|
||
|
int i2 = i + 1;
|
||
|
long j11 = j2;
|
||
|
long j12 = (j10 >>> 32) + (j8 * j2) + (iArr3[i2] & 4294967295L);
|
||
|
iArr3[i2] = (int) j12;
|
||
|
long j13 = (j12 >>> 32) + ((j3 & 4294967295L) * j8) + (iArr3[r5] & 4294967295L);
|
||
|
iArr3[i + 2] = (int) j13;
|
||
|
long j14 = (j13 >>> 32) + ((j4 & 4294967295L) * j8) + (iArr3[r5] & 4294967295L);
|
||
|
iArr3[i + 3] = (int) j14;
|
||
|
long j15 = (j14 >>> 32) + (j8 * (j5 & 4294967295L)) + (iArr3[r5] & 4294967295L);
|
||
|
iArr3[i + 4] = (int) j15;
|
||
|
long j16 = (j15 >>> 32) + j7 + (iArr3[r0] & 4294967295L);
|
||
|
iArr3[i + 5] = (int) j16;
|
||
|
j6 = j16 >>> 32;
|
||
|
i = i2;
|
||
|
j = j9;
|
||
|
j4 = j4;
|
||
|
j2 = j11;
|
||
|
j3 = j3;
|
||
|
}
|
||
|
return (int) j6;
|
||
|
}
|
||
|
|
||
|
public static int mulAddTo(int[] iArr, int i, int[] iArr2, int i2, int[] iArr3, int i3) {
|
||
|
long j = iArr2[i2] & 4294967295L;
|
||
|
long j2 = iArr2[i2 + 1] & 4294967295L;
|
||
|
long j3 = iArr2[i2 + 2];
|
||
|
long j4 = iArr2[i2 + 3];
|
||
|
long j5 = iArr2[i2 + 4];
|
||
|
long j6 = 0;
|
||
|
int i4 = 0;
|
||
|
int i5 = i3;
|
||
|
while (i4 < 5) {
|
||
|
long j7 = iArr[i + i4] & 4294967295L;
|
||
|
long j8 = j;
|
||
|
long j9 = (j7 * j) + (iArr3[i5] & 4294967295L);
|
||
|
int i6 = i4;
|
||
|
iArr3[i5] = (int) j9;
|
||
|
int i7 = i5 + 1;
|
||
|
long j10 = j2;
|
||
|
long j11 = (j9 >>> 32) + (j7 * j2) + (iArr3[i7] & 4294967295L);
|
||
|
iArr3[i7] = (int) j11;
|
||
|
long j12 = (j11 >>> 32) + ((j3 & 4294967295L) * j7) + (iArr3[r4] & 4294967295L);
|
||
|
iArr3[i5 + 2] = (int) j12;
|
||
|
long j13 = (j12 >>> 32) + ((j4 & 4294967295L) * j7) + (iArr3[r4] & 4294967295L);
|
||
|
iArr3[i5 + 3] = (int) j13;
|
||
|
long j14 = (j13 >>> 32) + (j7 * (j5 & 4294967295L)) + (iArr3[r4] & 4294967295L);
|
||
|
iArr3[i5 + 4] = (int) j14;
|
||
|
long j15 = (j14 >>> 32) + j6 + (iArr3[r12] & 4294967295L);
|
||
|
iArr3[i5 + 5] = (int) j15;
|
||
|
j6 = j15 >>> 32;
|
||
|
i5 = i7;
|
||
|
j4 = j4;
|
||
|
j2 = j10;
|
||
|
j3 = j3;
|
||
|
i4 = i6 + 1;
|
||
|
j = j8;
|
||
|
}
|
||
|
return (int) j6;
|
||
|
}
|
||
|
|
||
|
public static int mul33WordAdd(int i, int i2, int[] iArr, int i3) {
|
||
|
long j = i;
|
||
|
long j2 = i2 & 4294967295L;
|
||
|
long j3 = ((j & 4294967295L) * j2) + (iArr[i3] & 4294967295L);
|
||
|
iArr[i3] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + j2 + (iArr[r4] & 4294967295L);
|
||
|
iArr[i3 + 1] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (4294967295L & iArr[r8]);
|
||
|
iArr[i3 + 2] = (int) j5;
|
||
|
if ((j5 >>> 32) == 0) {
|
||
|
return 0;
|
||
|
}
|
||
|
return Nat.incAt(5, iArr, i3, 3);
|
||
|
}
|
||
|
|
||
|
public static int mul33DWordAdd(int i, long j, int[] iArr, int i2) {
|
||
|
long j2 = i & 4294967295L;
|
||
|
long j3 = j & 4294967295L;
|
||
|
long j4 = (j2 * j3) + (iArr[i2] & 4294967295L);
|
||
|
iArr[i2] = (int) j4;
|
||
|
long j5 = j >>> 32;
|
||
|
long j6 = (j4 >>> 32) + (j2 * j5) + j3 + (iArr[r8] & 4294967295L);
|
||
|
iArr[i2 + 1] = (int) j6;
|
||
|
long j7 = (j6 >>> 32) + j5 + (iArr[r0] & 4294967295L);
|
||
|
iArr[i2 + 2] = (int) j7;
|
||
|
long j8 = (j7 >>> 32) + (4294967295L & iArr[r11]);
|
||
|
iArr[i2 + 3] = (int) j8;
|
||
|
if ((j8 >>> 32) == 0) {
|
||
|
return 0;
|
||
|
}
|
||
|
return Nat.incAt(5, iArr, i2, 4);
|
||
|
}
|
||
|
|
||
|
public static long mul33Add(int i, int[] iArr, int i2, int[] iArr2, int i3, int[] iArr3, int i4) {
|
||
|
long j = i & 4294967295L;
|
||
|
long j2 = iArr[i2] & 4294967295L;
|
||
|
long j3 = (j * j2) + (iArr2[i3] & 4294967295L);
|
||
|
iArr3[i4] = (int) j3;
|
||
|
long j4 = iArr[i2 + 1] & 4294967295L;
|
||
|
long j5 = (j3 >>> 32) + (j * j4) + j2 + (iArr2[i3 + 1] & 4294967295L);
|
||
|
iArr3[i4 + 1] = (int) j5;
|
||
|
long j6 = iArr[i2 + 2] & 4294967295L;
|
||
|
long j7 = (j5 >>> 32) + (j * j6) + j4 + (iArr2[i3 + 2] & 4294967295L);
|
||
|
iArr3[i4 + 2] = (int) j7;
|
||
|
long j8 = iArr[i2 + 3] & 4294967295L;
|
||
|
long j9 = (j7 >>> 32) + (j * j8) + j6 + (iArr2[i3 + 3] & 4294967295L);
|
||
|
iArr3[i4 + 3] = (int) j9;
|
||
|
long j10 = iArr[i2 + 4] & 4294967295L;
|
||
|
long j11 = (j9 >>> 32) + (j * j10) + j8 + (4294967295L & iArr2[i3 + 4]);
|
||
|
iArr3[i4 + 4] = (int) j11;
|
||
|
return (j11 >>> 32) + j10;
|
||
|
}
|
||
|
|
||
|
public static void mul(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
long j = iArr2[0] & 4294967295L;
|
||
|
int i = 1;
|
||
|
long j2 = iArr2[1] & 4294967295L;
|
||
|
long j3 = iArr2[2] & 4294967295L;
|
||
|
long j4 = iArr2[3] & 4294967295L;
|
||
|
long j5 = iArr2[4] & 4294967295L;
|
||
|
long j6 = iArr[0] & 4294967295L;
|
||
|
long j7 = j6 * j;
|
||
|
iArr3[0] = (int) j7;
|
||
|
long j8 = (j7 >>> 32) + (j6 * j2);
|
||
|
iArr3[1] = (int) j8;
|
||
|
long j9 = (j8 >>> 32) + (j6 * j3);
|
||
|
iArr3[2] = (int) j9;
|
||
|
long j10 = (j9 >>> 32) + (j6 * j4);
|
||
|
iArr3[3] = (int) j10;
|
||
|
long j11 = (j10 >>> 32) + (j6 * j5);
|
||
|
iArr3[4] = (int) j11;
|
||
|
iArr3[5] = (int) (j11 >>> 32);
|
||
|
for (int i2 = 5; i < i2; i2 = 5) {
|
||
|
long j12 = iArr[i] & 4294967295L;
|
||
|
long j13 = (j12 * j) + (iArr3[i] & 4294967295L);
|
||
|
iArr3[i] = (int) j13;
|
||
|
int i3 = i + 1;
|
||
|
long j14 = (j13 >>> 32) + (j12 * j2) + (iArr3[i3] & 4294967295L);
|
||
|
iArr3[i3] = (int) j14;
|
||
|
long j15 = (j14 >>> 32) + (j12 * j3) + (iArr3[r3] & 4294967295L);
|
||
|
iArr3[i + 2] = (int) j15;
|
||
|
long j16 = (j15 >>> 32) + (j12 * j4) + (iArr3[r3] & 4294967295L);
|
||
|
iArr3[i + 3] = (int) j16;
|
||
|
long j17 = (j16 >>> 32) + (j12 * j5) + (iArr3[r3] & 4294967295L);
|
||
|
iArr3[i + 4] = (int) j17;
|
||
|
iArr3[i + 5] = (int) (j17 >>> 32);
|
||
|
i = i3;
|
||
|
j4 = j4;
|
||
|
j = j;
|
||
|
j2 = j2;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static void mul(int[] iArr, int i, int[] iArr2, int i2, int[] iArr3, int i3) {
|
||
|
long j = iArr2[i2] & 4294967295L;
|
||
|
long j2 = iArr2[i2 + 1] & 4294967295L;
|
||
|
long j3 = iArr2[i2 + 2] & 4294967295L;
|
||
|
long j4 = iArr2[i2 + 3] & 4294967295L;
|
||
|
long j5 = iArr2[i2 + 4] & 4294967295L;
|
||
|
long j6 = iArr[i] & 4294967295L;
|
||
|
long j7 = j6 * j;
|
||
|
iArr3[i3] = (int) j7;
|
||
|
long j8 = (j7 >>> 32) + (j6 * j2);
|
||
|
iArr3[i3 + 1] = (int) j8;
|
||
|
long j9 = (j8 >>> 32) + (j6 * j3);
|
||
|
iArr3[i3 + 2] = (int) j9;
|
||
|
long j10 = (j9 >>> 32) + (j6 * j4);
|
||
|
iArr3[i3 + 3] = (int) j10;
|
||
|
long j11 = (j10 >>> 32) + (j6 * j5);
|
||
|
iArr3[i3 + 4] = (int) j11;
|
||
|
iArr3[i3 + 5] = (int) (j11 >>> 32);
|
||
|
int i4 = 1;
|
||
|
int i5 = i3;
|
||
|
while (i4 < 5) {
|
||
|
int i6 = i5 + 1;
|
||
|
long j12 = iArr[i + i4] & 4294967295L;
|
||
|
long j13 = j;
|
||
|
long j14 = (j12 * j) + (iArr3[i6] & 4294967295L);
|
||
|
iArr3[i6] = (int) j14;
|
||
|
long j15 = (j14 >>> 32) + (j12 * j2) + (iArr3[r2] & 4294967295L);
|
||
|
iArr3[i5 + 2] = (int) j15;
|
||
|
long j16 = (j15 >>> 32) + (j12 * j3) + (iArr3[r2] & 4294967295L);
|
||
|
iArr3[i5 + 3] = (int) j16;
|
||
|
long j17 = (j16 >>> 32) + (j12 * j4) + (iArr3[r2] & 4294967295L);
|
||
|
iArr3[i5 + 4] = (int) j17;
|
||
|
long j18 = (j17 >>> 32) + (j12 * j5) + (iArr3[r2] & 4294967295L);
|
||
|
iArr3[i5 + 5] = (int) j18;
|
||
|
iArr3[i5 + 6] = (int) (j18 >>> 32);
|
||
|
i4++;
|
||
|
i5 = i6;
|
||
|
j = j13;
|
||
|
j3 = j3;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static boolean isZero(int[] iArr) {
|
||
|
for (int i = 0; i < 5; i++) {
|
||
|
if (iArr[i] != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean isOne(int[] iArr) {
|
||
|
if (iArr[0] != 1) {
|
||
|
return false;
|
||
|
}
|
||
|
for (int i = 1; i < 5; i++) {
|
||
|
if (iArr[i] != 0) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean gte(int[] iArr, int[] iArr2) {
|
||
|
for (int i = 4; i >= 0; i--) {
|
||
|
int i2 = iArr[i] ^ PKIFailureInfo.systemUnavail;
|
||
|
int i3 = Integer.MIN_VALUE ^ iArr2[i];
|
||
|
if (i2 < i3) {
|
||
|
return false;
|
||
|
}
|
||
|
if (i2 > i3) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean gte(int[] iArr, int i, int[] iArr2, int i2) {
|
||
|
for (int i3 = 4; i3 >= 0; i3--) {
|
||
|
int i4 = iArr[i + i3] ^ PKIFailureInfo.systemUnavail;
|
||
|
int i5 = Integer.MIN_VALUE ^ iArr2[i2 + i3];
|
||
|
if (i4 < i5) {
|
||
|
return false;
|
||
|
}
|
||
|
if (i4 > i5) {
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static int getBit(int[] iArr, int i) {
|
||
|
int i2;
|
||
|
if (i == 0) {
|
||
|
i2 = iArr[0];
|
||
|
} else {
|
||
|
int i3 = i >> 5;
|
||
|
if (i3 < 0 || i3 >= 5) {
|
||
|
return 0;
|
||
|
}
|
||
|
i2 = iArr[i3] >>> (i & 31);
|
||
|
}
|
||
|
return i2 & 1;
|
||
|
}
|
||
|
|
||
|
public static int[] fromBigInteger(BigInteger bigInteger) {
|
||
|
if (bigInteger.signum() < 0 || bigInteger.bitLength() > 160) {
|
||
|
throw new IllegalArgumentException();
|
||
|
}
|
||
|
int[] create = create();
|
||
|
int i = 0;
|
||
|
while (bigInteger.signum() != 0) {
|
||
|
create[i] = bigInteger.intValue();
|
||
|
bigInteger = bigInteger.shiftRight(32);
|
||
|
i++;
|
||
|
}
|
||
|
return create;
|
||
|
}
|
||
|
|
||
|
public static boolean eq(int[] iArr, int[] iArr2) {
|
||
|
for (int i = 4; i >= 0; i--) {
|
||
|
if (iArr[i] != iArr2[i]) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static boolean diff(int[] iArr, int i, int[] iArr2, int i2, int[] iArr3, int i3) {
|
||
|
boolean gte = gte(iArr, i, iArr2, i2);
|
||
|
if (gte) {
|
||
|
sub(iArr, i, iArr2, i2, iArr3, i3);
|
||
|
} else {
|
||
|
sub(iArr2, i2, iArr, i, iArr3, i3);
|
||
|
}
|
||
|
return gte;
|
||
|
}
|
||
|
|
||
|
public static int[] createExt() {
|
||
|
return new int[10];
|
||
|
}
|
||
|
|
||
|
public static int[] create() {
|
||
|
return new int[5];
|
||
|
}
|
||
|
|
||
|
public static void copy(int[] iArr, int[] iArr2) {
|
||
|
iArr2[0] = iArr[0];
|
||
|
iArr2[1] = iArr[1];
|
||
|
iArr2[2] = iArr[2];
|
||
|
iArr2[3] = iArr[3];
|
||
|
iArr2[4] = iArr[4];
|
||
|
}
|
||
|
|
||
|
public static int addToEachOther(int[] iArr, int i, int[] iArr2, int i2) {
|
||
|
long j = (iArr[i] & 4294967295L) + (iArr2[i2] & 4294967295L);
|
||
|
int i3 = (int) j;
|
||
|
iArr[i] = i3;
|
||
|
iArr2[i2] = i3;
|
||
|
long j2 = (j >>> 32) + (iArr[r4] & 4294967295L) + (iArr2[r7] & 4294967295L);
|
||
|
int i4 = (int) j2;
|
||
|
iArr[i + 1] = i4;
|
||
|
iArr2[i2 + 1] = i4;
|
||
|
long j3 = (j2 >>> 32) + (iArr[r4] & 4294967295L) + (iArr2[r7] & 4294967295L);
|
||
|
int i5 = (int) j3;
|
||
|
iArr[i + 2] = i5;
|
||
|
iArr2[i2 + 2] = i5;
|
||
|
long j4 = (j3 >>> 32) + (iArr[r4] & 4294967295L) + (iArr2[r7] & 4294967295L);
|
||
|
int i6 = (int) j4;
|
||
|
iArr[i + 3] = i6;
|
||
|
iArr2[i2 + 3] = i6;
|
||
|
long j5 = (j4 >>> 32) + (iArr[r12] & 4294967295L) + (4294967295L & iArr2[r14]);
|
||
|
int i7 = (int) j5;
|
||
|
iArr[i + 4] = i7;
|
||
|
iArr2[i2 + 4] = i7;
|
||
|
return (int) (j5 >>> 32);
|
||
|
}
|
||
|
|
||
|
public static int addTo(int[] iArr, int[] iArr2) {
|
||
|
long j = (iArr[0] & 4294967295L) + (iArr2[0] & 4294967295L);
|
||
|
iArr2[0] = (int) j;
|
||
|
long j2 = (j >>> 32) + (iArr[1] & 4294967295L) + (iArr2[1] & 4294967295L);
|
||
|
iArr2[1] = (int) j2;
|
||
|
long j3 = (j2 >>> 32) + (iArr[2] & 4294967295L) + (iArr2[2] & 4294967295L);
|
||
|
iArr2[2] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + (iArr[3] & 4294967295L) + (iArr2[3] & 4294967295L);
|
||
|
iArr2[3] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (iArr[4] & 4294967295L) + (4294967295L & iArr2[4]);
|
||
|
iArr2[4] = (int) j5;
|
||
|
return (int) (j5 >>> 32);
|
||
|
}
|
||
|
|
||
|
public static int addTo(int[] iArr, int i, int[] iArr2, int i2, int i3) {
|
||
|
long j = (i3 & 4294967295L) + (iArr[i] & 4294967295L) + (iArr2[i2] & 4294967295L);
|
||
|
iArr2[i2] = (int) j;
|
||
|
long j2 = (j >>> 32) + (iArr[i + 1] & 4294967295L) + (iArr2[r13] & 4294967295L);
|
||
|
iArr2[i2 + 1] = (int) j2;
|
||
|
long j3 = (j2 >>> 32) + (iArr[i + 2] & 4294967295L) + (iArr2[r13] & 4294967295L);
|
||
|
iArr2[i2 + 2] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + (iArr[i + 3] & 4294967295L) + (iArr2[r13] & 4294967295L);
|
||
|
iArr2[i2 + 3] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (iArr[i + 4] & 4294967295L) + (4294967295L & iArr2[r12]);
|
||
|
iArr2[i2 + 4] = (int) j5;
|
||
|
return (int) (j5 >>> 32);
|
||
|
}
|
||
|
|
||
|
public static int addBothTo(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
long j = (iArr[0] & 4294967295L) + (iArr2[0] & 4294967295L) + (iArr3[0] & 4294967295L);
|
||
|
iArr3[0] = (int) j;
|
||
|
long j2 = (j >>> 32) + (iArr[1] & 4294967295L) + (iArr2[1] & 4294967295L) + (iArr3[1] & 4294967295L);
|
||
|
iArr3[1] = (int) j2;
|
||
|
long j3 = (j2 >>> 32) + (iArr[2] & 4294967295L) + (iArr2[2] & 4294967295L) + (iArr3[2] & 4294967295L);
|
||
|
iArr3[2] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + (iArr[3] & 4294967295L) + (iArr2[3] & 4294967295L) + (iArr3[3] & 4294967295L);
|
||
|
iArr3[3] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (iArr[4] & 4294967295L) + (iArr2[4] & 4294967295L) + (iArr3[4] & 4294967295L);
|
||
|
iArr3[4] = (int) j5;
|
||
|
return (int) (j5 >>> 32);
|
||
|
}
|
||
|
|
||
|
public static int add(int[] iArr, int[] iArr2, int[] iArr3) {
|
||
|
long j = (iArr[0] & 4294967295L) + (iArr2[0] & 4294967295L);
|
||
|
iArr3[0] = (int) j;
|
||
|
long j2 = (j >>> 32) + (iArr[1] & 4294967295L) + (iArr2[1] & 4294967295L);
|
||
|
iArr3[1] = (int) j2;
|
||
|
long j3 = (j2 >>> 32) + (iArr[2] & 4294967295L) + (iArr2[2] & 4294967295L);
|
||
|
iArr3[2] = (int) j3;
|
||
|
long j4 = (j3 >>> 32) + (iArr[3] & 4294967295L) + (iArr2[3] & 4294967295L);
|
||
|
iArr3[3] = (int) j4;
|
||
|
long j5 = (j4 >>> 32) + (iArr[4] & 4294967295L) + (iArr2[4] & 4294967295L);
|
||
|
iArr3[4] = (int) j5;
|
||
|
return (int) (j5 >>> 32);
|
||
|
}
|
||
|
}
|