fix:SM2PrivateKey的实现

This commit is contained in:
ChessNineeee
2021-04-09 16:09:24 +08:00
parent d786218ec9
commit cca446b901
@@ -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;
}