diff --git a/src/decaf_fast.c b/src/decaf_fast.c index b658706..76a2391 100644 --- a/src/decaf_fast.c +++ b/src/decaf_fast.c @@ -681,32 +681,6 @@ void decaf_448_scalar_encode( } } -void decaf_448_point_scalarmul_xxx ( - decaf_448_point_t a, - const decaf_448_point_t b, - const decaf_448_scalar_t scalar -) { - /* w=2 signed window uses about 1.5 adds per bit. - * I figured a few extra lines was worth the 25% speedup. - */ - decaf_448_point_t w,b3,tmp; - decaf_448_point_double(w,b); - /* b3 = b*3 */ - decaf_448_point_add(b3,w,b); - int i; - for (i=DECAF_448_SCALAR_BITS &~ 1; i>0; i-=2) { - decaf_word_t bits = scalar->limb[i/WBITS]>>(i%WBITS); - decaf_448_cond_sel(tmp,b,b3,((bits^(bits>>1))&1)-1); - decaf_448_point_double(w,w); - decaf_448_point_add_sub(w,w,tmp,((bits>>1)&1)-1); - decaf_448_point_double(w,w); - } - decaf_448_point_add_sub(w,w,b,((scalar->limb[0]>>1)&1)-1); - /* low bit is special because fo signed window */ - decaf_448_cond_sel(tmp,b,decaf_448_point_identity,-(scalar->limb[0]&1)); - decaf_448_point_sub(a,w,tmp); -} - /* Operations on [p]niels */ static void cond_neg_niels ( niels_t n, @@ -971,24 +945,9 @@ decaf_bool_t decaf_448_point_valid ( return out; } -// void decaf_448_precompute ( -// decaf_448_precomputed_s *a, -// const decaf_448_point_t b -// ) { -// decaf_448_point_copy(a->p[0],b); -// } - -// void decaf_448_precomputed_scalarmul ( -// decaf_448_point_t a, -// const decaf_448_precomputed_s *b, -// const decaf_448_scalar_t scalar -// ) { -// decaf_448_point_scalarmul(a,b->p[0],scalar); -// } - -void gf_batch_invert ( +static void gf_batch_invert ( gf *__restrict__ out, - const gf *in, + /* const */ gf *in, unsigned int n ) { // if (n==0) { @@ -1026,7 +985,7 @@ decaf_448_precompute ( decaf_448_precomputed_s *table, const decaf_448_point_t base ) { - const int n = 5, t = 5, s = 18; // TODO MAGIC + const unsigned int n = 5, t = 5, s = 18; // TODO MAGIC assert(n*t*s >= DECAF_448_SCALAR_BITS); decaf_448_point_t working, start, doubles[t-1]; @@ -1101,7 +1060,7 @@ void decaf_448_precomputed_scalarmul ( const decaf_448_scalar_t scalar ) { unsigned int i,j,k; - const int n = 5, t = 5, s = 18; // TODO MAGIC + const unsigned int n = 5, t = 5, s = 18; // TODO MAGIC decaf_448_scalar_t scalar2, onehalf = {{{0}}}, two = {{{2}}}, arrr; onehalf->limb[SCALAR_WORDS-1] = 1ull<<(WBITS-1); diff --git a/src/decaf_gen_tables.c b/src/decaf_gen_tables.c index 6edff31..40032cb 100644 --- a/src/decaf_gen_tables.c +++ b/src/decaf_gen_tables.c @@ -19,8 +19,8 @@ int main(int argc, char **argv) { (void)argc; (void)argv; decaf_448_precomputed_s *pre; - posix_memalign((void**)&pre, alignof_decaf_448_precomputed_s, sizeof_decaf_448_precomputed_s); - if (!pre) return 1; + int ret = posix_memalign((void**)&pre, alignof_decaf_448_precomputed_s, sizeof_decaf_448_precomputed_s); + if (ret || !pre) return 1; decaf_448_precompute(pre, decaf_448_point_base); const decaf_word_t *output = (const decaf_word_t *)pre; diff --git a/test/test_scalarmul.c b/test/test_scalarmul.c index 961a8b9..9e5070f 100644 --- a/test/test_scalarmul.c +++ b/test/test_scalarmul.c @@ -113,7 +113,12 @@ single_scalarmul_compatibility_test ( decaf_448_point_t ed2, ed3; struct decaf_448_precomputed_s *dpre; - posix_memalign((void**)&dpre, alignof_decaf_448_precomputed_s, sizeof_decaf_448_precomputed_s); + int pmret = posix_memalign( + (void**)&dpre, + alignof_decaf_448_precomputed_s, + sizeof_decaf_448_precomputed_s + ); + if (pmret) return 1; tw_extended_a_t ed; convert_tw_extensible_to_tw_extended(ed, &text); uint8_t ser4[DECAF_448_SER_BYTES];