2021SC@SDUSC 山东大学软件学院软件工程应用与实践
1、mrebrick.c结构
mrebrick.c的总体结构如下,,主要实现了ebrick_init()、 ebrick_end()、mul_brick()几个在miracl开源库中比较重要的函数,这一次的博客就是读一下这函数的功能。
2、源代码
BOOL ebrick_init(_MIPD_ ebrick *B,big x,big y,big a,big b,big n,int window,int nb)
{ /* Uses Montgomery arithmetic internally *
* (x,y) is the fixed base *
* a,b and n are parameters and modulus of the curve *
* window is the window size in bits and *
* nb is the maximum number of bits in the multiplier */
int i,j,k,t,bp,len,bptr,is;
epoint **table;
epoint *w;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (nb<2 || window<1 || window>nb || mr_mip->ERNUM) return FALSE;
t=MR_ROUNDUP(nb,window);
if (t<2) return FALSE;
MR_IN(115)
#ifndef MR_ALWAYS_BINARY
if (mr_mip->base != mr_mip->base2)
{
mr_berror(_MIPP_ MR_ERR_NOT_SUPPORTED);
MR_OUT
return FALSE;
}
#endif
B->window=window;
B->max=nb;
table=(epoint **)mr_alloc(_MIPP_ (1<<window),sizeof(epoint *));
if (table==NULL)
{
mr_berror(_