求代码:java实现SM2算法压缩公钥X计算出Y

tianjk 2018-06-08 03:44:26
求代码:用java实现国密SM2算法,已知压缩公钥X,计算出Y
...全文
1202 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
HardessGod 2019-01-08
  • 打赏
  • 举报
回复
有没有解压缩的java代码
LongXiao4 2018-09-25
  • 打赏
  • 举报
回复
https://download.csdn.net/download/longxiao4/10686237,c实现的方法,请大家参考,谢谢!!!
阿杜丢 2018-08-10
  • 打赏
  • 举报
回复
公钥压缩算法有文档没?要不不懂原理
tianjk 2018-06-22
  • 打赏
  • 举报
回复
引用 2 楼 flybird12956312 的回复:
求问一下怎么实现的?能指教一下吗?

代码贴出来了
tianjk 2018-06-22
  • 打赏
  • 举报
回复
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;
}
tianjk 2018-06-22
  • 打赏
  • 举报
回复
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;
}
flybird12956312 2018-06-21
  • 打赏
  • 举报
回复
求问一下怎么实现的?能指教一下吗?
tianjk 2018-06-08
  • 打赏
  • 举报
回复
我自己解决了

50,530

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧