use of com.github.zhenwei.provider.jcajce.provider.asymmetric.ec.BCECPublicKey in project LinLong-Java by zhenwei1108.
the class HashBuilder method sm3Digest.
/**
* @param [publicKey, source]
* @return byte[]
* @author zhangzhenwei
* @description SM3公钥参与运算
* @date 2022/2/9 22:48
*/
private byte[] sm3Digest(DigestParams digestParams, byte[] source) {
SM3Digest digest = new SM3Digest();
PublicKey publicKey = digestParams.getPublicKey();
if (publicKey instanceof BCECPublicKey) {
BCECPublicKey key = (BCECPublicKey) publicKey;
digest.init(digestParams.getUserID(), key.getParameters().getCurve(), key.getParameters().getG(), key.getQ());
}
byte[] hash = new byte[digest.getDigestSize()];
digest.update(source, 0, source.length);
digest.doFinal(hash, 0);
return hash;
}
Aggregations