serializable.atd 4.32 KB
Newer Older
Stephane Glondu's avatar
Stephane Glondu committed
1 2 3
(**************************************************************************)
(*                                BELENIOS                                *)
(*                                                                        *)
Stephane Glondu's avatar
Stephane Glondu committed
4
(*  Copyright © 2012-2016 Inria                                           *)
Stephane Glondu's avatar
Stephane Glondu committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(*                                                                        *)
(*  This program is free software: you can redistribute it and/or modify  *)
(*  it under the terms of the GNU Affero General Public License as        *)
(*  published by the Free Software Foundation, either version 3 of the    *)
(*  License, or (at your option) any later version, with the additional   *)
(*  exemption that compiling, linking, and/or using OpenSSL is allowed.   *)
(*                                                                        *)
(*  This program is distributed in the hope that it will be useful, but   *)
(*  WITHOUT ANY WARRANTY; without even the implied warranty of            *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *)
(*  Affero General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Affero General Public      *)
(*  License along with this program.  If not, see                         *)
(*  <http://www.gnu.org/licenses/>.                                       *)
(**************************************************************************)

Stephane Glondu's avatar
Stephane Glondu committed
22 23 24 25
<doc text="Serializable datatypes">

(** {2 Predefined types} *)

26 27
type number <ocaml predef from="Serializable_builtin"> = abstract
type uuid <ocaml predef from="Serializable_builtin"> = abstract
Stephane Glondu's avatar
Stephane Glondu committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45

(** {2 Basic cryptographic datastructures} *)

type 'a ciphertext = {
  alpha : 'a;
  beta : 'a;
}
<doc text="An ElGamal ciphertext.">

type proof = {
  challenge : number;
  response : number;
}
<doc text="A Fiat-Shamir non-interactive zero-knowledge proof of knowledge (ZKP).">

type disjunctive_proof = proof list <ocaml repr="array">
<doc text="A disjunctive ZKP. The size of the array is the number of disjuncts. ">

46 47 48 49 50 51 52
(** {2 Trustees} *)

type 'a trustee_public_key = {
  pok : proof;
  public_key : 'a;
} <ocaml field_prefix="trustee_">

Stephane Glondu's avatar
Stephane Glondu committed
53 54
(** {2 Elections} *)

55
type ff_params = {
56 57 58
  g : number;
  p : number;
  q : number;
59
}
60 61
<doc text="Parameters for a multiplicative subgroup of a finite field.">

62 63 64 65 66
type ('a, 'b) wrapped_pubkey = {
  group : 'a;
  y : 'b;
} <ocaml field_prefix="wpk_">
<doc text="A public key wrapped with its group parameters.">
67

Stephane Glondu's avatar
Stephane Glondu committed
68 69
type question = {
  answers : string list <ocaml repr="array">;
70
  ?blank : bool option;
Stephane Glondu's avatar
Stephane Glondu committed
71 72 73 74 75
  min : int;
  max : int;
  question : string;
} <ocaml field_prefix="q_">

76
type 'a params = {
Stephane Glondu's avatar
Stephane Glondu committed
77 78 79 80 81 82 83 84
  description : string;
  name : string;
  public_key : 'a;
  questions : question list <ocaml repr="array">;
  uuid : uuid;
} <ocaml field_prefix="e_">
<doc text="Election parameters relevant for creating a ballot.">

85 86 87 88 89 90 91
type template = {
  description : string;
  name : string;
  questions : question list <ocaml repr="array">;
} <ocaml field_prefix="t_">
<doc text="Election template.">

Stephane Glondu's avatar
Stephane Glondu committed
92 93 94 95
type 'a answer = {
  choices : 'a ciphertext list <ocaml repr="array">;
  individual_proofs : disjunctive_proof list <ocaml repr="array">;
  overall_proof : disjunctive_proof;
96
  ?blank_proof : disjunctive_proof option;
Stephane Glondu's avatar
Stephane Glondu committed
97 98 99 100 101
}
<doc text="An answer to a question. It consists of a weight for each
choice, a proof that each of these weights is 0 or 1, and an overall
proof that the total weight is within bounds.">

102 103
(* FIXME: merge this with trustee_public_key *)
type 'a signature = {
Stephane Glondu's avatar
Stephane Glondu committed
104
  public_key : 'a;
105 106 107 108
  challenge : number;
  response : number;
} <ocaml field_prefix="s_">

Stephane Glondu's avatar
Stephane Glondu committed
109 110 111 112
type 'a ballot = {
  answers : 'a answer list <ocaml repr="array">;
  election_hash : string;
  election_uuid : uuid;
113
  ?signature : 'a signature option;
Stephane Glondu's avatar
Stephane Glondu committed
114 115 116 117 118 119 120
}

type 'a partial_decryption = {
  decryption_factors : 'a list <ocaml repr="array"> list <ocaml repr="array">;
  decryption_proofs : proof list <ocaml repr="array"> list <ocaml repr="array">;
}

Stephane Glondu's avatar
Stephane Glondu committed
121 122
type plaintext = int list <ocaml repr="array"> list <ocaml repr="array">

123 124
type 'a encrypted_tally = 'a ciphertext list <ocaml repr="array"> list <ocaml repr="array">

Stephane Glondu's avatar
Stephane Glondu committed
125
type 'a result = {
Stephane Glondu's avatar
Stephane Glondu committed
126
  num_tallied : int;
127
  encrypted_tally : 'a encrypted_tally;
Stephane Glondu's avatar
Stephane Glondu committed
128
  partial_decryptions : 'a partial_decryption list <ocaml repr="array">;
Stephane Glondu's avatar
Stephane Glondu committed
129
  result : plaintext;
Stephane Glondu's avatar
Stephane Glondu committed
130
}