當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。