src/main/java/cn/jiguang/common/utils/sm2/BCECUtil.java
public static X962Parameters getDomainParametersFromName(java.security.spec.ECParameterSpec ecSpec,
        boolean withCompression) {
        X962Parameters params;

        if (ecSpec instanceof ECNamedCurveSpec) {
            ASN1ObjectIdentifier curveOid = ECUtil.getNamedCurveOid(((ECNamedCurveSpec) ecSpec).getName());
            if (curveOid == null) {
                curveOid = new ASN1ObjectIdentifier(((ECNamedCurveSpec) ecSpec).getName());
            }
            params = new X962Parameters(curveOid);
        } else if (ecSpec == null) {
            params = new X962Parameters(DERNull.INSTANCE);
        } else {
            ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve());

            X9ECParameters ecP = new X9ECParameters(
                curve,
                EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression),
                ecSpec.getOrder(),
                BigInteger.valueOf(ecSpec.getCofactor()),
                ecSpec.getCurve().getSeed());

            params = new X962Parameters(ecP);
        }

        return params;
    }
public static X962Parameters getDomainParametersFromName(java.security.spec.ECParameterSpec ecSpec,
        boolean withCompression) {
        X962Parameters params;

        if (ecSpec instanceof ECNamedCurveSpec) {
            ASN1ObjectIdentifier curveOid = ECUtil.getNamedCurveOid(((ECNamedCurveSpec) ecSpec).getName());
            if (curveOid == null) {
                curveOid = new ASN1ObjectIdentifier(((ECNamedCurveSpec) ecSpec).getName());
            }
            params = new X962Parameters(curveOid);
        } else if (ecSpec == null) {
            params = new X962Parameters(DERNull.INSTANCE);
        } else {
            ECCurve curve = EC5Util.convertCurve(ecSpec.getCurve());

            X9ECParameters ecP = new X9ECParameters(
                curve,
                EC5Util.convertPoint(curve, ecSpec.getGenerator(), withCompression),
                ecSpec.getOrder(),
                BigInteger.valueOf(ecSpec.getCofactor()),
                ecSpec.getCurve().getSeed());

            params = new X962Parameters(ecP);
        }

        return params;
    }
public static X962Parameters getDomainParametersFromName ( java . security . spec . ECParameterSpec ecSpec , boolean withCompression ) { X962Parameters params ; if ( ecSpec instanceof ECNamedCurveSpec ) { ASN1ObjectIdentifier curveOid = ECUtil . getNamedCurveOid ( ( ( ECNamedCurveSpec ) ecSpec ) . getName ( ) ) ; if ( curveOid == null ) { curveOid = new ASN1ObjectIdentifier ( ( ( ECNamedCurveSpec ) ecSpec ) . getName ( ) ) ; } params = new X962Parameters ( curveOid ) ; } else if ( ecSpec == null ) { params = new X962Parameters ( DERNull . INSTANCE ) ; } else { ECCurve curve = EC5Util . convertCurve ( ecSpec . getCurve ( ) ) ; X9ECParameters ecP = new X9ECParameters ( curve , EC5Util . convertPoint ( curve , ecSpec . getGenerator ( ) , withCompression ) , ecSpec . getOrder ( ) , BigInteger . valueOf ( ecSpec . getCofactor ( ) ) , ecSpec . getCurve ( ) . getSeed ( ) ) ; params = new X962Parameters ( ecP ) ; } return params ; }
copy from BC

@param ecSpec
@param withCompression
@return
copy from BC