protected ECFieldElement two(ECFieldElement x) { return x.add(x); }
protected ECFieldElement two(ECFieldElement x) { return x.add(x); }
protected ECFieldElement two(ECFieldElement x) { return x.add(x); }
protected ECFieldElement two(ECFieldElement x) { return x.add(x); }
protected ECFieldElement three(ECFieldElement x) { return two(x).add(x); }
protected ECFieldElement three(ECFieldElement x) { return two(x).add(x); }
protected ECFieldElement three(ECFieldElement x) { return two(x).add(x); }
protected ECFieldElement three(ECFieldElement x) { return two(x).add(x); }
private static ECFieldElement trace(ECFieldElement fe) { ECFieldElement t = fe; for (int i = 1; i < fe.getFieldSize(); ++i) { t = t.square().add(fe); } return t; }
private static ECFieldElement trace(ECFieldElement fe) { ECFieldElement t = fe; for (int i = 1; i < fe.getFieldSize(); ++i) { t = t.square().add(fe); } return t; }
public ECFieldElement squarePlusProduct(ECFieldElement x, ECFieldElement y) { return square().add(x.multiply(y)); }
public ECFieldElement multiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y) { return multiply(b).add(x.multiply(y)); }
public ECFieldElement multiplyPlusProduct(ECFieldElement b, ECFieldElement x, ECFieldElement y) { return multiply(b).add(x.multiply(y)); }
public ECFieldElement squarePlusProduct(ECFieldElement x, ECFieldElement y) { return square().add(x.multiply(y)); }
protected ECFieldElement doubleProductFromSquares(ECFieldElement a, ECFieldElement b, ECFieldElement aSquared, ECFieldElement bSquared) { /* * NOTE: If squaring in the field is faster than multiplication, then this is a quicker * way to calculate 2.A.B, if A^2 and B^2 are already known. */ return a.add(b).square().subtract(aSquared).subtract(bSquared); }
protected ECFieldElement doubleProductFromSquares(ECFieldElement a, ECFieldElement b, ECFieldElement aSquared, ECFieldElement bSquared) { /* * NOTE: If squaring in the field is faster than multiplication, then this is a quicker * way to calculate 2.A.B, if A^2 and B^2 are already known. */ return a.add(b).square().subtract(aSquared).subtract(bSquared); }
protected ECFieldElement doubleProductFromSquares(ECFieldElement a, ECFieldElement b, ECFieldElement aSquared, ECFieldElement bSquared) { /* * NOTE: If squaring in the field is faster than multiplication, then this is a quicker * way to calculate 2.A.B, if A^2 and B^2 are already known. */ return a.add(b).square().subtract(aSquared).subtract(bSquared); }
protected ECFieldElement doubleProductFromSquares(ECFieldElement a, ECFieldElement b, ECFieldElement aSquared, ECFieldElement bSquared) { /* * NOTE: If squaring in the field is faster than multiplication, then this is a quicker * way to calculate 2.A.B, if A^2 and B^2 are already known. */ return a.add(b).square().subtract(aSquared).subtract(bSquared); }
public ECPoint negate() { if (this.isInfinity()) { return this; } ECFieldElement X = this.x; if (X.isZero()) { return this; } // L is actually Lambda (X + Y/X) here ECFieldElement L = this.y, Z = this.zs[0]; return new SecT131R2Point(curve, X, L.add(Z), new ECFieldElement[]{ Z }, this.withCompression); } }
public static BigInteger y(ECCurve curve, BigInteger x) { // Andrey Jivsov https://www.ietf.org/archive/id/draft-jivsov-ecc-compact-05.txt. ECFieldElement X = curve.fromBigInteger(x); ECFieldElement rhs = X.square().add(curve.getA()).multiply(X).add(curve.getB()); // y' = sqrt( C(x) ), where y'>0 ECFieldElement yTilde = rhs.sqrt(); if (yTilde == null) { throw new IllegalArgumentException("invalid point compression"); } // y = min(y',p-y') BigInteger yT = yTilde.toBigInteger(); BigInteger yTn = yTilde.negate().toBigInteger(); BigInteger y = yT.compareTo(yTn) == -1 ? yT : yTn; return y; }