miracl库下椭圆曲线方程常用函数使用入门

本文介绍了MIRACL库中用于椭圆曲线GF(p)的常用函数,包括椭圆曲线初始化、点乘、点加减、点比较、点复制等操作。还提到了椭圆曲线方程的参数示例,如SM2国密算法的推荐参数,并提供了代码实例来验证点坐标在曲线上的合法性。
摘要由CSDN通过智能技术生成

下面列举了椭圆曲线GF(p)素数域常用函数:(持续更新)



椭圆曲线GF(p)素数域常用函数:
1.椭圆曲线方程初始化
ecurve_init
Function: void ecurve_init(A,B,p,type)
big A,B,p;
int type;
Module: mrcurve.c
Description: Initialises the internal parameters of the current active GF(p) elliptic curve. The curve is assumed to be of the form y2 =x3 + Ax + B mod p, the so-called Weierstrass model. This routine can be called subsequently with the parameters of a different curve.
Parameters: Three big numbers A, B and p. The type parameter must be either MR_PROJECTIVE or MR_AFFINE, and specifies whether projective or affine co-ordinates should be used internally. Normally the former is faster. (投影坐标、仿射坐标)
Return value: None

2.点乘
ecurve_mult
Function: void ecurve_mult(k,p,pa)
big k;
epoint *p,*pa;
Description: Multiplies a point on a GP(p) elliptic curve by an integer. Uses the addition/subtraction method.
Parameters: A big number k, and two points p and pa. On exit pa=k*p.
Return value: None
Restrictions: The point p must be on the active curve.

3.点乘加快速运算
ecurve_mult2
Function: void ecurve_mult2(k1,p1,k2,p2,pa)
big k1,k2;
epoint *p1,*p2,*pa;
Description: Calculates the point k1.p1+k2.p2 on a GF(p) elliptic curve. This is quicker than doing two separate multiplications and an addition. Useful for certain cryptosystems. (See ecsver.c for example)
Parameters: Two big integers k1 and k2, and three points p1, p2 and pa.
On exit pa = k1.p1+k2.p2
Return value: None

4.点的加法pa=pa+a
ecurve_add
Function: void ecurve_add(p,pa)
epoint *p,*pa;
Description: Adds two points on a GF(p) elliptic curve using the special rule for addition. Note that if pa=p, then a different duplication rule is used. Addition is quicker if p is normalised.
Parameters: Two points on the current active curve, pa and p. On exit pa=pa+p.
Return value: None
Restrictions: The input points must actually be on the current active curve.

5.点的减法pa=pa-a
ecurve_sub
Function: void ecurve_sub(p,pa)
epoint *p,*pa;
Description: Subtracts two points on a GF(p) elliptic curve. Actually negates p and adds it to pa. Subtraction is quicker if p is normalised.
Parameters: Two points on the current active curve, pa and p. On exit pa = pa-p.
Return value: None
Restrictions: The input points must actually be on the current active curve.

6.比较椭圆曲线上两个点是否相同
epoint_comp
Function: BOOL epoint_comp(p1,p2)
epoint *p1,*p2;
Description: Compares two points on the current active GF(p) elliptic curve.
Parameters: Two points p1 and p2.
Return Value: TRUE if the points are the same, otherwise FALSE.

7.点的复制
epoint_copy
Function: void epoint_copy(p1,p2)
epoint *p1,*p2;
Description: Copies one point to another on a GF(p) ellip

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值