本文整理汇总了Java中org.bouncycastle.math.ec.ECPoint.add方法的典型用法代码示例。如果您正苦于以下问题:Java ECPoint.add方法的具体用法?Java ECPoint.add怎么用?Java ECPoint.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.math.ec.ECPoint
的用法示例。
在下文中一共展示了ECPoint.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sm2Verify
import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
public void sm2Verify(byte md[], ECPoint userKey, BigInteger r, BigInteger s, SM2Result sm2Result) {
sm2Result.R = null;
BigInteger e = new BigInteger(1, md);
BigInteger t = r.add(s).mod(ecc_n);
if (t.equals(BigInteger.ZERO)) {
return;
} else {
ECPoint x1y1 = ecc_point_g.multiply(sm2Result.s);
System.out.println("X0: " + x1y1.getX().toBigInteger().toString(16));
System.out.println("Y0: " + x1y1.getY().toBigInteger().toString(16));
System.out.println("");
x1y1 = x1y1.add(userKey.multiply(t));
System.out.println("X1: " + x1y1.getX().toBigInteger().toString(16));
System.out.println("Y1: " + x1y1.getY().toBigInteger().toString(16));
System.out.println("");
sm2Result.R = e.add(x1y1.getX().toBigInteger()).mod(ecc_n);
System.out.println("R: " + sm2Result.R.toString(16));
return;
}
}
示例2: Verify
import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
private static boolean Verify(byte[] plaintext, ECPoint pubkey, BigInteger s_bi, BigInteger e_bi) throws Exception {
// Compute rv = sG+eY
ECPoint rv_EC = mpcGlobals.G.multiply(s_bi); // sG
rv_EC = rv_EC.add(pubkey.multiply(e_bi)); // +eY
// Compute ev = H(m||rv)
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(plaintext);
md.update(rv_EC.getEncoded(false));
byte[] ev = md.digest();
BigInteger ev_bi = new BigInteger(1, ev);
ev_bi = ev_bi.mod(mpcGlobals.n);
///System.out.println(bytesToHex(e_bi.toByteArray()));
//System.out.println(bytesToHex(ev_bi.toByteArray()));
if (_FAIL_ON_ASSERT) {
assert (e_bi.compareTo(ev_bi) == 0);
}
// compare ev with e
return e_bi.compareTo(ev_bi) == 0;
}
示例3: encrypt
import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
public static ECPoint[] encrypt(ECParameterSpec ecSpec, ECPoint pk, ECPoint m, SecureRandom sr) {
ECPoint g = ecSpec.getG();
BigInteger n = ecSpec.getN();
BigInteger r = getRandom(sr, n);
ECPoint g_r = g.multiply(r);
ECPoint m_g_r = g_r.add(m);
ECPoint pk_r = pk.multiply(r);
return new ECPoint[] { pk_r, m_g_r };
}