src/main/java/cn/jiguang/common/utils/sm2/BCECUtil.java
public static byte[] convertECPrivateKeyToSEC1(ECPrivateKeyParameters priKey,
        ECPublicKeyParameters pubKey) throws IOException {
        byte[] pkcs8Bytes = convertECPrivateKeyToPKCS8(priKey, pubKey);
        PrivateKeyInfo pki = PrivateKeyInfo.getInstance(pkcs8Bytes);
        ASN1Encodable encodable = pki.parsePrivateKey();
        ASN1Primitive primitive = encodable.toASN1Primitive();
        byte[] sec1Bytes = primitive.getEncoded();
        return sec1Bytes;
    }
public static byte[] convertECPrivateKeyToSEC1(ECPrivateKeyParameters priKey,
        ECPublicKeyParameters pubKey) throws IOException {
        byte[] pkcs8Bytes = convertECPrivateKeyToPKCS8(priKey, pubKey);
        PrivateKeyInfo pki = PrivateKeyInfo.getInstance(pkcs8Bytes);
        ASN1Encodable encodable = pki.parsePrivateKey();
        ASN1Primitive primitive = encodable.toASN1Primitive();
        byte[] sec1Bytes = primitive.getEncoded();
        return sec1Bytes;
    }
public static byte [ ] convertECPrivateKeyToSEC1 ( ECPrivateKeyParameters priKey , ECPublicKeyParameters pubKey ) throws IOException { byte [ ] pkcs8Bytes = convertECPrivateKeyToPKCS8 ( priKey , pubKey ) ; PrivateKeyInfo pki = PrivateKeyInfo . getInstance ( pkcs8Bytes ) ; ASN1Encodable encodable = pki . parsePrivateKey ( ) ; ASN1Primitive primitive = encodable . toASN1Primitive ( ) ; byte [ ] sec1Bytes = primitive . getEncoded ( ) ; return sec1Bytes ; }
将ECC私钥转换为SEC1标准的字节流
openssl d2i_ECPrivateKey函数要求的DER编码的私钥也是SEC1标准的，
这个工具函数的主要目的就是为了能生成一个openssl可以直接“识别”的ECC私钥.
相对RSA私钥的PKCS1标准，ECC私钥的标准为SEC1

@param priKey
@param pubKey
@return
@throws IOException
将ECC私钥转换为SEC1标准的字节流 openssl d2i_ECPrivateKey函数要求的DER编码的私钥也是SEC1标准的， 这个工具函数的主要目的就是为了能生成一个openssl可以直接“识别”的ECC私钥 . 相对RSA私钥的PKCS1标准，ECC私钥的标准为SEC1