src/main/core/com/gypsyengineer/tlsbunny/utils/ECUtils.java
public static void checkPointOnCurve(ECPoint point, EllipticCurve ec)
            throws ECException {

        BigInteger p = getP(ec);
        BigInteger x = point.getAffineX();
        BigInteger y = point.getAffineY();

        if (x == null || y == null) {
            throw new ECException("point is at infinity");
        }

        // Check 0 <= x < p and 0 <= y < p.
        if (x.signum() == -1 || x.compareTo(p) >= 0) {
            throw new ECException("x is out of range [0, p-1]");
        }
        if (y.signum() == -1 || y.compareTo(p) >= 0) {
            throw new ECException("y is out of range [0, p-1]");
        }

        // Check y^2 == x^3 + a x + b (mod p)
        BigInteger lhs = y.multiply(y).mod(p);
        BigInteger rhs = x.multiply(x).add(ec.getA()).multiply(x).add(ec.getB()).mod(p);
        if (!lhs.equals(rhs)) {
            throw new ECException("point is not on curve");
        }
    }
/**
     * (borrowed from wycheproof)
     *
     * Checks that a point is on a given elliptic curve. This method implements the partial public key
     * validation routine from Section 5.6.2.6 of NIST SP 800-56A
     * http://csrc.nist.gov/publications/nistpubs/800-56A/SP800-56A_Revision1_Mar08-2007.pdf A partial
     * public key validation is sufficient for curves with cofactor 1. See Section B.3 of
     * http://www.nsa.gov/ia/_files/SuiteB_Implementer_G-113808.pdf The point validations above are
     * taken from recommendations for ECDH, because parameter checks in ECDH are much more important
     * than for the case of ECDSA. Performing this test for ECDSA keys is mainly a sanity check.
     *
     * @param point the point that needs verification
     * @param ec the elliptic curve. This must be a curve over a prime order field.
     * @throws ECException if the field is binary or if the point is not on the curve.
     */
(borrowed from wycheproof)
Checks that a point is on a given elliptic curve.

@param point the point that needs verification
@param ec the elliptic curve. This must be a curve over a prime order field.
@throws ECException if the field is binary or if the point is not on the curve.
( borrowed from wycheproof ) Checks that a point is on a given elliptic curve . @param point the point that needs verification @param ec the elliptic curve . This must be a curve over a prime order field . @throws ECException if the field is binary or if the point is not on the curve .
public static void checkPointOnCurve(ECPoint point, EllipticCurve ec)
            throws ECException {
        BigInteger p = getP(ec);
        BigInteger x = point.getAffineX();
        BigInteger y = point.getAffineY();
        if (x == null || y == null) {
            throw new ECException("point is at infinity");
        }
        if (x.signum() == -1 || x.compareTo(p) >= 0) {
            throw new ECException("x is out of range [0, p-1]");
        }
        if (y.signum() == -1 || y.compareTo(p) >= 0) {
            throw new ECException("y is out of range [0, p-1]");
        }
        BigInteger lhs = y.multiply(y).mod(p);
        BigInteger rhs = x.multiply(x).add(ec.getA()).multiply(x).add(ec.getB()).mod(p);
        if (!lhs.equals(rhs)) {
            throw new ECException("point is not on curve");
        }
    }
public static void checkPointOnCurve ( ECPoint point , EllipticCurve ec ) throws ECException { BigInteger p = getP ( ec ) ; BigInteger x = point . getAffineX ( ) ; BigInteger y = point . getAffineY ( ) ; if ( x == null || y == null ) { throw new ECException ( "point is at infinity" ) ; } if ( x . signum ( ) == - 1 || x . compareTo ( p ) >= 0 ) { throw new ECException ( "x is out of range [0, p-1]" ) ; } if ( y . signum ( ) == - 1 || y . compareTo ( p ) >= 0 ) { throw new ECException ( "y is out of range [0, p-1]" ) ; } BigInteger lhs = y . multiply ( y ) . mod ( p ) ; BigInteger rhs = x . multiply ( x ) . add ( ec . getA ( ) ) . multiply ( x ) . add ( ec . getB ( ) ) . mod ( p ) ; if ( ! lhs . equals ( rhs ) ) { throw new ECException ( "point is not on curve" ) ; } }
(borrowed from wycheproof)
 Checks that a point is on a given elliptic curve.
( borrowed from wycheproof ) Checks that a point is on a given elliptic curve .
// Check 0 <= x < p and 0 <= y < p. // Check y^2 == x^3 + a x + b (mod p)