@Test public void success_AddBasePoint() { Point doubled = curve.getBasePoint().add(curve.getBasePoint()); assertThat(doubled.getAffineX().getInteger(), is(new BigInteger("24727413235106541002554574571675588834622768167397638456726423682521233608206"))); assertThat(doubled.getAffineY().getInteger(), is(new BigInteger("15549675580280190176352668710449542251549572066445060580507079593062643049417"))); }
@Override public final Point add(Point point) { Coordinate x1 = this.x; Coordinate y1 = this.y; Coordinate z1 = this.z; Coordinate t1 = this.t; Coordinate x2 = point.getX(); Coordinate y2 = point.getY(); Coordinate z2 = point.getZ(); Coordinate t2 = point.getT(); Coordinate d = new CoordinateEd25519(curve.getD().getInteger()); Coordinate coord2 = new CoordinateEd25519(BigInteger.ONE.shiftLeft(1)); Coordinate A = y1.subtract(x1).multiply(y2.subtract(x2)).mod(); Coordinate B = y1.add(x1).multiply(y2.add(x2)).mod(); Coordinate C = t1.multiply(coord2).multiply(d).multiply(t2).mod(); Coordinate D = z1.multiply(coord2).multiply(z2).mod(); Coordinate E = B.subtract(A).mod(); Coordinate F = D.subtract(C).mod(); Coordinate G = D.add(C).mod(); Coordinate H = B.add(A).mod(); Coordinate x3 = E.multiply(F).mod(); Coordinate y3 = G.multiply(H).mod(); Coordinate t3 = E.multiply(H).mod(); Coordinate z3 = F.multiply(G).mod(); return new PointEd25519(x3, y3, z3, t3); }
PointEd25519 extends Point { @Override public final Point add(Point point) { Coordinate x1 = this.x; Coordinate y1 = this.y; Coordinate z1 = this.z; Coordinate t1 = this.t; Coordinate x2 = point.getX(); Coordinate y2 = point.getY(); Coordinate z2 = point.getZ(); Coordinate t2 = point.getT(); Coordinate d = new CoordinateEd25519(curve.getD().getInteger()); Coordinate coord2 = new CoordinateEd25519(BigInteger.ONE.shiftLeft(1)); Coordinate A = y1.subtract(x1).multiply(y2.subtract(x2)).mod(); Coordinate B = y1.add(x1).multiply(y2.add(x2)).mod(); Coordinate C = t1.multiply(coord2).multiply(d).multiply(t2).mod(); Coordinate D = z1.multiply(coord2).multiply(z2).mod(); Coordinate E = B.subtract(A).mod(); Coordinate F = D.subtract(C).mod(); Coordinate G = D.add(C).mod(); Coordinate H = B.add(A).mod(); Coordinate x3 = E.multiply(F).mod(); Coordinate y3 = G.multiply(H).mod(); Coordinate t3 = E.multiply(H).mod(); Coordinate z3 = F.multiply(G).mod(); return new PointEd25519(x3, y3, z3, t3); } }
PointEd25519 extends Point { @Override public final Point add(Point point) { Coordinate x1 = this.x; Coordinate y1 = this.y; Coordinate z1 = this.z; Coordinate t1 = this.t; Coordinate x2 = point.getX(); Coordinate y2 = point.getY(); Coordinate z2 = point.getZ(); Coordinate t2 = point.getT(); Coordinate d = new CoordinateEd25519(curve.getD().getInteger()); Coordinate coord2 = new CoordinateEd25519(BigInteger.ONE.shiftLeft(1)); Coordinate A = y1.subtract(x1).multiply(y2.subtract(x2)).mod(); Coordinate B = y1.add(x1).multiply(y2.add(x2)).mod(); Coordinate C = t1.multiply(coord2).multiply(d).multiply(t2).mod(); Coordinate D = z1.multiply(coord2).multiply(z2).mod(); Coordinate E = B.subtract(A).mod(); Coordinate F = D.subtract(C).mod(); Coordinate G = D.add(C).mod(); Coordinate H = B.add(A).mod(); Coordinate x3 = E.multiply(F).mod(); Coordinate y3 = G.multiply(H).mod(); Coordinate t3 = E.multiply(H).mod(); Coordinate z3 = F.multiply(G).mod(); return new PointEd25519(x3, y3, z3, t3); } PointEd25519(Coordinate x, Coordinate y, Coordinate z, Coordinate t); }
PointEd25519 extends Point { @Override public final Point add(Point point) { Coordinate x1 = this.x; Coordinate y1 = this.y; Coordinate z1 = this.z; Coordinate t1 = this.t; Coordinate x2 = point.getX(); Coordinate y2 = point.getY(); Coordinate z2 = point.getZ(); Coordinate t2 = point.getT(); Coordinate d = new CoordinateEd25519(curve.getD().getInteger()); Coordinate coord2 = new CoordinateEd25519(BigInteger.ONE.shiftLeft(1)); Coordinate A = y1.subtract(x1).multiply(y2.subtract(x2)).mod(); Coordinate B = y1.add(x1).multiply(y2.add(x2)).mod(); Coordinate C = t1.multiply(coord2).multiply(d).multiply(t2).mod(); Coordinate D = z1.multiply(coord2).multiply(z2).mod(); Coordinate E = B.subtract(A).mod(); Coordinate F = D.subtract(C).mod(); Coordinate G = D.add(C).mod(); Coordinate H = B.add(A).mod(); Coordinate x3 = E.multiply(F).mod(); Coordinate y3 = G.multiply(H).mod(); Coordinate t3 = E.multiply(H).mod(); Coordinate z3 = F.multiply(G).mod(); return new PointEd25519(x3, y3, z3, t3); } PointEd25519(Coordinate x, Coordinate y, Coordinate z, Coordinate t); static PointEd25519 fromAffine(Coordinate x, Coordinate y); @Override final Point add(Point point); @Override Point doubling(); @Override final Point scalarMultiply(BigInteger integer); @Override Point negateY(); @Override final EncodedPoint encode(); @Override Point negate(); }
PointEd25519 extends Point { @Override public final Point add(Point point) { Coordinate x1 = this.x; Coordinate y1 = this.y; Coordinate z1 = this.z; Coordinate t1 = this.t; Coordinate x2 = point.getX(); Coordinate y2 = point.getY(); Coordinate z2 = point.getZ(); Coordinate t2 = point.getT(); Coordinate d = new CoordinateEd25519(curve.getD().getInteger()); Coordinate coord2 = new CoordinateEd25519(BigInteger.ONE.shiftLeft(1)); Coordinate A = y1.subtract(x1).multiply(y2.subtract(x2)).mod(); Coordinate B = y1.add(x1).multiply(y2.add(x2)).mod(); Coordinate C = t1.multiply(coord2).multiply(d).multiply(t2).mod(); Coordinate D = z1.multiply(coord2).multiply(z2).mod(); Coordinate E = B.subtract(A).mod(); Coordinate F = D.subtract(C).mod(); Coordinate G = D.add(C).mod(); Coordinate H = B.add(A).mod(); Coordinate x3 = E.multiply(F).mod(); Coordinate y3 = G.multiply(H).mod(); Coordinate t3 = E.multiply(H).mod(); Coordinate z3 = F.multiply(G).mod(); return new PointEd25519(x3, y3, z3, t3); } PointEd25519(Coordinate x, Coordinate y, Coordinate z, Coordinate t); static PointEd25519 fromAffine(Coordinate x, Coordinate y); @Override final Point add(Point point); @Override Point doubling(); @Override final Point scalarMultiply(BigInteger integer); @Override Point negateY(); @Override final EncodedPoint encode(); @Override Point negate();  }