Beispiel #1
0
// Compute inverse of an fpe, store result in rop:
void fpe_invert(fpe_t rop, const fpe_t op1)
{
  fpe_set(rop,op1);
  int i;
  for(i = 254; i >= 0; i--)
  {
    fpe_mul(rop,rop,rop);
    if(scalar_getbit(bn_pminus2, i))
      fpe_mul(rop,rop,op1);
  }
}
Beispiel #2
0
Datei: fp2e.c Projekt: agl/dclxvi
// Inverse multiple of an fp2e, store result in rop:
void fp2e_invert(fp2e_t rop, const fp2e_t op)
{
#ifdef N_OPS
  invfp2ctr += 1;
#endif
  /* New version */
  fp2e_t d1, d2;
  int i;
  fp2e_parallel_coeffmul(d1, op, op);
  for (i = 0; i < 24; i += 2)
    d1->v[i] = d1->v[i + 1] = d1->v[i] + d1->v[i + 1];
  fp2e_short_coeffred(d1);
  for (i = 0; i < 24; i += 2) {
    d2->v[i] = op->v[i];
    d2->v[i + 1] = -op->v[i + 1];
  }
  fp2e_set(rop, d1);
  for (i = 254; i >= 0; i--) {
    fp2e_parallel_coeffmul(rop, rop, rop);
    if (scalar_getbit(bn_pminus2, i))
      fp2e_parallel_coeffmul(rop, rop, d1);
  }
  fp2e_parallel_coeffmul(rop, rop, d2);
}