mulInterleaved method

Bls12Fp6 mulInterleaved(
  1. Bls12Fp6 b
)

Interleaved multiplication (schoolbook optimized)

Implementation

Bls12Fp6 mulInterleaved(Bls12Fp6 b) {
  final a = this;

  final b10p = b.c1.c0 + b.c1.c1;
  final b10m = b.c1.c0 - b.c1.c1;
  final b20p = b.c2.c0 + b.c2.c1;
  final b20m = b.c2.c0 - b.c2.c1;

  return Bls12Fp6(
    c0: Bls12Fp2(
      c0: Bls12Fp.sumOfProducts(
        [a.c0.c0, -a.c0.c1, a.c1.c0, -a.c1.c1, a.c2.c0, -a.c2.c1],
        [b.c0.c0, b.c0.c1, b20m, b20p, b10m, b10p],
      ),
      c1: Bls12Fp.sumOfProducts(
        [a.c0.c0, a.c0.c1, a.c1.c0, a.c1.c1, a.c2.c0, a.c2.c1],
        [b.c0.c1, b.c0.c0, b20p, b20m, b10p, b10m],
      ),
    ),
    c1: Bls12Fp2(
      c0: Bls12Fp.sumOfProducts(
        [a.c0.c0, -a.c0.c1, a.c1.c0, -a.c1.c1, a.c2.c0, -a.c2.c1],
        [b.c1.c0, b.c1.c1, b.c0.c0, b.c0.c1, b20m, b20p],
      ),
      c1: Bls12Fp.sumOfProducts(
        [a.c0.c0, a.c0.c1, a.c1.c0, a.c1.c1, a.c2.c0, a.c2.c1],
        [b.c1.c1, b.c1.c0, b.c0.c1, b.c0.c0, b20p, b20m],
      ),
    ),
    c2: Bls12Fp2(
      c0: Bls12Fp.sumOfProducts(
        [a.c0.c0, -a.c0.c1, a.c1.c0, -a.c1.c1, a.c2.c0, -a.c2.c1],
        [b.c2.c0, b.c2.c1, b.c1.c0, b.c1.c1, b.c0.c0, b.c0.c1],
      ),
      c1: Bls12Fp.sumOfProducts(
        [a.c0.c0, a.c0.c1, a.c1.c0, a.c1.c1, a.c2.c0, a.c2.c1],
        [b.c2.c1, b.c2.c0, b.c1.c1, b.c1.c0, b.c0.c1, b.c0.c0],
      ),
    ),
  );
}