protected ECPoint detach() { return new SecT193R2Point(null, getAffineXCoord(), getAffineYCoord()); }
public ECPoint twicePlus(ECPoint b) if (this.isInfinity()) return twice(); ECCurve curve = this.getCurve(); if (X2.isZero() || !Z2.isOne()) return twice().add(b); return new SecT193R2Point(curve, A, curve.getB().sqrt(), withCompression); ECFieldElement L3 = A.add(B).square().multiplyPlusProduct(T, L2plus1, Z3); return new SecT193R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
public ECPoint twice() { if (this.isInfinity()) { return this; } ECCurve curve = this.getCurve(); ECFieldElement X1 = this.x; if (X1.isZero()) { // A point with X == 0 is it's own additive inverse return curve.getInfinity(); } ECFieldElement L1 = this.y, Z1 = this.zs[0]; boolean Z1IsOne = Z1.isOne(); ECFieldElement L1Z1 = Z1IsOne ? L1 : L1.multiply(Z1); ECFieldElement Z1Sq = Z1IsOne ? Z1 : Z1.square(); ECFieldElement a = curve.getA(); ECFieldElement aZ1Sq = Z1IsOne ? a : a.multiply(Z1Sq); ECFieldElement T = L1.square().add(L1Z1).add(aZ1Sq); if (T.isZero()) { return new SecT193R2Point(curve, T, curve.getB().sqrt(), withCompression); } ECFieldElement X3 = T.square(); ECFieldElement Z3 = Z1IsOne ? T : T.multiply(Z1Sq); ECFieldElement X1Z1 = Z1IsOne ? X1 : X1.multiply(Z1); ECFieldElement L3 = X1Z1.squarePlusProduct(T, L1Z1).add(X3).add(Z3); return new SecT193R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression); }
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 SecT193R2Point(curve, X, L.add(Z), new ECFieldElement[]{ Z }, this.withCompression); } }
protected boolean getCompressionYTilde() { ECFieldElement X = this.getRawXCoord(); if (X.isZero()) { return false; } ECFieldElement Y = this.getRawYCoord(); // Y is actually Lambda (X + Y/X) here return Y.testBitZero() != X.testBitZero(); }
protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, boolean withCompression) { return new SecT193R2Point(this, x, y, withCompression); }
public ECFieldElement getYCoord() { ECFieldElement X = x, L = y; if (this.isInfinity() || X.isZero()) { return L; } // Y is actually Lambda (X + Y/X) here; convert to affine value on the fly ECFieldElement Y = L.add(X).multiply(X); ECFieldElement Z = zs[0]; if (!Z.isOne()) { Y = Y.divide(Z); } return Y; }
public ECPoint add(ECPoint b) if (this.isInfinity()) ECCurve curve = this.getCurve(); return twice(); ECPoint p = this.normalize(); X1 = p.getXCoord(); ECFieldElement Y1 = p.getYCoord(); if (X3.isZero()) return new SecT193R2Point(curve, X3, curve.getB().sqrt(), this.withCompression); if (X3.isZero()) return new SecT193R2Point(curve, X3, curve.getB().sqrt(), this.withCompression); return new SecT193R2Point(curve, X3, L3, new ECFieldElement[]{ Z3 }, this.withCompression);
protected ECPoint createRawPoint(ECFieldElement x, ECFieldElement y, ECFieldElement[] zs, boolean withCompression) { return new SecT193R2Point(this, x, y, zs, withCompression); }
public SecT193R2Curve() { super(193, 15, 0, 0); this.infinity = new SecT193R2Point(this, null, null); this.a = fromBigInteger(new BigInteger(1, Hex.decode("0163F35A5137C2CE3EA6ED8667190B0BC43ECD69977702709B"))); this.b = fromBigInteger(new BigInteger(1, Hex.decode("00C9BB9E8927D4D64C377E2AB2856A5B16E3EFB7F61D4316AE"))); this.order = new BigInteger(1, Hex.decode("010000000000000000000000015AAB561B005413CCD4EE99D5")); this.cofactor = BigInteger.valueOf(2); this.coord = SecT193R2_DEFAULT_COORDS; }