本文整理汇总了Java中org.bouncycastle.math.ec.ECPoint.equals方法的典型用法代码示例。如果您正苦于以下问题:Java ECPoint.equals方法的具体用法?Java ECPoint.equals怎么用?Java ECPoint.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.math.ec.ECPoint
的用法示例。
在下文中一共展示了ECPoint.equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.bouncycastle.math.ec.ECPoint; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SecureRandom sr = new SecureRandom(); // SecureRandom is thread-safe
Security.addProvider(new BouncyCastleProvider());
ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec("P-256");
BigInteger n = ecSpec.getN();
KeyPairGenerator kpg = KeyPairGenerator.getInstance("ECDSA", "BC");
kpg.initialize(ecSpec, new SecureRandom());
KeyPair pair = kpg.generateKeyPair();
ECPoint pki = ((ECPublicKey) pair.getPublic()).getQ();
BigInteger xi = ((ECPrivateKey) pair.getPrivate()).getD();
// BigInteger xi = getRandom(n);
System.out.println("xi = " + xi);
BigInteger xj = getRandom(sr, n);
System.out.println("xj = " + xj);
ECPoint g = ecSpec.getG();
encoded(g);
// ECPoint pki = g.multiply(xi);
System.out.println("pki = " + pki);
encoded(pki);
ECPoint pkj = g.multiply(xj);
System.out.println("pkj = " + pkj);
encoded(pkj);
ECPoint m = g.multiply(getRandom(sr, n));
System.out.println("m = " + m);
encoded(m);
ECPoint[] c = encrypt(ecSpec, pki, m, sr);
ECPoint m2 = decrypt(ecSpec, xi, c);
System.out.println("m2 = " + m2);
encoded(m2);
if (!m2.equals(m)) {
System.out.println("Error 1!");
} else {
System.out.println("m == m2? " + m2.equals(m));
}
// RKG & REENC
BigInteger invxi = xi.modInverse(n);
BigInteger rk = xj.multiply(invxi).mod(n);
ECPoint[] c_j = reencrypt(ecSpec, rk, c);
ECPoint m3 = decrypt(ecSpec, xj, c_j);
System.out.println("m3 = " + m3);
if (!m3.equals(m))
System.out.println("Error 2!");
}