/* Galbraith & Scott Method */ static void gs(BIG u[4],BIG e) { int i,j; BIG v[4],t,q; DBIG d; BIG_rcopy(q,CURVE_Order); for (i=0;i<4;i++) { BIG_rcopy(t,CURVE_WB[i]); BIG_mul(d,t,e); BIG_ddiv(v[i],d,q); BIG_zero(u[i]); } BIG_copy(u[0],e); for (i=0;i<4;i++) for (j=0;j<4;j++) { BIG_rcopy(t,CURVE_BB[j][i]); BIG_modmul(t,v[j],t,q); BIG_add(u[i],u[i],q); BIG_sub(u[i],u[i],t); BIG_mod(u[i],q); } return; }
/* Galbraith & Scott Method */ static void gs(BIG u[4],BIG e) { int i; #if CHOICE<BLS_CURVES int j; BIG v[4],t,q; DBIG d; BIG_rcopy(q,CURVE_Order); for (i=0; i<4; i++) { BIG_rcopy(t,CURVE_WB[i]); //BIG_norm(t); BIG_norm(e); BIG_mul(d,t,e); BIG_ddiv(v[i],d,q); BIG_zero(u[i]); } BIG_copy(u[0],e); for (i=0; i<4; i++) for (j=0; j<4; j++) { BIG_rcopy(t,CURVE_BB[j][i]); BIG_modmul(t,v[j],t,q); BIG_add(u[i],u[i],q); BIG_sub(u[i],u[i],t); BIG_mod(u[i],q); } #else BIG x,w; BIG_rcopy(x,CURVE_Bnx); BIG_copy(w,e); for (i=0; i<4; i++) { BIG_copy(u[i],w); BIG_mod(u[i],x); BIG_sdiv(w,x); } #endif return; }
/* GLV method */ static void glv(BIG u[2],BIG e) { #if CHOICE<BLS_CURVES int i,j; BIG v[2],t,q; DBIG d; BIG_rcopy(q,CURVE_Order); for (i=0; i<2; i++) { BIG_rcopy(t,CURVE_W[i]); //BIG_norm(t); BIG_norm(e); BIG_mul(d,t,e); BIG_ddiv(v[i],d,q); BIG_zero(u[i]); } BIG_copy(u[0],e); for (i=0; i<2; i++) for (j=0; j<2; j++) { BIG_rcopy(t,CURVE_SB[j][i]); BIG_modmul(t,v[j],t,q); BIG_add(u[i],u[i],q); BIG_sub(u[i],u[i],t); BIG_mod(u[i],q); } #else // -(x^2).P = (Beta.x,y) BIG x,x2,q; BIG_rcopy(x,CURVE_Bnx); BIG_smul(x2,x,x); BIG_copy(u[0],e); BIG_mod(u[0],x2); BIG_copy(u[1],e); BIG_sdiv(u[1],x2); BIG_rcopy(q,CURVE_Order); BIG_sub(u[1],q,u[1]); #endif return; }