helios_datatypes.atd 2.21 KB
Newer Older
Stephane Glondu's avatar
Stephane Glondu committed
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 69 70 71 72 73 74 75 76 77 78 79
(** {1 Core types} *)

type number <ocaml predef from="Core_datatypes"> = abstract
type uuid <ocaml predef from="Core_datatypes"> = abstract
type datetime <ocaml predef from="Core_datatypes"> = abstract

(** {1 ElGamal keys} *)

type public_key = {
  g : number;
  p : number;
  q : number;
  y : number;
}

type private_key = {
  public_key : public_key;
  x : number;
}

(** {1 Elections} *)

type tally_type = [
  | Homomorphic <json name="homomorphic">
]

type choice_type = [
  | Approval <json name="approval">
]

type result_type = [
  | Absolute <json name="absolute">
  | Relative <json name="relative">
]

type question = {
  answer_urls : unit list;
  answers : string list;
  choice_type : choice_type;
  max : int;
  min : int;
  question : string;
  result_type : result_type;
  short_name : string;
  tally_type : tally_type;
} <ocaml field_prefix="q_">

type election = {
  cast_url : string;
  description : string;
  frozen_at : datetime;
  name : string;
  openreg : bool;
  public_key : public_key;
  questions : question list;
  uuid : uuid;
  short_name : string;
  use_voter_aliases : bool;
  voters_hash : unit;
  voting_ends_at : unit;
  voting_starts_at : unit;
} <ocaml field_prefix="e_">

(** {1 Ballots} *)

type choice = {
  alpha : number;
  beta : number;
}

type commitment = {
  a <json name="A"> : number;
  b <json name="B"> : number;
}

type proof_item = {
  challenge : number;
  commitment : commitment;
  response : number;
80
} <ocaml field_prefix="dp_">
Stephane Glondu's avatar
Stephane Glondu committed
81

Stephane Glondu's avatar
Stephane Glondu committed
82
type proof = proof_item list <ocaml repr="array">
Stephane Glondu's avatar
Stephane Glondu committed
83 84

type answer = {
Stephane Glondu's avatar
Stephane Glondu committed
85 86
  choices : choice list <ocaml repr="array">;
  individual_proofs : proof list <ocaml repr="array">;
Stephane Glondu's avatar
Stephane Glondu committed
87 88 89 90
  overall_proof : proof;
}

type vote = {
Stephane Glondu's avatar
Stephane Glondu committed
91
  answers : answer list <ocaml repr="array">;
Stephane Glondu's avatar
Stephane Glondu committed
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
  election_hash : string;
  election_uuid : uuid;
}

(** {1 Tally} *)

type tally = choice list list

type encrypted_tally = {
  num_tallied : int;
  tally : tally;
}

(** {1 Partial decryptions} *)

107 108 109 110 111 112 113 114 115 116 117
type pok = {
  challenge : number;
  commitment : number;
  response : number;
} <ocaml field_prefix="pok_">

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

Stephane Glondu's avatar
Stephane Glondu committed
118 119 120 121
type partial_decryption = {
  decryption_factors : number list list;
  decryption_proofs : proof list;
}