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

G2 elliptic curve group for BLS12-381.

This is the elliptic curve E'(Fq2): y² = x³ + 4(1 + u) over the quadratic extension Fq2.
G2 is used for signatures in BLS signatures.

Points are represented in Jacobian coordinates (X, Y, Z) where:
- Affine coordinates: (X/Z², Y/Z³) over Fq2
- Point at infinity: (1, 1, 0)

# `t`

```elixir
@type t() :: %{
  x: Tezex.Crypto.BLS.Fq2.t(),
  y: Tezex.Crypto.BLS.Fq2.t(),
  z: Tezex.Crypto.BLS.Fq2.t()
}
```

# `add`

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

Adds two G2 points.

# `clear_cofactor`

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

Clear the cofactor of a G2 point to map it to the prime-order subgroup.
Uses the efficient cofactor H_EFF_G2.

# `double`

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

Doubles a G2 point.

# `eq?`

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

Checks if two G2 points are equal.

# `from_affine`

```elixir
@spec from_affine(Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t()) :: t()
```

Creates a G2 point from affine coordinates.

# `from_compressed_bytes`

```elixir
@spec from_compressed_bytes(binary()) :: {:ok, t()} | {:error, :invalid_point}
```

Deserializes a G2 point from compressed format (96 bytes).

# `generator`

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

Returns the generator point for G2.

# `hash_to_curve`

```elixir
@spec hash_to_curve(binary(), binary()) :: t()
```

Hash-to-curve for G2 - maps a message to a point on G2.
Implements hash-to-curve following IRTF standards.

# `is_infinity?`

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

Alias for is_zero?/1 for compatibility.

# `is_on_curve?`

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

Checks if a point is on the curve.

# `is_zero?`

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

Checks if a point is the point at infinity.

# `iso_map_g2`

```elixir
@spec iso_map_g2(
  Tezex.Crypto.BLS.Fq2.t(),
  Tezex.Crypto.BLS.Fq2.t(),
  Tezex.Crypto.BLS.Fq2.t()
) ::
  {Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t()}
```

Isogeny mapping from 3-isogenous curve to G2.
3-isogeny mapping from E'(Fq2) to E(Fq2).

# `mul`

```elixir
@spec mul(t(), Tezex.Crypto.BLS.Fr.t()) :: t()
```

Multiplies a G2 point by a scalar using double-and-add algorithm.

# `mul_integer`

```elixir
@spec mul_integer(t(), non_neg_integer()) :: t()
```

Multiplies a G2 point by a large integer (for cofactor clearing).

# `negate`

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

Negates a G2 point.

# `new`

```elixir
@spec new(
  Tezex.Crypto.BLS.Fq2.t(),
  Tezex.Crypto.BLS.Fq2.t(),
  Tezex.Crypto.BLS.Fq2.t()
) :: t()
```

Creates a G2 point from Jacobian coordinates.

# `sswu_map`

```elixir
@spec sswu_map(Tezex.Crypto.BLS.Fq2.t()) ::
  {Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t()}
```

Optimized SSWU Map for G2.
Maps an FQ2 element to a point on the 3-isogenous curve.

# `to_affine`

```elixir
@spec to_affine(t()) ::
  {:ok, {Tezex.Crypto.BLS.Fq2.t(), Tezex.Crypto.BLS.Fq2.t()}}
  | {:error, :point_at_infinity}
```

Converts a G2 point to affine coordinates.

# `to_compressed_bytes`

```elixir
@spec to_compressed_bytes(t()) :: binary()
```

Serializes a G2 point to compressed format (96 bytes).

# `zero`

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

Returns the point at infinity (identity element).

---

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