package ff
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Module type Ff.T
Source
General module signature for a finite field
minimal number of bytes required to encode a value of the field.
is_one x
returns true
if x
is the neutral element for the multiplication
random ()
returns a random element of the field. A state for the PRNG can be given to initialize the PRNG in the requested state. If no state is given, no initialisation is performed
non_null_random ()
returns a non null random element of the field. A state for the PRNG can be given to initialize the PRNG in the requested state. If no state is given, no initialisation is performed
negate x
returns -x mod order
. Equivalently, negate x
returns the unique y
such that x + y mod order = 0
inverse_opt x
returns x^-1
if x
is not 0
as an option, else None
div_opt a b
returns a * b^-1
as an option. Return None
if b = zero
Create a value t from a predefined string representation. It is not required that to_string of_string t = t. By default, decimal representation of the number is used, modulo the order of the field
String representation of a value t. It is not required that to_string of_string t = t. By default, decimal representation of the number is used
From a predefined bytes representation, construct a value t. It is not required that to_bytes of_bytes t = t. By default, little endian encoding is used and the given element is modulo the prime order
Convert the value t to a bytes representation which can be used for hashing for instance. It is not required that to_bytes of_bytes t = t. By default, little endian encoding is used, and length of the resulting bytes may vary depending on the order.
is_nth_root_of_unity n x
returns true
if x
is a nth-root of unity
of_z x
builds an element t from the Zarith element x. mod order
is applied if x > order