📄 lib_bgnzn.h
字号:
#ifndef _LIB_BIGINTZMOD_H
#define _LIB_BIGINTZMOD_H
#include "lib_type.h"
/**
* for test only
*
* to query the status of BIGINTZMOD Module
*
**/
void print_bgn_zn_status();
/**
*
* start bgn_z_mod module
*
**/
BGNZN_MD_ID bgn_zn_start( const BIGINT *n );
/**
*
* end bgn_z_mod module
*
**/
void bgn_zn_end(BGNZN_MD_ID bgnzn_md_id);
/**
* clone src to des
* return des where des = src
**/
void bgn_zn_clone(BGNZN_MD_ID bgnzn_md_id,const BIGINT * src,BIGINT * des);
/**
* compare a and b
* if a > b, then return 1
* if a = b, then return 0
* if a < b, then return -1
**/
int bgn_zn_cmp(BGNZN_MD_ID bgnzn_md_id,const BIGINT * a,const BIGINT *b);
/**
*
* set a = 0
**/
void bgn_zn_set_zero(BGNZN_MD_ID bgnzn_md_id,BIGINT * a);
/**
*
* set a = 1
**/
void bgn_zn_set_one(BGNZN_MD_ID bgnzn_md_id,BIGINT * a);
/**
*
* set a = n
**/
void bgn_zn_set_word(BGNZN_MD_ID bgnzn_md_id,BIGINT *a,UINT32 n);
/**
* return e = 2 ^ nth mod n
* = ( 1 << nth ) mod n
* where nth = 0,1,...,{BIGINTSIZE - 1}
*
**/
void bgn_zn_set_e(BGNZN_MD_ID bgnzn_md_id,BIGINT *e,const UINT32 nth);
/**
*
* set a = 2^ {BIGINTSIZE} - 1 mod n
**/
void bgn_zn_set_max(BGNZN_MD_ID bgnzn_md_id,BIGINT * a);
/**
*
* if src = 0, then return EC_TRUE
* if src !=0, then return EC_FALSE
*
**/
EC_BOOL bgn_zn_is_zero(BGNZN_MD_ID bgnzn_md_id,const BIGINT* src);
/**
*
* if src = 1, then return EC_TRUE
* if src !=1, then return EC_FALSE
*
**/
EC_BOOL bgn_zn_is_one(BGNZN_MD_ID bgnzn_md_id,const BIGINT* src);
/**
*
* if src is odd, then return EC_TRUE
* if src is even, then return EC_FALSE
*
**/
EC_BOOL bgn_zn_is_odd(BGNZN_MD_ID bgnzn_md_id,BIGINT *src);
/**
* let a belong to [0, n - 1], then
* c = ( a >> WORDSIZE ) mod n = (a >> nbits)
* return c
*
**/
void bgn_zn_shr_onewordsize(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,BIGINT *c);
/**
* let a belong to [0, n - 1], then
* c = ( a >> nbits ) mod n = (a >> nbits)
* return c
*
**/
void bgn_zn_shr_lesswordsize(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a, const UINT32 nbits,BIGINT *c);
/**
* let a belong to [0, n - 1], then
* c = ( a << WORDSIZE ) mod n
* return c
*
**/
void bgn_zn_shl_onewordsize(BGNZN_MD_ID bgnzn_md_id,const BIGINT * a, BIGINT * c);
/**
* let a belong to [0, n - 1], then
* c = ( a << nbits ) mod n
* return c
*
**/
void bgn_zn_shl_lesswordsize(BGNZN_MD_ID bgnzn_md_id,const BIGINT * a, const UINT32 nbits, BIGINT * c);
/**
** Let the NAF representative of k be
* k = SUM ( s_i * 2 ^ i, where s_i belong to {1,0,-1} and i = 0..n )
* Then return s = [ s_0,...,s_n ] and n
* i.e,
* s[ 0 ] = s_0,... s[ n ] = s_n
*
*
**/
int bgn_zn_naf(BGNZN_MD_ID bgnzn_md_id,const BIGINT *k,int *s);
/**
* c = ( a + b ) mod n
* where a < n and b < n
*
**/
void bgn_zn_add(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,const BIGINT *b, BIGINT *c );
/**
* c = ( a - b ) mod n
* where a < n and b < n
*
**/
void bgn_zn_sub(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,const BIGINT *b,BIGINT *c );
/**
void bgn_zn_neg(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,BIGINT *c );
* c = ( a * b ) mod n
* where a < n and b < n
*
**/
void bgn_zn_mul(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,const BIGINT *b,BIGINT *c );
/**
* c = ( a ^ 2 ) mod n
* where a < n
*
**/
void bgn_zn_squ(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,BIGINT *c );
/**
* c = ( a ^ e ) mod n
* where 0 < a < n and e < 2 ^ WORDSIZE
*
**/
void bgn_zn_sexp(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,const UINT32 e,BIGINT *c );
/**
* c = ( a ^ e ) mod n
* where 0 < a < n and e < 2 ^ BIGINTSIZE
*
**/
void bgn_zn_exp(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,const BIGINT *e,BIGINT *c );
/**
*
* if a = 0 , then return EC_FALSE
* if n > a > 0 and GCD(a,n) > 1, then return EC_FALSE
* if n > a > 0 and GCD(a,n) = 1, then return EC_TRUE and
* c = ( 1 / a ) mod n
* where 0 < a < n
*
**/
EC_BOOL bgn_zn_inv(BGNZN_MD_ID bgnzn_md_id,const BIGINT *a,BIGINT *c );
#endif /* _LIB_BIGINTZMOD_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -