aboutsummaryrefslogtreecommitdiff
path: root/lib/pairing.mli
blob: a76343d4f435185b96b44f591d378adc413f06d4 (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
module G1 : Curve.S with type t = Curves.E.t and type f = Fields.Fp.t
module G2 : Curve.S with type t = Curves.E2.t and type f = Fields.Fp2.t

module Gt : sig
  type t

  val id : t
  (** The group's identity element. *)

  val g : t
  (** The group's generator. *)

  val dot : t -> t -> t
  (** [dot a b] is the group operation applied to [a] and [b]. *)

  val inv : t -> t
  (** [inv a] is the inverse of [a]. Note that the invariant
      [equal id (dot a (inv a))] always holds. *)

  val equal : t -> t -> bool
  (** [equal a b] is true if [a] has the same value as [b] *)

  val to_f : t -> Fields.Fp12.t
  (** [to_fp12 a] is the underlying field value of the group element [a]. *)

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

  (** Unsafe pairing group construction functions. *)
  module Unsafe : sig
    val of_f_unchecked : Fields.Fp12.t -> t
    (** [of_fp12_unchecked a] is a pairing element of value [a]. This function
        does not check whether the value actually belongs to the pairing group
        [Gt]. *)

    val of_string_unchecked : string -> t
    (** [of_string_unchecked s] returns the pairing element represented by [s].
        This function does not check whether the value belongs to the group
        [Gt]. *)
  end
end

val e' : G1.t -> G2.t -> Fields.Fp12.t
(** [e p q] is the elliptic curve pairing of [p] and [q] without final
    exponentiation. This is useful when you only want to compare pairings,
    without actually mapping them to [Gt]. *)

val e : G1.t -> G2.t -> Gt.t
(** [e p q] is the elliptic curve pairing of [p] and [q]. *)