本文整理汇总了Java中org.bouncycastle.math.ec.FixedPointCombMultiplier类的典型用法代码示例。如果您正苦于以下问题:Java FixedPointCombMultiplier类的具体用法?Java FixedPointCombMultiplier怎么用?Java FixedPointCombMultiplier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FixedPointCombMultiplier类属于org.bouncycastle.math.ec包,在下文中一共展示了FixedPointCombMultiplier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSignatureForHash
import org.bouncycastle.math.ec.FixedPointCombMultiplier; //导入依赖的package包/类
public byte[] generateSignatureForHash(byte[] eHash) throws CryptoException {
BigInteger n = ecParams.getN();
BigInteger e = new BigInteger(1, eHash);
BigInteger d = ((ECPrivateKeyParameters)ecKey).getD();
BigInteger r, s;
ECMultiplier basePointMultiplier = new FixedPointCombMultiplier();
// 5.2.1 Draft RFC: SM2 Public Key Algorithms
do {// generate s
BigInteger k;
do { // generate r
// A3
k = kCalculator.nextK();
// A4
ECPoint p = basePointMultiplier.multiply(ecParams.getG(), k).normalize();
// A5
r = e.add(p.getAffineXCoord().toBigInteger()).mod(n);
} while (r.equals(ECConstants.ZERO) || r.add(k).equals(n));
// A6
BigInteger dPlus1ModN = d.add(ECConstants.ONE).modInverse(n);
s = k.subtract(r.multiply(d)).mod(n);
s = dPlus1ModN.multiply(s).mod(n);
} while (s.equals(ECConstants.ZERO));
// A7
try {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new ASN1Integer(r));
v.add(new ASN1Integer(s));
return new DERSequence(v).getEncoded(ASN1Encoding.DER);
} catch (IOException ex) {
throw new CryptoException("unable to encode signature: " + ex.getMessage(), ex);
}
}
示例2: publicPointFromPrivate
import org.bouncycastle.math.ec.FixedPointCombMultiplier; //导入依赖的package包/类
/**
* Returns public key point from the given private key.
*/
private static ECPoint publicPointFromPrivate(BigInteger privKey) {
/*
* TODO: FixedPointCombMultiplier currently doesn't support scalars longer than the group
* order, but that could change in future versions.
*/
if (privKey.bitLength() > CURVE.getN().bitLength()) {
privKey = privKey.mod(CURVE.getN());
}
return new FixedPointCombMultiplier().multiply(CURVE.getG(), privKey);
}
示例3: create
import org.bouncycastle.math.ec.FixedPointCombMultiplier; //导入依赖的package包/类
public static Optional<ECCurvePoint> create(BigInteger d, String curveName) {
X9ECParameters x9ECParameters = ECAssistant.x9ECParameters(curveName);
ECPoint Q = new FixedPointCombMultiplier().multiply(x9ECParameters.getG(), d).normalize();
ECCurvePoint point = new ECCurvePoint(Q, curveName, x9ECParameters);
return Optional.of(point);
}
示例4: createBasePointMultiplier
import org.bouncycastle.math.ec.FixedPointCombMultiplier; //导入依赖的package包/类
protected ECMultiplier createBasePointMultiplier()
{
return new FixedPointCombMultiplier();
}