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

View Source

Quadratic extension field Fq2 for BLS12-381.

Fq2 = Fq[u] / (u^2 + 1) where Fq is the base field. Elements are represented as a + b*u where a, b ∈ Fq.

Summary

Functions

Adds two Fq2 elements.

Computes the conjugate of an Fq2 element. conj(a + bu) = a - bu

Checks if two Fq2 elements are equal.

Creates an Fq2 element from integers.

Computes the modular inverse of an Fq2 element. inv(a + bu) = conj(a + bu) / norm(a + b*u)

Checks if an Fq2 element is one.

Checks if an Fq2 element is zero.

Returns the field modulus.

Multiplies two Fq2 elements. (a1 + b1u) (a2 + b2u) = (a1a2 - b1b2) + (a1b2 + b1a2)u

Multiplies an Fq2 element by a scalar.

Negates an Fq2 element.

Creates an Fq2 element from two Fq elements (a + b*u).

Computes the norm of an Fq2 element. norm(a + bu) = (a + bu) (a - bu) = a^2 + b^2

One element of Fq2.

Raises an Fq2 element to a power.

Sign function sgn0(x) = 1 when x is 'negative'; otherwise, sgn0(x) = 0. For Fq2, this is optimized for m = 2 as defined in the hash-to-curve spec.

Computes the square root of an Fq2 element using modular square root algorithm.

Squares an Fq2 element. (a + bu)^2 = a^2 + 2abu + b^2u^2 = (a^2 - b^2) + (2ab)u

Subtracts two Fq2 elements (x - y).

Extracts the coefficients of an Fq2 element as a tuple of integers.

Zero element of Fq2.

Types

Functions

add(arg1, arg2)

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

Adds two Fq2 elements.

conjugate(arg)

@spec conjugate(t()) :: t()

Computes the conjugate of an Fq2 element. conj(a + bu) = a - bu

eq?(arg1, arg2)

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

Checks if two Fq2 elements are equal.

from_integers(a_int, b_int)

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

Creates an Fq2 element from integers.

inv(element)

@spec inv(t()) :: {:ok, t()} | {:error, :not_invertible}

Computes the modular inverse of an Fq2 element. inv(a + bu) = conj(a + bu) / norm(a + b*u)

is_one?(arg)

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

Checks if an Fq2 element is one.

is_zero?(arg)

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

Checks if an Fq2 element is zero.

modulus()

@spec modulus() :: non_neg_integer()

Returns the field modulus.

mul(arg1, arg2)

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

Multiplies two Fq2 elements. (a1 + b1u) (a2 + b2u) = (a1a2 - b1b2) + (a1b2 + b1a2)u

mul_scalar(arg, scalar)

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

Multiplies an Fq2 element by a scalar.

neg(arg)

@spec neg(t()) :: t()

Negates an Fq2 element.

new(a, b)

Creates an Fq2 element from two Fq elements (a + b*u).

norm(arg)

@spec norm(t()) :: Tezex.Crypto.BLS.Fq.t()

Computes the norm of an Fq2 element. norm(a + bu) = (a + bu) (a - bu) = a^2 + b^2

one()

@spec one() :: t()

One element of Fq2.

pow(base, exp)

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

Raises an Fq2 element to a power.

sgn0(arg)

@spec sgn0(t()) :: 0 | 1

Sign function sgn0(x) = 1 when x is 'negative'; otherwise, sgn0(x) = 0. For Fq2, this is optimized for m = 2 as defined in the hash-to-curve spec.

sqrt(element)

@spec sqrt(t()) :: {:ok, t()} | {:error, :no_sqrt}

Computes the square root of an Fq2 element using modular square root algorithm.

square(arg)

@spec square(t()) :: t()

Squares an Fq2 element. (a + bu)^2 = a^2 + 2abu + b^2u^2 = (a^2 - b^2) + (2ab)u

sub(arg1, arg2)

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

Subtracts two Fq2 elements (x - y).

to_integers(arg)

@spec to_integers(t()) :: {non_neg_integer(), non_neg_integer()}

Extracts the coefficients of an Fq2 element as a tuple of integers.

zero()

@spec zero() :: t()

Zero element of Fq2.