code: public boolean isOnCurve(Curve curve) {
      switch (repr) {
        case P2:
        case P3:
          FieldElement recip = Z.invert();
          FieldElement x = X.multiply(recip);
          FieldElement y = Y.multiply(recip);
          FieldElement xx = x.square();
          FieldElement yy = y.square();
          FieldElement dxxyy = curve.getD().multiply(xx).multiply(yy);
          return curve.getField().ONE.add(dxxyy).add(xx).equals(yy);
  
        default:
          return toP2().isOnCurve(curve);
      }
    }
docs: Verify that a point is on the curve.
  
  @param curve The curve to check.
  @return true if the point lies on the curve.