Tezex.Crypto.BLS.Fq12 (tezex v3.2.0)
View SourceThe 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).
Summary
Functions
Adds two Fq12 elements.
Checks if two Fq12 elements are equal.
Divides two Fq12 elements (a / b = a * b^(-1)).
Computes the Frobenius endomorphism φ: Fq12 → Fq12 where φ(x) = x^p. This raises each coefficient to the power p and applies the precomputed basis transformation.
Creates an Fq12 element from integers.
Computes the modular inverse of an Fq12 element. Uses the FqP inverse implementation.
Checks if an Fq12 element is one.
Checks if an Fq12 element is zero.
Multiplies two Fq12 elements.
Creates an Fq12 element from a list of 12 Fq coefficients.
Creates an Fq12 element from a list of coefficients and modulus coefficients. This is used for testing compatibility.
Returns the one element in Fq12.
Returns the one element with custom modulus (for testing).
Optimized final exponentiation for BLS12-381.
Raises an Fq12 element to a power.
Multiplies an Fq12 element by a scalar Fq element.
Subtracts two Fq12 elements.
Types
@type t() :: Tezex.Crypto.BLS.FqP.t()
Functions
Adds two Fq12 elements.
Checks if two Fq12 elements are equal.
Divides two Fq12 elements (a / b = a * b^(-1)).
Computes the Frobenius endomorphism φ: Fq12 → Fq12 where φ(x) = x^p. This raises each coefficient to the power p and applies the precomputed basis transformation.
Creates an Fq12 element from integers.
Computes the modular inverse of an Fq12 element. Uses the FqP inverse implementation.
Checks if an Fq12 element is one.
Checks if an Fq12 element is zero.
Multiplies two Fq12 elements.
@spec new([Tezex.Crypto.BLS.Fq.t()]) :: t()
Creates an Fq12 element from a list of 12 Fq coefficients.
@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.
@spec one() :: t()
Returns the one element in Fq12.
Returns the one element with custom modulus (for testing).
Optimized final exponentiation for BLS12-381.
Instead of computing f^((p^12-1)/r) directly (~4314 bits), this computes:
- f^(p^2 + 1) using 2 Frobenius operations + 1 multiplication
- (f^(p^2 + 1))^(p^6 - 1) using 6 Frobenius operations + 1 inversion
- 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)
Raises an Fq12 element to a power.
@spec scalar_mul(t(), Tezex.Crypto.BLS.Fq.t()) :: t()
Multiplies an Fq12 element by a scalar Fq element.
Subtracts two Fq12 elements.