what-the-bank/sources/org/bouncycastle/math/ec/custom/sec/SecT131FieldElement.java

197 lines
6.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.math.ec.custom.sec;
import java.math.BigInteger;
import org.bouncycastle.math.ec.ECFieldElement;
import org.bouncycastle.math.raw.Nat;
import org.bouncycastle.math.raw.Nat192;
import org.bouncycastle.util.Arrays;
import org.jmrtd.cbeff.ISO781611;
/* loaded from: classes6.dex */
public class SecT131FieldElement extends ECFieldElement {
protected long[] x;
@Override // org.bouncycastle.math.ec.ECFieldElement
public int getFieldSize() {
return ISO781611.CREATION_DATE_AND_TIME_TAG;
}
public int getK1() {
return 2;
}
public int getK2() {
return 3;
}
public int getK3() {
return 8;
}
public int getM() {
return ISO781611.CREATION_DATE_AND_TIME_TAG;
}
public int getRepresentation() {
return 3;
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement negate() {
return this;
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public BigInteger toBigInteger() {
return Nat192.toBigInteger64(this.x);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public boolean testBitZero() {
return (this.x[0] & 1) != 0;
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement subtract(ECFieldElement eCFieldElement) {
return add(eCFieldElement);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement squarePow(int i) {
if (i <= 0) {
return this;
}
long[] create64 = Nat192.create64();
SecT131Field.squareN(this.x, i, create64);
return new SecT131FieldElement(create64);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement squarePlusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2) {
long[] jArr = this.x;
long[] jArr2 = ((SecT131FieldElement) eCFieldElement).x;
long[] jArr3 = ((SecT131FieldElement) eCFieldElement2).x;
long[] create64 = Nat.create64(5);
SecT131Field.squareAddToExt(jArr, create64);
SecT131Field.multiplyAddToExt(jArr2, jArr3, create64);
long[] create642 = Nat192.create64();
SecT131Field.reduce(create64, create642);
return new SecT131FieldElement(create642);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement squareMinusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2) {
return squarePlusProduct(eCFieldElement, eCFieldElement2);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement square() {
long[] create64 = Nat192.create64();
SecT131Field.square(this.x, create64);
return new SecT131FieldElement(create64);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement sqrt() {
long[] create64 = Nat192.create64();
SecT131Field.sqrt(this.x, create64);
return new SecT131FieldElement(create64);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement multiplyPlusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2, ECFieldElement eCFieldElement3) {
long[] jArr = this.x;
long[] jArr2 = ((SecT131FieldElement) eCFieldElement).x;
long[] jArr3 = ((SecT131FieldElement) eCFieldElement2).x;
long[] jArr4 = ((SecT131FieldElement) eCFieldElement3).x;
long[] create64 = Nat.create64(5);
SecT131Field.multiplyAddToExt(jArr, jArr2, create64);
SecT131Field.multiplyAddToExt(jArr3, jArr4, create64);
long[] create642 = Nat192.create64();
SecT131Field.reduce(create64, create642);
return new SecT131FieldElement(create642);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement multiplyMinusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2, ECFieldElement eCFieldElement3) {
return multiplyPlusProduct(eCFieldElement, eCFieldElement2, eCFieldElement3);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement multiply(ECFieldElement eCFieldElement) {
long[] create64 = Nat192.create64();
SecT131Field.multiply(this.x, ((SecT131FieldElement) eCFieldElement).x, create64);
return new SecT131FieldElement(create64);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public boolean isZero() {
return Nat192.isZero64(this.x);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public boolean isOne() {
return Nat192.isOne64(this.x);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement invert() {
long[] create64 = Nat192.create64();
SecT131Field.invert(this.x, create64);
return new SecT131FieldElement(create64);
}
public int hashCode() {
return Arrays.hashCode(this.x, 0, 3) ^ 131832;
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public String getFieldName() {
return "SecT131Field";
}
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof SecT131FieldElement) {
return Nat192.eq64(this.x, ((SecT131FieldElement) obj).x);
}
return false;
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement divide(ECFieldElement eCFieldElement) {
return multiply(eCFieldElement.invert());
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement addOne() {
long[] create64 = Nat192.create64();
SecT131Field.addOne(this.x, create64);
return new SecT131FieldElement(create64);
}
@Override // org.bouncycastle.math.ec.ECFieldElement
public ECFieldElement add(ECFieldElement eCFieldElement) {
long[] create64 = Nat192.create64();
SecT131Field.add(this.x, ((SecT131FieldElement) eCFieldElement).x, create64);
return new SecT131FieldElement(create64);
}
protected SecT131FieldElement(long[] jArr) {
this.x = jArr;
}
public SecT131FieldElement(BigInteger bigInteger) {
if (bigInteger == null || bigInteger.signum() < 0 || bigInteger.bitLength() > 131) {
throw new IllegalArgumentException("x value invalid for SecT131FieldElement");
}
this.x = SecT131Field.fromBigInteger(bigInteger);
}
public SecT131FieldElement() {
this.x = Nat192.create64();
}
}