Half the order of the field, used for certain comparisons.
The scalar value -1 in the field, represented positively.
The order of the finite field (i.e., the modulus).
Represents the scalar value 1 in the field.
Represents the scalar value 0 in the field.
Checks if two bigint values are equal within the context of the field. It ensures the result is within the field if and only if the input values are within the field.
The first value to compare.
The second value to compare.
True if 'a' equals 'b', false otherwise.
Compares two bigint values to determine if the first is greater than or equal to the second, considering the field's modular context. It ensures the result is within the field if and only if the input values are within the field.
The first value to compare.
The second value to compare.
True if 'a' is greater than or equal to 'b', false otherwise.
Computes the multiplicative inverse of a given value within the field. This method uses the Extended Euclidean Algorithm to find the inverse, ensuring the result is always a positive value less than the field's order. If the input value is zero, which has no inverse, an error is thrown.
The value for which to compute the inverse.
The multiplicative inverse of 'a' modulo the field's order.
if 'a' is zero.
Compares two bigint values to determine if the first is less than the second, taking into account the field's order for modular comparison. It ensures the result is within the field if and only if the input values are within the field.
The first value to compare.
The second value to compare.
True if 'a' is less than 'b', false otherwise.
Computes the negation of a bigint value within the field. The result is the modular additive inverse that, when added to the original value, yields zero in the field's modulus. It ensures the result is within the field if and only if the input values are within the field.
The value to negate.
The negation of 'a' modulo the field's order.
Raises a base to an exponent within the field, efficiently computing
scalar exponentiation using the square-and-multiply algorithm.
Supports both positive and negative exponents through the use of the inv
method for negatives.
The base to be exponentiated.
The exponent.
The result of raising 'base' to the power 'e' modulo the field's order.
Squares a bigint value within the field. This is a specific case of multiplication where the value is multiplied by itself, optimized for performance where applicable. It ensures the result is within the field if and only if the input values are within the field.
The value to square.
The square of 'a' modulo the field's order.
Subtracts one bigint from another under modulus. It ensures the result is within the field if and only if the input values are within the field.
The value from which to subtract.
The value to be subtracted.
The difference of 'a' and 'b' modulo the field's order.
F1Field Represents a finite field of order 'order' providing arithmetic operations under modulus. This class includes operations such as addition, subtraction, multiplication, division, and inversion, all performed modulo the field's order. It's designed to work with bigints, supporting large numbers for cryptographic purposes and other applications requiring modular arithmetic. Note that the outputs of the functions will always be within the field if and only if the input values are within the field. Devs need to make sure of that.