当前位置: 首页>>代码示例>>Java>>正文


Java FixedPointCombMultiplier类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:xipki,项目名称:xitk,代码行数:41,代码来源:SM2Signer.java

示例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);
}
 
开发者ID:web3j,项目名称:web3j,代码行数:14,代码来源:Sign.java

示例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);
}
 
开发者ID:horrorho,项目名称:InflatableDonkey,代码行数:8,代码来源:ECCurvePoint.java

示例4: createBasePointMultiplier

import org.bouncycastle.math.ec.FixedPointCombMultiplier; //导入依赖的package包/类
protected ECMultiplier createBasePointMultiplier()
{
    return new FixedPointCombMultiplier();
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:5,代码来源:ECNewPublicKeyTransform.java


注:本文中的org.bouncycastle.math.ec.FixedPointCombMultiplier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。