feInvert static method

void feInvert(
  1. FieldElement out,
  2. FieldElement z
)

Implementation

static void feInvert(FieldElement out, FieldElement z) {
  final FieldElement t0 = FieldElement();
  final FieldElement t1 = FieldElement();
  final FieldElement t2 = FieldElement();
  final FieldElement t3 = FieldElement();
  int i;

  feSq(t0, z);
  feSq(t1, t0);
  feSq(t1, t1);
  feMul(t1, z, t1);
  feMul(t0, t0, t1);
  feSq(t2, t0);
  feMul(t1, t1, t2);
  feSq(t2, t1);
  for (i = 0; i < 4; ++i) {
    feSq(t2, t2);
  }
  feMul(t1, t2, t1);
  feSq(t2, t1);
  for (i = 0; i < 9; ++i) {
    feSq(t2, t2);
  }
  feMul(t2, t2, t1);
  feSq(t3, t2);
  for (i = 0; i < 19; ++i) {
    feSq(t3, t3);
  }
  feMul(t2, t3, t2);
  feSq(t2, t2);
  for (i = 0; i < 9; ++i) {
    feSq(t2, t2);
  }
  feMul(t1, t2, t1);
  feSq(t2, t1);
  for (i = 0; i < 49; ++i) {
    feSq(t2, t2);
  }
  feMul(t2, t2, t1);
  feSq(t3, t2);
  for (i = 0; i < 99; ++i) {
    feSq(t3, t3);
  }
  feMul(t2, t3, t2);
  feSq(t2, t2);
  for (i = 0; i < 49; ++i) {
    feSq(t2, t2);
  }
  feMul(t1, t2, t1);
  feSq(t1, t1);
  for (i = 0; i < 4; ++i) {
    feSq(t1, t1);
  }
  feMul(out, t1, t0);

  return;
}