aboutsummaryrefslogtreecommitdiff
path: root/lib/curve.ml
blob: 896cce1dd59068a5e3a6b7cebd10dae7b1e09b03 (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
(** Elliptic Curve. *)

(** Module signature for an elliptic curve. *)
module type S = sig
  type t
  (** A type representing an element in an elliptic curve. *)

  val inf : t
  (** The point at infinity or additive identity. *)

  val g : t
  (** The generator point. *)

  val n : Z.t
  (** The order of the curve. *)

  val equal : t -> t -> bool
  (** [equal a b] returns [true] if [a] is equal to [b]. *)

  val neg : t -> t
  (** [neg a] is the additive inverse of [a]. [add a (neg a) = zero] for all
      [a]. *)

  val add : t -> t -> t
  (** [add a b] is the sum of [a] plus [b] *)

  val sub : t -> t -> t
  (** [sub a b] is the difference of [a] minus [b]. It is equivalent to
      [add a (neg b)]. *)

  val scalar_mul : Z.t -> t -> t
  (** [scalar_mul k a] is the scalar multiplication of [a] by [k]. *)

  val ( ~- ) : t -> t
  (** [neg]. *)

  val ( + ) : t -> t -> t
  (** [add]. *)

  val ( - ) : t -> t -> t
  (** [sub]. *)

  val ( $* ) : Z.t -> t -> t
  (** [scalar_mul]. *)
end