195 lines
6.4 KiB
Java
195 lines
6.4 KiB
Java
|
package org.bouncycastle.math.ec.custom.sec;
|
||
|
|
||
|
import java.math.BigInteger;
|
||
|
import org.bouncycastle.math.ec.ECFieldElement;
|
||
|
import org.bouncycastle.math.raw.Nat128;
|
||
|
import org.bouncycastle.util.Arrays;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public class SecT113FieldElement extends ECFieldElement {
|
||
|
protected long[] x;
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public int getFieldSize() {
|
||
|
return 113;
|
||
|
}
|
||
|
|
||
|
public int getK1() {
|
||
|
return 9;
|
||
|
}
|
||
|
|
||
|
public int getK2() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public int getK3() {
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
public int getM() {
|
||
|
return 113;
|
||
|
}
|
||
|
|
||
|
public int getRepresentation() {
|
||
|
return 2;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement negate() {
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public BigInteger toBigInteger() {
|
||
|
return Nat128.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 = Nat128.create64();
|
||
|
SecT113Field.squareN(this.x, i, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement squarePlusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2) {
|
||
|
long[] jArr = this.x;
|
||
|
long[] jArr2 = ((SecT113FieldElement) eCFieldElement).x;
|
||
|
long[] jArr3 = ((SecT113FieldElement) eCFieldElement2).x;
|
||
|
long[] createExt64 = Nat128.createExt64();
|
||
|
SecT113Field.squareAddToExt(jArr, createExt64);
|
||
|
SecT113Field.multiplyAddToExt(jArr2, jArr3, createExt64);
|
||
|
long[] create64 = Nat128.create64();
|
||
|
SecT113Field.reduce(createExt64, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@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 = Nat128.create64();
|
||
|
SecT113Field.square(this.x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement sqrt() {
|
||
|
long[] create64 = Nat128.create64();
|
||
|
SecT113Field.sqrt(this.x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement multiplyPlusProduct(ECFieldElement eCFieldElement, ECFieldElement eCFieldElement2, ECFieldElement eCFieldElement3) {
|
||
|
long[] jArr = this.x;
|
||
|
long[] jArr2 = ((SecT113FieldElement) eCFieldElement).x;
|
||
|
long[] jArr3 = ((SecT113FieldElement) eCFieldElement2).x;
|
||
|
long[] jArr4 = ((SecT113FieldElement) eCFieldElement3).x;
|
||
|
long[] createExt64 = Nat128.createExt64();
|
||
|
SecT113Field.multiplyAddToExt(jArr, jArr2, createExt64);
|
||
|
SecT113Field.multiplyAddToExt(jArr3, jArr4, createExt64);
|
||
|
long[] create64 = Nat128.create64();
|
||
|
SecT113Field.reduce(createExt64, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@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 = Nat128.create64();
|
||
|
SecT113Field.multiply(this.x, ((SecT113FieldElement) eCFieldElement).x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public boolean isZero() {
|
||
|
return Nat128.isZero64(this.x);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public boolean isOne() {
|
||
|
return Nat128.isOne64(this.x);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement invert() {
|
||
|
long[] create64 = Nat128.create64();
|
||
|
SecT113Field.invert(this.x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
return Arrays.hashCode(this.x, 0, 2) ^ 113009;
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public String getFieldName() {
|
||
|
return "SecT113Field";
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (obj == this) {
|
||
|
return true;
|
||
|
}
|
||
|
if (obj instanceof SecT113FieldElement) {
|
||
|
return Nat128.eq64(this.x, ((SecT113FieldElement) 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 = Nat128.create64();
|
||
|
SecT113Field.addOne(this.x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
@Override // org.bouncycastle.math.ec.ECFieldElement
|
||
|
public ECFieldElement add(ECFieldElement eCFieldElement) {
|
||
|
long[] create64 = Nat128.create64();
|
||
|
SecT113Field.add(this.x, ((SecT113FieldElement) eCFieldElement).x, create64);
|
||
|
return new SecT113FieldElement(create64);
|
||
|
}
|
||
|
|
||
|
protected SecT113FieldElement(long[] jArr) {
|
||
|
this.x = jArr;
|
||
|
}
|
||
|
|
||
|
public SecT113FieldElement(BigInteger bigInteger) {
|
||
|
if (bigInteger == null || bigInteger.signum() < 0 || bigInteger.bitLength() > 113) {
|
||
|
throw new IllegalArgumentException("x value invalid for SecT113FieldElement");
|
||
|
}
|
||
|
this.x = SecT113Field.fromBigInteger(bigInteger);
|
||
|
}
|
||
|
|
||
|
public SecT113FieldElement() {
|
||
|
this.x = Nat128.create64();
|
||
|
}
|
||
|
}
|