椭圆曲线点 [英] Elliptic curve point
问题描述
目前,iam正在开发一个使用椭圆曲线的项目。请给我一个解决方案,确定一个点是在椭圆曲线上吗?以及如何在椭圆曲线上获得点
Presently iam working on a project that uses elliptic curve. Please provide me a solution that determines whether a point is on the elliptic curve or not? and also how to get a point on the elliptic curve
推荐答案
检查点是否在椭圆曲线上很容易。只需检查您的点(x,y)
是否满足定义椭圆曲线的方程: y ^ 2 = x ^ 3 + ax + b
(记得在正确的字段中执行计算)。
Checking whether a point is on the elliptic curve is easy. Just check whether your point (x,y)
fulfills the equation defining your elliptic curve : y^2 = x^3 + ax + b
(remember to perform the calculation in the correct field).
使用Bouncycastle你可以这样做:
Using Bouncycastle you can do it like this:
ECCurve curve = //...
ECFieldElement x = //...
ECFieldElement y = //...
ECFieldElement a = curve.getA();
ECFieldElement b = curve.getB();
ECFieldElement lhs = y.multiply(y);
ECFieldElement rhs = x.multiply(x).multiply(x).add(a.multiply(x)).add(b);
boolean pointIsOnCurve = lhs.equals(rhs);
您已使用加密技术标记问题,因此我假设您要询问有限域上的椭圆曲线。该曲线将具有生成器 g 和订单。
要获取随机点,只需生成一个随机整数 x ,范围在0到(order -1)之间,然后选择 x * g 。
You have tagged the question with cryptography, so I assume you are asking about elliptic curves over a finite field. The curve will have a generator, g and an order. To get a random point, just generate a random integer, x, between 0 and (order - 1), and choose x * g.
您可以使用Bouncycastle这样做:
You can do it using Bouncycastle like this:
X9ECParameters x9 = NISTNamedCurves.getByName("P-224"); // or whatever curve you want to use
ECPoint g = x9.getG();
BigInteger n = x9.getN();
int nBitLength = n.bitLength();
BigInteger x;
do
{
x = new BigInteger(nBitLength, random);
}
while (x.equals(ZERO) || (x.compareTo(n) >= 0));
ECPoint randomPoint = g.multiply(x);
这篇关于椭圆曲线点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!