Tezex.Crypto.BLS.G2 (tezex v3.2.0)

View Source

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)

Summary

Functions

Adds two G2 points.

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

Doubles a G2 point.

Checks if two G2 points are equal.

Creates a G2 point from affine coordinates.

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

Returns the generator point for G2.

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

Alias for is_zero?/1 for compatibility.

Checks if a point is on the curve.

Checks if a point is the point at infinity.

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

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

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

Negates a G2 point.

Creates a G2 point from Jacobian coordinates.

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

Converts a G2 point to affine coordinates.

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

Returns the point at infinity (identity element).

Types

Functions

add(p1, p2)

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

Adds two G2 points.

clear_cofactor(point)

@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(point)

@spec double(t()) :: t()

Doubles a G2 point.

eq?(p1, p2)

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

Checks if two G2 points are equal.

from_affine(x, y)

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

Creates a G2 point from affine coordinates.

from_compressed_bytes(bytes)

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

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

generator()

@spec generator() :: t()

Returns the generator point for G2.

hash_to_curve(message, ciphersuite)

@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?(point)

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

Alias for is_zero?/1 for compatibility.

is_on_curve?(point)

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

Checks if a point is on the curve.

is_zero?(map)

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

Checks if a point is the point at infinity.

iso_map_g2(x, y, z)

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

mul(point, scalar)

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

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

mul_integer(point, scalar_int)

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

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

negate(point)

@spec negate(t()) :: t()

Negates a G2 point.

new(x, y, z)

Creates a G2 point from Jacobian coordinates.

sswu_map(t)

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

to_affine(point)

@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(point)

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

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

zero()

@spec zero() :: t()

Returns the point at infinity (identity element).