@SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public U add(final U other) {
    if (isInfinity() || other.isInfinity()) {
      return isInfinity() ? other : (U) this;
    } else if (equals(other)) {
      return doub();
    } else if (x.equals(other.x)) {
      return infinity();
    } else {
      final FieldElement x1 = x;
      final FieldElement y1 = y;
      final FieldElement x2 = other.x;
      final FieldElement y2 = other.y;

      final FieldElement m = y2.subtract(y1).divide(x2.subtract(x1));
      final FieldElement mSquared = m.power(2);
      final FieldElement newX = mSquared.subtract(x1).subtract(x2);
      final FieldElement newY = m.negate().multiply(newX).add(m.multiply(x1)).subtract(y1);

      return newInstance(newX, newY);
    }
  }
New instance of generic type U.

@param x the x
@param y the y
@return the U
crypto/algorithms/src/main/java/org/hyperledger/besu/crypto/altbn128/AbstractFieldPoint.java