aboutsummaryrefslogtreecommitdiff
path: root/lib/fields.mli
blob: 546618a56a3c9e13be9e84c59b491641ca878bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(** Finite fields used by the BLS12-381 curve and pairings *)

module Fp : sig
  include Field.S

  val of_string : string -> t
  (** [of_string s] returns the field element represented by [s]. *)

  val to_string : t -> string
  (** [to_string a] returns the string representation of [a]. *)
end
(* The prime field over which the BLS12-381 curve is defined. *)

module Fp2 : sig
  include Field.S

  type coeffs = Fp.t * Fp.t
  (** Polynomial coefficients of the extension field. *)

  val of_fp : Fp.t -> t
  (** [of_fp a] returns maps a field element to the extension field. *)

  val of_string : string -> t
  (** [of_string s] returns the field element represented by [s]. *)

  val to_string : t -> string
  (** [to_string a] returns the string representation of [a]. *)

  val of_coeffs : coeffs -> t
  (** [of_coeffs c] is the field element with polynomial coefficients [c]. *)

  val to_coeffs : t -> coeffs
  (** [to_coeffs a] are the polynomial coefficients of [a]. *)
end
(* The polynomial field extension of degree 2 for BLS12-381 pairings. *)

module Fp12 : sig
  include Field.S

  type coeffs =
    Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
    * Fp.t
  (** Polynomial coefficients of the extension field. *)

  val of_fp : Fp.t -> t
  (** [of_fp a] returns maps a field element to the extension field. *)

  val of_string : string -> t
  (** [of_string s] returns the field element represented by [s]. *)

  val to_string : t -> string
  (** [to_string a] returns the string representation of [a]. *)

  val of_coeffs : coeffs -> t
  (** [of_coeffs c] is the field element with polynomial coefficients [c]. *)

  val to_coeffs : t -> coeffs
  (** [to_coeffs a] are the polynomial coefficients of [a]. *)
end
(* The polynomial field extension of degree 12 for BLS12-381 pairings. *)