invert method

Bls12Fp6? invert()

Inversion

Implementation

Bls12Fp6? invert() {
  Bls12Fp2 c0 = (this.c1 * this.c2).mulByNonresidue();
  c0 = this.c0.square() - c0;

  Bls12Fp2 c1 = this.c2.square().mulByNonresidue();
  c1 = c1 - (this.c0 * this.c1);

  Bls12Fp2 c2 = this.c1.square();
  c2 = c2 - (this.c0 * this.c2);

  Bls12Fp2 tmp = ((this.c1 * c2) + (this.c2 * c1)).mulByNonresidue();
  tmp = tmp + (this.c0 * c0);

  final t = tmp.invert();
  if (t == null) return null;
  return Bls12Fp6(c0: t * c0, c1: t * c1, c2: t * c2);
}