use of org.bouncycastle.crypto.digests.SM3Digest in project xipki by xipki.
the class GMUtil method getSM2Z.
// CHECKSTYLE:SKIP
public static byte[] getSM2Z(byte[] userID, ASN1ObjectIdentifier curveOid, BigInteger pubPointX, BigInteger pubPointY) {
SM3Digest digest = new SM3Digest();
addUserId(digest, userID);
X9ECParameters ecParams = GMNamedCurves.getByOID(curveOid);
addFieldElement(digest, ecParams.getCurve().getA());
addFieldElement(digest, ecParams.getCurve().getB());
addFieldElement(digest, ecParams.getG().getAffineXCoord());
addFieldElement(digest, ecParams.getG().getAffineYCoord());
int fieldSize = (ecParams.getCurve().getFieldSize() + 7) / 8;
byte[] bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointX);
digest.update(bytes, 0, fieldSize);
bytes = BigIntegers.asUnsignedByteArray(fieldSize, pubPointY);
digest.update(bytes, 0, fieldSize);
byte[] result = new byte[digest.getDigestSize()];
digest.doFinal(result, 0);
return result;
}
Aggregations