50,639
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
public static String fromXgetY(String ysPubKey){
if (ysPubKey.length()!=33*2)
{
return "9001"; //长度不正确
}
if (!ysPubKey.substring(0, 2).equals("02") && !ysPubKey.substring(0,2).equals("03"))
{
return "9002"; //压缩公钥标识不正确
}
byte[] decode = Util.hexstr2byte(ysPubKey);
ECPoint tmpPoint = SM2.ecc_curve.decodePoint(decode);
ECFieldElement y = tmpPoint.getY();
String pubKeyY = Util.complete00(Util.bigIntegerTOHexForString(y.toBigInteger()), 64);
return "9000"+pubKeyY;
}