Library
Module
Module type
Parameter
Class
Class type
General module signature for a finite field
val order : Z.t
The order of the finite field
val zero : t
The neutral element for the addition
val one : t
The neutral element for the multiplication
val is_zero : t -> bool
is_zero x
returns true
if x
is the neutral element for the addition
val is_one : t -> bool
is_one x
returns true
if x
is the neutral element for the multiplication
val random : unit -> t
random ()
returns a random element of the field
val non_null_random : unit -> t
non_null_random ()
returns a non null random element of the field
negate x
returns -x mod order
. Equivalently, negate x
returns the unique y
such that x + y mod order = 0
val of_string : string -> t
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
val to_string : t -> string
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