-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShamir.mli
More file actions
69 lines (48 loc) · 2.25 KB
/
Shamir.mli
File metadata and controls
69 lines (48 loc) · 2.25 KB
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
(** MPC using Shamir sharing *)
(* Copyright Xavier Leroy.
License: LGPL 2.1 or later with OCaml LGPL Linking Exception *)
(** The computation is performed jointly by participants 1 to N.
Participant 0 can share data with the other participants,
but does not participate in the computation. *)
type value = int
(** Shared values are integers modulo [p]. *)
val p: int
(** The prime modulus [p = 2{^31} - 1]. *)
type share
(** A value is shared as the values of a random polynomial
whose constant coefficient is the value. *)
val send : value -> unit
(** To be executed by participant 0.
Send shares of the given integer to participants 1 to N. *)
val receive : unit -> share
(** To be executed by participants 1 to N.
Receive a share of the integer sent by participant 0. *)
val share : value -> share array
(** Each participant [i] shares its secret [xi] with all the
participants. The result is an array of shares for [x1...xN]. *)
val reveal : share -> value
(** Participants 1 to N put their shares in common.
They all learn the integer value of this sharing. *)
val of_int : value -> share
(** A trivial share for the given constant. *)
val add : share -> share -> share
(** Addition of two shared integers (modulo [p]). Local computation. *)
val neg : share -> share
(** Opposite of a shared integer (modulo [p]). Local computation. *)
val scale : int -> share -> share
(** Multiplication of a constant by a shared integer (modulo [p]).
Local computation. *)
val mul : share -> share -> share
(** Multiplication of two shared integers (modulo [p]).
Distributed computation. *)
(** Boolean operations over 0/1 values *)
val not : share -> share
(** Negation of a shared Boolean. Local computation. *)
val and_ : share -> share -> share
(** AND of two shared Booleans. Non-local computation. *)
val or_ : share -> share -> share
(** OR of two shared Booleans. Non-local computation. *)
val xor : share -> share -> share
(** Exclusive OR of two shared Booleans. Non-local computation. *)
val carry_out : share -> share -> share -> share
(** Carry-out of a full adder. Non-local computation. *)