invert method

  1. @override
JubJubFq? invert()
override

Implementation

@override
JubJubFq? invert() {
  if (isZero()) return null;
  JubJubFq squareAssignMulti(JubJubFq n, int numTimes) {
    for (int i = 0; i < numTimes; i++) {
      n = n.square();
    }
    return n;
  }

  JubJubFq t0 = square();
  JubJubFq t1 = t0 * this;
  JubJubFq t16 = t0.square();
  JubJubFq t6 = t16.square();
  JubJubFq t5 = t6 * t0;
  t0 = t6 * t16;
  JubJubFq t12 = t5 * t16;
  JubJubFq t2 = t6.square();
  JubJubFq t7 = t5 * t6;
  JubJubFq t15 = t0 * t5;
  JubJubFq t17 = t12.square();
  t1 *= t17;
  JubJubFq t3 = t7 * t2;
  JubJubFq t8 = t1 * t17;
  JubJubFq t4 = t8 * t2;
  JubJubFq t9 = t8 * t7;
  t7 = t4 * t5;
  JubJubFq t11 = t4 * t17;
  t5 = t9 * t17;
  JubJubFq t14 = t7 * t15;
  JubJubFq t13 = t11 * t12;
  t12 = t11 * t17;
  t15 = t15 * t12;
  t16 = t16 * t15;
  t3 = t3 * t16;
  t17 = t17 * t3;
  t0 = t0 * t17;
  t6 = t6 * t0;
  t2 = t2 * t6;

  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t17;
  t0 = squareAssignMulti(t0, 9);
  t0 = t0 * t16;
  t0 = squareAssignMulti(t0, 9);
  t0 = t0 * t15;
  t0 = squareAssignMulti(t0, 9);
  t0 = t0 * t15;
  t0 = squareAssignMulti(t0, 7);
  t0 = t0 * t14;
  t0 = squareAssignMulti(t0, 7);
  t0 = t0 * t13;
  t0 = squareAssignMulti(t0, 10);
  t0 = t0 * t12;
  t0 = squareAssignMulti(t0, 9);
  t0 = t0 * t11;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t8;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * this;
  t0 = squareAssignMulti(t0, 14);
  t0 = t0 * t9;
  t0 = squareAssignMulti(t0, 10);
  t0 = t0 * t8;
  t0 = squareAssignMulti(t0, 15);
  t0 = t0 * t7;
  t0 = squareAssignMulti(t0, 10);
  t0 = t0 * t6;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t5;
  t0 = squareAssignMulti(t0, 16);
  t0 = t0 * t3;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 7);
  t0 = t0 * t4;
  t0 = squareAssignMulti(t0, 9);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t3;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t3;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 8);
  t0 = t0 * t2;
  t0 = squareAssignMulti(t0, 5);
  t0 = t0 * t1;
  t0 = squareAssignMulti(t0, 5);
  t0 = t0 * t1;

  return t0;
}