diff --git a/src/ec_point.c b/src/ec_point.c index ae97cf6..a08a618 100644 --- a/src/ec_point.c +++ b/src/ec_point.c @@ -827,6 +827,18 @@ elligator_2s_inject ( IF32( field_weak_reduce( &L7 ) ); field_mulw_scc ( &L6, &a->y, -2-2*EDWARDS_D ); field_mul ( &L5, &L7, &L6 ); + /* FIXME Stability problem (API stability, not crash) / possible bug. + * change to: p448_mul ( &L5, &L7, &L4 ); ? + * This isn't a deep change: it's for sign adjustment. + * Need to check which one leads to the correct sign, probably by writig + * the invert routine. + * + * Also, the tool doesn't produce the optimal route to this. + * Let incoming L6 = a, L7 = e, L4 = b. + * + * Could compute be, (be)^2, (be)^3, a b^3 e^3, a b^3 e^4. = 4M+S + * instead of 6M. + */ field_mul ( &L8, &L5, &L4 ); field_mul ( &L4, &L5, &L6 ); field_mul ( &L5, &L7, &L8 ); diff --git a/src/include/ec_point.h b/src/include/ec_point.h index f875450..59e6278 100644 --- a/src/include/ec_point.h +++ b/src/include/ec_point.h @@ -481,6 +481,30 @@ validate_extensible ( const struct extensible_t* ext ); +/** + * If doNegate, then negate a twisted niels point. + */ +static __inline__ void +__attribute__((unused)) +cond_negate_tw_niels ( + struct tw_niels_t *n, + mask_t doNegate +) { + field_cond_swap(&n->a, &n->b, doNegate); + field_cond_neg(&n->c, doNegate); +} + +/** + * If doNegate, then negate a twisted projective niels point. + */ +static __inline__ void +__attribute__((unused)) +cond_negate_tw_pniels ( + struct tw_pniels_t *n, + mask_t doNegate +) { + cond_negate_tw_niels(&n->n, doNegate); +} void copy_affine ( diff --git a/src/scalarmul.c b/src/scalarmul.c index ea9cded..e67112c 100644 --- a/src/scalarmul.c +++ b/src/scalarmul.c @@ -47,23 +47,6 @@ montgomery_ladder ( return serialize_montgomery(out, &mont, in); } -static __inline__ void -cond_negate_tw_niels ( - struct tw_niels_t *n, - mask_t doNegate -) { - field_cond_swap(&n->a, &n->b, doNegate); - field_cond_neg(&n->c, doNegate); -} - -static __inline__ void -cond_negate_tw_pniels ( - struct tw_pniels_t *n, - mask_t doNegate -) { - cond_negate_tw_niels(&n->n, doNegate); -} - static __inline__ void constant_time_lookup_tw_pniels ( struct tw_pniels_t *out,