-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSHE.mli
More file actions
60 lines (40 loc) · 1.79 KB
/
SHE.mli
File metadata and controls
60 lines (40 loc) · 1.79 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
(** Somewhat homomorphic encryption of Booleans using big integers. *)
(* Copyright Xavier Leroy.
License: LGPL 2.1 or later with OCaml LGPL Linking Exception *)
(** Ref: van Dijk, Gentry, Halevy, Vaikuntanathan, "Fully homomorphic
encryption over the integers", Eurocrypt 2010. *)
type key = Z.t
type plaintext = bool
type ciphertext = Z.t
val keygen: unit -> key
(** Generate a private key. *)
val encrypt: key -> plaintext -> ciphertext
(** Randomized private-key encryption of a Boolean. *)
val decrypt: key -> ciphertext -> plaintext
(** Decryption of a Boolean. *)
val const: bool -> ciphertext
(** Trivial encryption of a Boolean. Appropriate if the Boolean
is a constant or is already encrypted. *)
val noise: key -> ciphertext -> int
(** Estimate the noise level (in bits) of the given ciphertext.
It must remain below [max_noise] for the ciphertext
to decrypt correctly. *)
val max_noise: int
(** Maximal noise level that still allows reliable decryption. *)
type public_key = ciphertext array
val pubkey: key -> public_key
(** Generate a public key that matches the given private key. *)
val pubencrypt: public_key -> plaintext -> ciphertext
(** Public-key encryption of a Boolean. *)
val hadd: ciphertext -> ciphertext -> ciphertext
(** Homomorphic addition (XOR). *)
val hmul: ciphertext -> ciphertext -> ciphertext
(** Homomorphic multiplication (AND). *)
val hnot: ciphertext -> ciphertext
(** Homomorphic Boolean negation. *)
val hxor: ciphertext -> ciphertext -> ciphertext
(** Homomorphic Boolean XOR (same as addition). *)
val hand: ciphertext -> ciphertext -> ciphertext
(** Homomorphic Boolean AND (same as multiplication). *)
val hor: ciphertext -> ciphertext -> ciphertext
(** Homomorphic Boolean OR. *)