ref/include/f11_260.c
// Reduce to unique representative.
// This is expensive. Only used for final signature or DH Key
Reduce to unique representative.
This is expensive. Only used for final signature or DH Key
Reduce to unique representative . This is expensive . Only used for final signature or DH Key
void narrow_complete(
  residue_narrow_reduced_t *result, const residue_narrow_t * __restrict w) {
  residue_narrow_t temp;
  for (int i = 0; i < NLIMBS; ++i) {
    temp.limbs[i] = w->limbs[i] - w->limbs[10];
  }
  reduce_step_narrow(&temp, &temp);
  int gt_mask = 0;
  int lt_mask = 0;
  int32_t limit[NLIMBS];
  for (int i = 0; i < NLIMBS; ++i) {
    temp.limbs[i] = temp.limbs[i] - temp.limbs[10];
    temp.limbs[i] += 1 & gt_mask;
    temp.limbs[i] -= 1 & lt_mask;
    gt_mask = -(temp.limbs[i] > T);
    lt_mask = -(temp.limbs[i] < 0);
    temp.limbs[i] -= (T & gt_mask);
    temp.limbs[i] += (T & lt_mask);
  }
  for (int i = 0; i < NLIMBS_REDUCED; ++i) {
    temp.limbs[i] -= temp.limbs[10];
    limit[i] = T;
  }
  int64_t all_t = -1;
  for (int i = NLIMBS_REDUCED - 2; i >= 0; --i) {
    all_t &= -(temp.limbs[i+1] == T);
    limit[i] -= 1 & (~all_t);
  }
  gt_mask = 0;
  lt_mask = 0;
  for (int i = 0; i < NLIMBS_REDUCED; ++i) {
    temp.limbs[i] += 1 & gt_mask;
    temp.limbs[i] -= 1 & lt_mask;
    gt_mask = -(temp.limbs[i] > limit[i]);
    lt_mask = -(temp.limbs[i] < 0);
    temp.limbs[i] -= (T & gt_mask);
    temp.limbs[i] += (T & lt_mask);
    result->limbs[i] = temp.limbs[i];
  }
}
void narrow_complete ( residue_narrow_reduced_t * result , const residue_narrow_t * __restrict w ) { residue_narrow_t temp ; for ( int i = 0 ; i < NLIMBS ; ++ i ) { temp . limbs [ i ] = w -> limbs [ i ] - w -> limbs [ 10 ] ; } reduce_step_narrow ( & temp , & temp ) ; int gt_mask = 0 ; int lt_mask = 0 ; int32_t limit [ NLIMBS ] ; for ( int i = 0 ; i < NLIMBS ; ++ i ) { temp . limbs [ i ] = temp . limbs [ i ] - temp . limbs [ 10 ] ; temp . limbs [ i ] += 1 & gt_mask ; temp . limbs [ i ] -= 1 & lt_mask ; gt_mask = - ( temp . limbs [ i ] > T ) ; lt_mask = - ( temp . limbs [ i ] < 0 ) ; temp . limbs [ i ] -= ( T & gt_mask ) ; temp . limbs [ i ] += ( T & lt_mask ) ; } for ( int i = 0 ; i < NLIMBS_REDUCED ; ++ i ) { temp . limbs [ i ] -= temp . limbs [ 10 ] ; limit [ i ] = T ; } int64_t all_t = -1 ; for ( int i = NLIMBS_REDUCED - 2 ; i >= 0 ; -- i ) { all_t &= - ( temp . limbs [ i + 1 ] == T ) ; limit [ i ] -= 1 & ( ~ all_t ) ; } gt_mask = 0 ; lt_mask = 0 ; for ( int i = 0 ; i < NLIMBS_REDUCED ; ++ i ) { temp . limbs [ i ] += 1 & gt_mask ; temp . limbs [ i ] -= 1 & lt_mask ; gt_mask = - ( temp . limbs [ i ] > limit [ i ] ) ; lt_mask = - ( temp . limbs [ i ] < 0 ) ; temp . limbs [ i ] -= ( T & gt_mask ) ; temp . limbs [ i ] += ( T & lt_mask ) ; result -> limbs [ i ] = temp . limbs [ i ] ; } }
Reduce to unique representative.
Reduce to unique representative .
// This may be combined with the final reduction from a multiply.