arkq / SM2349

GM/T serial standards implementations
17 stars 7 forks source link

SM2_ENC.c Floating point exception (core dumped) #1

Closed shatanyumi closed 2 years ago

shatanyumi commented 2 years ago

int Test_Point(epoint *point) { big x, y, x_3, tmp; x = mirvar(0); y = mirvar(0); x_3 = mirvar(0); tmp = mirvar(0);

//test if y^2=x^3+ax+b
epoint_get(point, x, y);
power(x, 3, para_p, x_3);        //x_3=x^3 mod p
multiply(x, para_a, x);           //x=a*x
divide(x, para_p, tmp);          //x=a*x mod p  , tmp=a*x/p
add(x_3, x, x);                     //x=x^3+ax
add(x, para_b, x);                  //x=x^3+ax+b
divide(x, para_p, tmp);             //x=x^3+ax+b mod p
power(y, 2, para_p, y);          //y=y^2 mod p
if (mr_compare(x, y) != 0)
    return ERR_NOT_VALID_POINT;
else return 0;

}

could u please tell me which version of the miral.a that is used by the repo?

arkq commented 2 years ago

could u please tell me which version of the miral.a that is used by the repo?

You should be able to use the newest version of MIRACL library: https://github.com/miracl/MIRACL In the latest commit I've added a brief instruction how to build all these reference algorithms.