what-the-bank/sources/org/bouncycastle/math/raw/Nat448.java

81 lines
2.0 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.math.raw;
import java.math.BigInteger;
import org.bouncycastle.util.Pack;
/* loaded from: classes6.dex */
public abstract class Nat448 {
public static BigInteger toBigInteger64(long[] jArr) {
byte[] bArr = new byte[56];
for (int i = 0; i < 7; i++) {
long j = jArr[i];
if (j != 0) {
Pack.longToBigEndian(j, bArr, (6 - i) << 3);
}
}
return new BigInteger(1, bArr);
}
public static boolean isZero64(long[] jArr) {
for (int i = 0; i < 7; i++) {
if (jArr[i] != 0) {
return false;
}
}
return true;
}
public static boolean isOne64(long[] jArr) {
if (jArr[0] != 1) {
return false;
}
for (int i = 1; i < 7; i++) {
if (jArr[i] != 0) {
return false;
}
}
return true;
}
public static long[] fromBigInteger64(BigInteger bigInteger) {
if (bigInteger.signum() < 0 || bigInteger.bitLength() > 448) {
throw new IllegalArgumentException();
}
long[] create64 = create64();
int i = 0;
while (bigInteger.signum() != 0) {
create64[i] = bigInteger.longValue();
bigInteger = bigInteger.shiftRight(64);
i++;
}
return create64;
}
public static boolean eq64(long[] jArr, long[] jArr2) {
for (int i = 6; i >= 0; i--) {
if (jArr[i] != jArr2[i]) {
return false;
}
}
return true;
}
public static long[] createExt64() {
return new long[14];
}
public static long[] create64() {
return new long[7];
}
public static void copy64(long[] jArr, long[] jArr2) {
jArr2[0] = jArr[0];
jArr2[1] = jArr[1];
jArr2[2] = jArr[2];
jArr2[3] = jArr[3];
jArr2[4] = jArr[4];
jArr2[5] = jArr[5];
jArr2[6] = jArr[6];
}
}