如何使用org.bouncycastle.math.ec.ECPoint.subtract()方法进行椭圆曲线点减法操作?
- 内容介绍
- 文章标签
- 相关推荐
本文共计900个文字,预计阅读时间需要4分钟。
本文简要介绍了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的原理,并给出了一些代码示例。
Java中的ECPoint.subtract()方法用于计算两个椭圆曲线点之间的差值。该方法遵循以下步骤:
1. 获取两个椭圆曲线点P和Q。
2.计算点P和Q的坐标。
3.使用椭圆曲线减法公式计算结果点R。
以下是ECPoint.subtract()方法的一个简单示例:
java
import org.bouncycastle.math.ec.ECPoint;import org.bouncycastle.math.ec.ECFieldElement;import org.bouncycastle.math.ec.ECCurve;// 创建椭圆曲线参数ECCurve curve=new ECCurve.Fp( new BigInteger(6277101735386680763835789423207666416083908700390324961279, 16), new BigInteger(2188824287183927522224640574525727508854836440049077083318, 16), new BigInteger(269599466671506397946670150870196005136670747375756852309, 16), new BigInteger(5, 16));
// 创建椭圆曲线点P和QECPoint P=curve.createPoint(new BigInteger(3, 16), new BigInteger(5, 16));ECPoint Q=curve.createPoint(new BigInteger(6, 16), new BigInteger(7, 16));
// 计算点RECPoint R=P.subtract(Q);
// 输出结果System.out.println(P: + P);System.out.println(Q: + Q);System.out.println(R: + R);
在上述示例中,我们首先创建了椭圆曲线参数和两个点P和Q。然后,我们使用subtract()方法计算了点R。最后,我们输出了点P、Q和R的坐标。
本文整理了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]);
本文共计900个文字,预计阅读时间需要4分钟。
本文简要介绍了Java中org.bouncycastle.math.ec.ECPoint.subtract()方法的原理,并给出了一些代码示例。
Java中的ECPoint.subtract()方法用于计算两个椭圆曲线点之间的差值。该方法遵循以下步骤:
1. 获取两个椭圆曲线点P和Q。
2.计算点P和Q的坐标。
3.使用椭圆曲线减法公式计算结果点R。
以下是ECPoint.subtract()方法的一个简单示例:
java
import org.bouncycastle.math.ec.ECPoint;import org.bouncycastle.math.ec.ECFieldElement;import org.bouncycastle.math.ec.ECCurve;// 创建椭圆曲线参数ECCurve curve=new ECCurve.Fp( new BigInteger(6277101735386680763835789423207666416083908700390324961279, 16), new BigInteger(2188824287183927522224640574525727508854836440049077083318, 16), new BigInteger(269599466671506397946670150870196005136670747375756852309, 16), new BigInteger(5, 16));
// 创建椭圆曲线点P和QECPoint P=curve.createPoint(new BigInteger(3, 16), new BigInteger(5, 16));ECPoint Q=curve.createPoint(new BigInteger(6, 16), new BigInteger(7, 16));
// 计算点RECPoint R=P.subtract(Q);
// 输出结果System.out.println(P: + P);System.out.println(Q: + Q);System.out.println(R: + R);
在上述示例中,我们首先创建了椭圆曲线参数和两个点P和Q。然后,我们使用subtract()方法计算了点R。最后,我们输出了点P、Q和R的坐标。
本文整理了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]);

