mirror of
https://gitee.com/willfree/min-dev-java.git
synced 2026-06-18 06:00:25 +08:00
fix:SM2PrivateKey的实现
This commit is contained in:
@@ -58,11 +58,24 @@ public class SM2PrivateKey implements PrivateKeyInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBytes(byte[] d) {
|
||||
// TODO 待与go版本进行兼容 目前版本无法使用
|
||||
if(d.length != 32 && d.length != 33)
|
||||
// public boolean setBytes(byte[] d) {
|
||||
// // TODO 待与go版本进行兼容 目前版本无法使用
|
||||
// if(d.length != 32 && d.length != 33)
|
||||
// return false;
|
||||
// privateKey = new ECPrivateKeyParameters(new BigInteger(d), SM2Base.DOMAIN_PARAMS);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @description 与external_amd64同步
|
||||
* @params d {byte[]}
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setBytes(byte[] d){
|
||||
if (d.length != 64)
|
||||
return false;
|
||||
privateKey = new ECPrivateKeyParameters(new BigInteger(d), SM2Base.DOMAIN_PARAMS);
|
||||
String priStr = new String(d);
|
||||
privateKey = new ECPrivateKeyParameters(new BigInteger(priStr, 16), SM2Base.DOMAIN_PARAMS);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user