feDivpowm1 static method

void feDivpowm1(
  1. FieldElement r,
  2. FieldElement u,
  3. FieldElement v
)

Implementation

static void feDivpowm1(FieldElement r, FieldElement u, FieldElement v) {
  final FieldElement v3 = FieldElement(),
      uv7 = FieldElement(),
      t0 = FieldElement(),
      t1 = FieldElement(),
      t2 = FieldElement();
  int i;

  feSq(v3, v);
  feMul(v3, v3, v); /* v3 = v^3 */
  feSq(uv7, v3);
  feMul(uv7, uv7, v);
  feMul(uv7, uv7, u); /* uv7 = uv^7 */

  /*fe_pow22523(uv7, uv7);*/

  /* From fe_pow22523.c */

  feSq(t0, uv7);
  feSq(t1, t0);
  feSq(t1, t1);
  feMul(t1, uv7, t1);
  feMul(t0, t0, t1);
  feSq(t0, t0);
  feMul(t0, t1, t0);
  feSq(t1, t0);
  for (i = 0; i < 4; ++i) {
    feSq(t1, t1);
  }
  feMul(t0, t1, t0);
  feSq(t1, t0);
  for (i = 0; i < 9; ++i) {
    feSq(t1, t1);
  }
  feMul(t1, t1, t0);
  feSq(t2, t1);
  for (i = 0; i < 19; ++i) {
    feSq(t2, t2);
  }
  feMul(t1, t2, t1);
  for (i = 0; i < 10; ++i) {
    feSq(t1, t1);
  }
  feMul(t0, t1, t0);
  feSq(t1, t0);
  for (i = 0; i < 49; ++i) {
    feSq(t1, t1);
  }
  feMul(t1, t1, t0);
  feSq(t2, t1);
  for (i = 0; i < 99; ++i) {
    feSq(t2, t2);
  }
  feMul(t1, t2, t1);
  for (i = 0; i < 50; ++i) {
    feSq(t1, t1);
  }
  feMul(t0, t1, t0);
  feSq(t0, t0);
  feSq(t0, t0);
  feMul(t0, t0, uv7);

  /* End fe_pow22523.c */
  /* t0 = (uv^7)^((q-5)/8) */
  feMul(t0, t0, v3);
  feMul(r, t0, u); /* u^(m+1)v^(-(m+1)) */
}