⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_ecf2n.h

📁 用于ECC公钥密码算法的大数运算库
💻 H
字号:
#ifndef _LIB_ECF2N_H
#define _LIB_ECF2N_H

#include "lib_type.h"

/**
*   for test only
*
*   to query the status of ECF2N Module
*
**/
void print_ec_f2n_status();

/**
*
* start ECF2N module 
*
**/
ECF2N_MD_ID ec_f2n_start( const BIGINT *f_x, const ECF2N_CURVE *curve, const BIGINT *order, const EC_CURVE_POINT *base_point );

/**
*
* end ECF2N module 
*
**/
void ec_f2n_end(ECF2N_MD_ID ecf2n_md_id);

/**
*   define Point (0,0) as infinit point
*   if the point P is equal to (0,0), then return EC_TRUE
*   otherwise, return EC_FALSE
*
**/
EC_BOOL ec_f2n_point_is_infinit(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P);

/**
*
*   set point P = (0,0) as the infinit point
*   return the point P
*
**/
void ec_f2n_point_set_infinit(ECF2N_MD_ID ecf2n_md_id, EC_CURVE_POINT * P);

/**
*
*   define affine Point [x:y:0] as infinit affine point
*   if the z of affine point P is zero, then return EC_TRUE
*   otherwise, return EC_FALSE
*
**/
UINT32 ec_f2n_point_aff_is_infinit(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P);

/**
*
*   set affine point P = [1:0:0] as the infinit affine point
*   return the affine point P
*
**/
void ec_f2n_point_aff_set_infinit(ECF2N_MD_ID ecf2n_md_id, EC_CURVE_AFF_POINT * P);

/**
*
*   copy point src to des
*   return des
*
**/
void ec_f2n_point_clone(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * src,EC_CURVE_POINT * des);

/**
*
*   copy affine point src to des
*   return des
*
**/
void ec_f2n_point_aff_clone(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * src,EC_CURVE_AFF_POINT * des);

/**
*   
*   if point curve_1  = curve_2, then return 0
*   if point curve_1 != curve_2, then return 1
*   
**/
UINT32 ec_f2n_curve_cmp(ECF2N_MD_ID ecf2n_md_id, const ECF2N_CURVE * curve_1,const ECF2N_CURVE * curve_2);

/**
*   
*   if point P  = Q, then return 0
*   if point P != Q, then return 1
*   
**/
UINT32 ec_f2n_point_cmp(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,const EC_CURVE_POINT * Q);

/**
*   
*   if affine point P  = Q, then return 0
*   if affine point P != Q, then return 1
*   
**/
UINT32 ec_f2n_point_aff_cmp(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P,const EC_CURVE_AFF_POINT * Q);

/**
*   
*   check point is on the elliptic curve(ec) refered by Module ID md_id
*   if the point is on the elliptic curve(ec), return EC_TRUE,
*   otherwise, return EC_FALSE
*   
**/
EC_BOOL ec_f2n_point_is_on_curve(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * point);

/**
*   let P = (x1,y1) be a point over ec
*   let negP = (x2,y2)= -P be a point over ec
*   return the negative point negP of P
*   the ec is refered by Module ID md_id
*   
*   note:
*       x2 = x1
*       y2 = x1 + y1 over F_{2^n}
*
**/
void ec_f2n_point_neg(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,EC_CURVE_POINT * negP);

/**
*   let P = [x1:y1:z1] be an affine point over ec
*   let Q = (x2,y2) be a point over ec
*   let R = [x3:y3:z3]
*   return R = P + Q over ec
*   
*   note : 
*       P address is not equal to R address
**/
void ec_f2n_point_mix_add(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P,const EC_CURVE_POINT * Q,EC_CURVE_AFF_POINT * R);

/**
*   let P = [x1:y1:z1] be an affine point over ec
*   let R = [x3:y3:z3]
void ec_f2n_point_mix_sub(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P,const EC_CURVE_POINT * Q,EC_CURVE_AFF_POINT * R);
*   return R = 2 * P over ec
*   
*   note : 
*       P address is not equal to R address
**/
void ec_f2n_point_aff_double(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P,EC_CURVE_AFF_POINT * R);

/**
void ec_f2n_point_convert(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,EC_CURVE_AFF_POINT * R);
*   let P = [x1:y1:z1] be an affine point over ec
*   let R = (x3,y3)
*   return R = P over ec
*   where
*       x3 = x1 / (z1)
*       y3 = y1 / (z1 ^ 2)   
*
*   note : 
*       P address is not equal to R address
**/
void ec_f2n_point_aff_convert(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_AFF_POINT * P,EC_CURVE_POINT * R);

/**
*   let P = (x1,y1) be an affine point over ec
*   let R = (x3,y3)
*   return R = k *P over ec
*
**/
void ec_f2n_point_aff_mul(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,const BIGINT * k,EC_CURVE_POINT * R);

/**
*   let P = (x1,y1) be an affine point over ec
*   let R = (x3,y3)
*   return R = k * P over ec
*
*   here, if the point P is basepoint, then use the basepoint-fixed algorithm, 
*   otherwise, use the NAF algorithm
*
**/
void ec_f2n_point_mul(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,const BIGINT * k,EC_CURVE_POINT * R);

/**
*   let P = (x1,y1) be a point over ec
*   let Q = (x2,y2) be a point over ec
*   let R = (x3,y3)
*   return R = P + Qover ec
*
**/
void ec_f2n_point_add(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,const EC_CURVE_POINT * Q,EC_CURVE_POINT * R);

/**
*   let P = (x1,y1) be a point over ec
*   let R = (x3,y3)
*   return R = 2 * P over ec
*
**/
void ec_f2n_point_double(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,EC_CURVE_POINT * R);

void ec_f2n_point_sub(ECF2N_MD_ID ecf2n_md_id, const EC_CURVE_POINT * P,const EC_CURVE_POINT * Q,EC_CURVE_POINT * R);

#endif /*_LIB_ECF2N_H*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -