Tezex.Crypto.BLS.Fq2 (tezex v3.2.0)
View SourceQuadratic 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
@type t() :: {Tezex.Crypto.BLS.Fq.t(), Tezex.Crypto.BLS.Fq.t()}
Functions
Adds two Fq2 elements.
Computes the conjugate of an Fq2 element. conj(a + bu) = a - bu
Checks if two Fq2 elements are equal.
@spec from_integers(non_neg_integer(), non_neg_integer()) :: t()
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.
@spec modulus() :: non_neg_integer()
Returns the field modulus.
Multiplies two Fq2 elements. (a1 + b1u) (a2 + b2u) = (a1a2 - b1b2) + (a1b2 + b1a2)u
@spec mul_scalar(t(), non_neg_integer()) :: t()
Multiplies an Fq2 element by a scalar.
Negates an Fq2 element.
@spec new(Tezex.Crypto.BLS.Fq.t(), Tezex.Crypto.BLS.Fq.t()) :: t()
Creates an Fq2 element from two Fq elements (a + b*u).
@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
@spec one() :: t()
One element of Fq2.
@spec pow(t(), non_neg_integer()) :: t()
Raises an Fq2 element to a power.
@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.
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).
@spec to_integers(t()) :: {non_neg_integer(), non_neg_integer()}
Extracts the coefficients of an Fq2 element as a tuple of integers.
@spec zero() :: t()
Zero element of Fq2.