#include "test.h" #include #include "scalarmul.h" #include "ec_point.h" #include "field.h" #include "crandom.h" #define STRIDE 7 /* 0 = succeed, 1 = inval, -1 = fail */ static int single_scalarmul_compatibility_test ( const struct field_t *base, const word_t *scalar, int nbits ) { struct tw_extensible_t text, work; struct field_t mont, ct, vl, vt; int ret = 0, i; mask_t succ, succm; succ = deserialize_and_twist_approx(&text, &sqrt_d_minus_1, base); succm = montgomery_ladder(&mont,base,scalar,nbits,1); if (succ != succm) { youfail(); printf(" Deserialize_and_twist_approx succ=%d, montgomery_ladder succ=%d\n", (int)-succ, (int)-succm); printf(" nbits = %d\n", nbits); field_print(" base", base); scalar_print(" scal", scalar, (nbits+WORD_BITS-1)/WORD_BITS); return -1; } if (!succ) { return 1; } struct { int n,t,s; } params[] = {{5,5,18},{3,5,30},{4,4,28},{1,2,224}}; // FIELD_MAGIC const int nparams = sizeof(params)/sizeof(params[0]); struct fixed_base_table_t fbt; const int nsizes = 6; struct field_t fbout[nparams], wout[nsizes]; memset(&fbt, 0, sizeof(fbt)); memset(&fbout, 0, sizeof(fbout)); memset(&wout, 0, sizeof(wout)); /* compute using combs */ for (i=0; i