如何运用org.bouncycastle.math.ec.ECPoint.subtract()方法精确计算椭圆曲线上的点相减操作?
- 内容介绍
- 文章标签
- 相关推荐
本文共计725个文字,预计阅读时间需要3分钟。
本文简要梳理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subtract()方法的基本使用。
示例代码如下:
javaimport org.bouncycastle.math.ec.ECPoint;import org.bouncycastle.math.ec.ECAlgorithms;import org.bouncycastle.math.ec.ECConstants;
// 创建两个点ECPoint p1=ECAlgorithms.createECPairingPoint(ECConstants.Fp256, new BigInteger(0x6b17d2f02e30c85e2b57e743fe4341ed8aa956a47983978a325728eb97816885ff), new BigInteger(0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315e3ca435ed107bd18));ECPoint p2=ECAlgorithms.createECPairingPoint(ECConstants.Fp256, new BigInteger(0x6b17d2f02e30c85e2b57e743fe4341ed8aa956a47983978a325728eb97816885ff), new BigInteger(0x3a3e7f9b7d1c8b0f6a9c3b9e9c392a2c7fe28b959f2815b16f81798482b7e66));
// 计算两点之差ECPoint result=p1.subtract(p2);
// 输出结果System.out.println(Result: + result);
本文整理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subt本文整理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subtract()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ECPoint.subtract()方法的具体详情如下:包路径:org.bouncycastle.math.ec.ECPoint类名称:ECPoint方法名:subtract
ECPoint.subtract介绍
暂无
代码示例
代码示例来源:origin: redfish64/TinyTravelTracker
/** * Decrypt an EC pair producing the original EC point. * * @param pair the EC point pair to process. * @return the result of the Elgamal process. */ public ECPoint decrypt(ECPair pair) { if (key == null) { throw new IllegalStateException("ECElGamalDecryptor not initialised"); } ECPoint tmp = pair.getX().multiply(key.getD()); return pair.getY().subtract(tmp).normalize(); }}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
/** * Decrypt an EC pair producing the original EC point. * * @param pair the EC point pair to process. * @return the result of the Elgamal process. */ public ECPoint decrypt(ECPair pair) { if (key == null) { throw new IllegalStateException("ECElGamalDecryptor not initialised"); } ECCurve curve = key.getParameters().getCurve(); ECPoint tmp = ECAlgorithms.cleanPoint(curve, pair.getX()).multiply(key.getD()); return ECAlgorithms.cleanPoint(curve, pair.getY()).subtract(tmp).normalize(); }}
代码示例来源:origin: redfish64/TinyTravelTracker
static ECPoint implShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l){ ECCurve curve = P.getCurve(); ECPoint infinity = curve.getInfinity(); // TODO conjugate co-Z addition (ZADDC) can return both of these ECPoint PaddQ = P.add(Q); ECPoint PsubQ = P.subtract(Q); ECPoint[] points = new ECPoint[]{ Q, PsubQ, P, PaddQ }; curve.normalizeAll(points); ECPoint[] table = new ECPoint[] { points[3].negate(), points[2].negate(), points[1].negate(), points[0].negate(), infinity, points[0], points[1], points[2], points[3] }; byte[] jsf = WNafUtil.generateJSF(k, l); ECPoint R = infinity; int i = jsf.length; while (--i >= 0) { int jsfi = jsf[i]; // NOTE: The shifting ensures the sign is extended correctly int kDigit = ((jsfi <> 28), lDigit = ((jsfi <> 28); int index = 4 + (kDigit * 3) + lDigit; R = R.twicePlus(table[index]); } return R;}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
static ECPoint implShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l){ ECCurve curve = P.getCurve(); ECPoint infinity = curve.getInfinity(); // TODO conjugate co-Z addition (ZADDC) can return both of these ECPoint PaddQ = P.add(Q); ECPoint PsubQ = P.subtract(Q); ECPoint[] points = new ECPoint[]{ Q, PsubQ, P, PaddQ }; curve.normalizeAll(points); ECPoint[] table = new ECPoint[] { points[3].negate(), points[2].negate(), points[1].negate(), points[0].negate(), infinity, points[0], points[1], points[2], points[3] }; byte[] jsf = WNafUtil.generateJSF(k, l); ECPoint R = infinity; int i = jsf.length; while (--i >= 0) { int jsfi = jsf[i]; // NOTE: The shifting ensures the sign is extended correctly int kDigit = ((jsfi <> 28), lDigit = ((jsfi <> 28); int index = 4 + (kDigit * 3) + lDigit; R = R.twicePlus(table[index]); } return R;}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
pow2Table[minWidth] = pow2Table[0].subtract(pow2Table[1]);
本文共计725个文字,预计阅读时间需要3分钟。
本文简要梳理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subtract()方法的基本使用。
示例代码如下:
javaimport org.bouncycastle.math.ec.ECPoint;import org.bouncycastle.math.ec.ECAlgorithms;import org.bouncycastle.math.ec.ECConstants;
// 创建两个点ECPoint p1=ECAlgorithms.createECPairingPoint(ECConstants.Fp256, new BigInteger(0x6b17d2f02e30c85e2b57e743fe4341ed8aa956a47983978a325728eb97816885ff), new BigInteger(0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315e3ca435ed107bd18));ECPoint p2=ECAlgorithms.createECPairingPoint(ECConstants.Fp256, new BigInteger(0x6b17d2f02e30c85e2b57e743fe4341ed8aa956a47983978a325728eb97816885ff), new BigInteger(0x3a3e7f9b7d1c8b0f6a9c3b9e9c392a2c7fe28b959f2815b16f81798482b7e66));
// 计算两点之差ECPoint result=p1.subtract(p2);
// 输出结果System.out.println(Result: + result);
本文整理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subt本文整理了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的一些代码示例,展示了ECPoint.subtract()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ECPoint.subtract()方法的具体详情如下:包路径:org.bouncycastle.math.ec.ECPoint类名称:ECPoint方法名:subtract
ECPoint.subtract介绍
暂无
代码示例
代码示例来源:origin: redfish64/TinyTravelTracker
/** * Decrypt an EC pair producing the original EC point. * * @param pair the EC point pair to process. * @return the result of the Elgamal process. */ public ECPoint decrypt(ECPair pair) { if (key == null) { throw new IllegalStateException("ECElGamalDecryptor not initialised"); } ECPoint tmp = pair.getX().multiply(key.getD()); return pair.getY().subtract(tmp).normalize(); }}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
/** * Decrypt an EC pair producing the original EC point. * * @param pair the EC point pair to process. * @return the result of the Elgamal process. */ public ECPoint decrypt(ECPair pair) { if (key == null) { throw new IllegalStateException("ECElGamalDecryptor not initialised"); } ECCurve curve = key.getParameters().getCurve(); ECPoint tmp = ECAlgorithms.cleanPoint(curve, pair.getX()).multiply(key.getD()); return ECAlgorithms.cleanPoint(curve, pair.getY()).subtract(tmp).normalize(); }}
代码示例来源:origin: redfish64/TinyTravelTracker
static ECPoint implShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l){ ECCurve curve = P.getCurve(); ECPoint infinity = curve.getInfinity(); // TODO conjugate co-Z addition (ZADDC) can return both of these ECPoint PaddQ = P.add(Q); ECPoint PsubQ = P.subtract(Q); ECPoint[] points = new ECPoint[]{ Q, PsubQ, P, PaddQ }; curve.normalizeAll(points); ECPoint[] table = new ECPoint[] { points[3].negate(), points[2].negate(), points[1].negate(), points[0].negate(), infinity, points[0], points[1], points[2], points[3] }; byte[] jsf = WNafUtil.generateJSF(k, l); ECPoint R = infinity; int i = jsf.length; while (--i >= 0) { int jsfi = jsf[i]; // NOTE: The shifting ensures the sign is extended correctly int kDigit = ((jsfi <> 28), lDigit = ((jsfi <> 28); int index = 4 + (kDigit * 3) + lDigit; R = R.twicePlus(table[index]); } return R;}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
static ECPoint implShamirsTrickJsf(ECPoint P, BigInteger k, ECPoint Q, BigInteger l){ ECCurve curve = P.getCurve(); ECPoint infinity = curve.getInfinity(); // TODO conjugate co-Z addition (ZADDC) can return both of these ECPoint PaddQ = P.add(Q); ECPoint PsubQ = P.subtract(Q); ECPoint[] points = new ECPoint[]{ Q, PsubQ, P, PaddQ }; curve.normalizeAll(points); ECPoint[] table = new ECPoint[] { points[3].negate(), points[2].negate(), points[1].negate(), points[0].negate(), infinity, points[0], points[1], points[2], points[3] }; byte[] jsf = WNafUtil.generateJSF(k, l); ECPoint R = infinity; int i = jsf.length; while (--i >= 0) { int jsfi = jsf[i]; // NOTE: The shifting ensures the sign is extended correctly int kDigit = ((jsfi <> 28), lDigit = ((jsfi <> 28); int index = 4 + (kDigit * 3) + lDigit; R = R.twicePlus(table[index]); } return R;}
代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on
pow2Table[minWidth] = pow2Table[0].subtract(pow2Table[1]);

