# `Tezex.Crypto.BLS.Fq12`
[🔗](https://github.com/objkt-com/tezex/blob/v4.0.0/lib/crypto/bls/fq12.ex#L1)

The 12th-degree extension field Fq12 for BLS12-381.
This is the target field for pairings: GT = Fq12.

The field is constructed as Fq12 = Fq[x]/(x^12 + 2 - 2*x^6).

# `t`

```elixir
@type t() :: Tezex.Crypto.BLS.FqP.t()
```

# `add`

```elixir
@spec add(t(), t()) :: t()
```

Adds two Fq12 elements.

# `eq?`

```elixir
@spec eq?(t(), t()) :: boolean()
```

Checks if two Fq12 elements are equal.

# `field_div`

```elixir
@spec field_div(t(), t()) :: t()
```

Divides two Fq12 elements (a / b = a * b^(-1)).

# `frobenius`

```elixir
@spec frobenius(t()) :: t()
```

Computes the Frobenius endomorphism φ: Fq12 → Fq12 where φ(x) = x^p.
This raises each coefficient to the power p and applies the precomputed basis transformation.

# `from_integers`

```elixir
@spec from_integers([integer()]) :: t()
```

Creates an Fq12 element from integers.

# `inv`

```elixir
@spec inv(t()) :: t()
```

Computes the modular inverse of an Fq12 element.
Uses the FqP inverse implementation.

# `is_one?`

```elixir
@spec is_one?(t()) :: boolean()
```

Checks if an Fq12 element is one.

# `is_zero?`

```elixir
@spec is_zero?(t()) :: boolean()
```

Checks if an Fq12 element is zero.

# `mul`

```elixir
@spec mul(t(), t()) :: t()
```

Multiplies two Fq12 elements.

# `new`

```elixir
@spec new([Tezex.Crypto.BLS.Fq.t()]) :: t()
```

Creates an Fq12 element from a list of 12 Fq coefficients.

# `new`

```elixir
@spec new([Tezex.Crypto.BLS.Fq.t()], [integer()]) :: t()
```

Creates an Fq12 element from a list of coefficients and modulus coefficients.
This is used for testing compatibility.

# `one`

```elixir
@spec one() :: t()
```

Returns the one element in Fq12.

# `one`

```elixir
@spec one([integer()]) :: t()
```

Returns the one element with custom modulus (for testing).

# `optimized_final_exponentiation`

```elixir
@spec optimized_final_exponentiation(t()) :: t()
```

Optimized final exponentiation for BLS12-381.

Instead of computing f^((p^12-1)/r) directly (~4314 bits), this computes:
1. f^(p^2 + 1) using 2 Frobenius operations + 1 multiplication
2. (f^(p^2 + 1))^(p^6 - 1) using 6 Frobenius operations + 1 inversion
3. result^((p^4-p^2+1)/r) using optimized exponentiation (~1268 bits)

This gives the same result as the naive approach but is much faster.
Total: 8 Frobenius + 1 mul + 1 inv + 1 pow(1268 bits) vs 1 pow(4314 bits)

# `pow`

```elixir
@spec pow(t(), integer()) :: t()
```

Raises an Fq12 element to a power.

# `scalar_mul`

```elixir
@spec scalar_mul(t(), Tezex.Crypto.BLS.Fq.t()) :: t()
```

Multiplies an Fq12 element by a scalar Fq element.

# `sub`

```elixir
@spec sub(t(), t()) :: t()
```

Subtracts two Fq12 elements.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
