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


Java ScalarOps.multiplyAndAdd方法代码示例

本文整理汇总了Java中net.i2p.crypto.eddsa.math.ScalarOps.multiplyAndAdd方法的典型用法代码示例。如果您正苦于以下问题:Java ScalarOps.multiplyAndAdd方法的具体用法?Java ScalarOps.multiplyAndAdd怎么用?Java ScalarOps.multiplyAndAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.i2p.crypto.eddsa.math.ScalarOps的用法示例。


在下文中一共展示了ScalarOps.multiplyAndAdd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: engineSign

import net.i2p.crypto.eddsa.math.ScalarOps; //导入方法依赖的package包/类
@Override
protected byte[] engineSign() throws SignatureException {
    Curve curve = key.getParams().getCurve();
    ScalarOps sc = key.getParams().getScalarOps();
    byte[] a = ((EdDSAPrivateKey) key).geta();

    byte[] message = baos.toByteArray();
    // r = H(h_b,...,h_2b-1,M)
    byte[] r = digest.digest(message);

    // r mod l
    // Reduces r from 64 bytes to 32 bytes
    r = sc.reduce(r);

    // R = rB
    GroupElement R = key.getParams().getB().scalarMultiply(r);
    byte[] Rbyte = R.toByteArray();

    // S = (r + H(Rbar,Abar,M)*a) mod l
    digest.update(Rbyte);
    digest.update(((EdDSAPrivateKey) key).getAbyte());
    byte[] h = digest.digest(message);
    h = sc.reduce(h);
    byte[] S = sc.multiplyAndAdd(h, a, r);

    // R+S
    int b = curve.getField().getb();
    ByteBuffer out = ByteBuffer.allocate(b/4);
    out.put(Rbyte).put(S);
    return out.array();
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:32,代码来源:EdDSAEngine.java

示例2: x_engineSign

import net.i2p.crypto.eddsa.math.ScalarOps; //导入方法依赖的package包/类
private byte[] x_engineSign() throws SignatureException {
    Curve curve = key.getParams().getCurve();
    ScalarOps sc = key.getParams().getScalarOps();
    byte[] a = ((EdDSAPrivateKey) key).geta();

    byte[] message;
    int offset, length;
    if (oneShotMode) {
        if (oneShotBytes == null)
            throw new SignatureException("update() not called first");
        message = oneShotBytes;
        offset = oneShotOffset;
        length = oneShotLength;
    } else {
        if (baos == null)
            message = new byte[0];
        else
            message = baos.toByteArray();
        offset = 0;
        length = message.length;
    }
    // r = H(h_b,...,h_2b-1,M)
    digest.update(message, offset, length);
    byte[] r = digest.digest();

    // r mod l
    // Reduces r from 64 bytes to 32 bytes
    r = sc.reduce(r);

    // R = rB
    GroupElement R = key.getParams().getB().scalarMultiply(r);
    byte[] Rbyte = R.toByteArray();

    // S = (r + H(Rbar,Abar,M)*a) mod l
    digest.update(Rbyte);
    digest.update(((EdDSAPrivateKey) key).getAbyte());
    digest.update(message, offset, length);
    byte[] h = digest.digest();
    h = sc.reduce(h);
    byte[] S = sc.multiplyAndAdd(h, a, r);

    // R+S
    int b = curve.getField().getb();
    ByteBuffer out = ByteBuffer.allocate(b / 4);
    out.put(Rbyte).put(S);
    return out.array();
}
 
开发者ID:ubirch,项目名称:ubirch-scala-utils,代码行数:48,代码来源:EdDSAEngine.java

示例3: x_engineSign

import net.i2p.crypto.eddsa.math.ScalarOps; //导入方法依赖的package包/类
private byte[] x_engineSign() throws SignatureException {
    Curve curve = key.getParams().getCurve();
    ScalarOps sc = key.getParams().getScalarOps();
    byte[] a = ((EdDSAPrivateKey) key).geta();

    byte[] message;
    int offset, length;
    if (oneShotMode) {
        if (oneShotBytes == null)
            throw new SignatureException("update() not called first");
        message = oneShotBytes;
        offset = oneShotOffset;
        length = oneShotLength;
    } else {
        if (baos == null)
            message = new byte[0];
        else
            message = baos.toByteArray();
        offset = 0;
        length = message.length;
    }
    // r = H(h_b,...,h_2b-1,M)
    digest.update(message, offset, length);
    byte[] r = digest.digest();

    // r mod l
    // Reduces r from 64 bytes to 32 bytes
    r = sc.reduce(r);

    // R = rB
    GroupElement R = key.getParams().getB().scalarMultiply(r);
    byte[] Rbyte = R.toByteArray();

    // S = (r + H(Rbar,Abar,M)*a) mod l
    digest.update(Rbyte);
    digest.update(((EdDSAPrivateKey) key).getAbyte());
    digest.update(message, offset, length);
    byte[] h = digest.digest();
    h = sc.reduce(h);
    byte[] S = sc.multiplyAndAdd(h, a, r);

    // R+S
    int b = curve.getField().getb();
    ByteBuffer out = ByteBuffer.allocate(b/4);
    out.put(Rbyte).put(S);
    return out.array();
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:48,代码来源:EdDSAEngine.java


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