Commit 7a2769b3 authored by Stephane Glondu's avatar Stephane Glondu

Remove WEB_PARAMS and WEB_ELECTION_DATA signatures

parent 88eefa23
......@@ -51,13 +51,12 @@ Results will be published on the election page
-- \nBelenios"
module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION = struct
module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION = struct
let uuid = Uuidm.to_string D.election.e_params.e_uuid
module D = D
include D
module E = Election.MakeElection(G)(M)
module G = D.G
module E = Election.MakeElection (G) (M)
module B : WEB_BALLOT_BOX = struct
......@@ -127,7 +126,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
match old_cred, old_record with
| None, None ->
(* first vote *)
if E.check_ballot election ballot then (
if E.check_ballot D.election ballot then (
let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >>
Ocsipersist.add ballots_table hash rawballot >>
......@@ -140,7 +139,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
| Some h, Some (_, old_credential) ->
(* revote *)
if credential = old_credential then (
if E.check_ballot election ballot then (
if E.check_ballot D.election ballot then (
Ocsipersist.remove ballots_table h >>
let hash = sha256_b64 rawballot in
Ocsipersist.add cred_table credential (Some hash) >>
......@@ -179,7 +178,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
Ocsipersist.add cred_table new_ None
let do_write f =
Lwt_io.(with_file ~mode:Output (dir / string_of_election_file f))
Lwt_io.(with_file ~mode:Output (!spool_dir / uuid / string_of_election_file f))
let do_write_ballots () =
do_write ESBallots (fun oc ->
......@@ -233,7 +232,7 @@ module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB
let ballot = ballot_of_string G.read rawballot in
let ciphertext = E.extract_ciphertext ballot in
return (n + 1, E.combine_ciphertexts accu ciphertext))
ballots_table (0, E.neutral_ciphertext election)
ballots_table (0, E.neutral_ciphertext D.election)
in
let tally = string_of_encrypted_tally G.write tally in
Lwt_mutex.with_lock mutex (fun () ->
......
......@@ -22,4 +22,4 @@
open Signatures
open Web_signatures
module Make (D : WEB_ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION
module Make (D : ELECTION_DATA) (M : RANDOM with type 'a t = 'a Lwt.t) : WEB_ELECTION
......@@ -96,19 +96,29 @@ let get_raw_election uuid =
end
with _ -> return_none
let empty_metadata = {
e_owner = None;
e_auth_config = None;
e_cred_authority = None;
e_trustees = None;
}
let return_empty_metadata = return empty_metadata
let get_election_metadata uuid =
try_lwt
Lwt_io.chars_of_file (!spool_dir / uuid / "metadata.json") |>
Lwt_stream.to_string >>= fun x ->
return @@ Some (metadata_of_string x)
with _ -> return_none
return @@ metadata_of_string x
with _ -> return_empty_metadata
let get_elections_by_owner user =
Lwt_unix.files_of_directory !spool_dir |>
Lwt_stream.filter_s (fun x ->
if x = "." || x = ".." then return false else
match_lwt get_election_metadata x with
| Some m -> return (m.e_owner = Some user)
lwt metadata = get_election_metadata x in
match metadata.e_owner with
| Some o -> return (o = user)
| None -> return false
) |> Lwt_stream.to_list
......
......@@ -43,7 +43,7 @@ val get_auth_config : string -> (string * (string * string list)) list Lwt.t
val set_auth_config : string -> (string * (string * string list)) list -> unit Lwt.t
val get_raw_election : string -> string option Lwt.t
val get_election_metadata : string -> metadata option Lwt.t
val get_election_metadata : string -> metadata Lwt.t
val get_election_result : string -> Yojson.Safe.json result option Lwt.t
val get_elections_by_owner : user -> string list Lwt.t
......
......@@ -68,18 +68,8 @@ module type WEB_BALLOT_BOX = sig
number of ballots and the hash of the encrypted tally. *)
end
module type WEB_PARAMS = sig
val metadata : metadata
val dir : string
end
module type WEB_ELECTION_DATA = sig
include ELECTION_DATA
include WEB_PARAMS
end
module type WEB_ELECTION = sig
module D : WEB_ELECTION_DATA
module E : ELECTION with type elt = D.G.t and type 'a m = 'a Lwt.t
module G : GROUP
module E : ELECTION with type elt = G.t and type 'a m = 'a Lwt.t
module B : WEB_BALLOT_BOX
end
This diff is collapsed.
......@@ -144,7 +144,7 @@ let base ~title ~login_box ~content ?(footer = div []) ?uuid () =
]))
let format_election kind election =
let module W = (val election : WEB_ELECTION_DATA) in
let module W = (val election : ELECTION_DATA) in
let e = W.election.e_params in
let service =
match kind with
......@@ -843,7 +843,7 @@ let election_setup_trustee token se () =
let election_setup_import uuid se (elections, tallied, archived) () =
let title = "Election " ^ se.se_questions.t_name ^ " — Import voters from another election" in
let format_election election =
let module W = (val election : WEB_ELECTION_DATA) in
let module W = (val election : ELECTION_DATA) in
let name = W.election.e_params.e_name in
let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in
let form = post_form
......@@ -879,7 +879,7 @@ let election_setup_import uuid se (elections, tallied, archived) () =
base ~title ~login_box ~content ()
let election_login_box w =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let module A = struct
let get_user () =
Web_auth_state.get_election_user W.election.e_params.e_uuid
......@@ -900,13 +900,13 @@ let election_login_box w =
fun () -> make_login_box ~site:false auth links
let file w x =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
Eliom_service.preapply
election_dir
(W.election.e_params.e_uuid, x)
let audit_footer w =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
div ~a:[a_style "line-height:1.5em;"] [
div [
div [
......@@ -936,7 +936,7 @@ let audit_footer w =
]
let election_home w state () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let state_ =
match state with
......@@ -1043,8 +1043,8 @@ let election_home w state () =
let uuid = params.e_uuid in
base ~title:params.e_name ~login_box ~content ~footer ~uuid ()
let election_admin w state () =
let module W = (val w : WEB_ELECTION_DATA) in
let election_admin w metadata state () =
let module W = (val w : ELECTION_DATA) in
let title = W.election.e_params.e_name ^ " — Administration" in
let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in
let state_form checked =
......@@ -1093,7 +1093,7 @@ let election_admin w state () =
| [] -> (None, i) :: (loop (i+1) ts)
else []
in
match W.metadata.e_trustees with
match metadata.e_trustees with
| None -> loop 1 []
| Some ts -> loop 1 ts
in
......@@ -1172,7 +1172,7 @@ let election_admin w state () =
in
let uuid = W.election.e_params.e_uuid in
let update_credential =
match W.metadata.e_cred_authority with
match metadata.e_cred_authority with
| Some "server" ->
pcdata ""
| _ ->
......@@ -1204,7 +1204,7 @@ let election_admin w state () =
base ~title ~login_box ~content ()
let update_credential w () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let form = post_form ~service:election_update_credential_post
(fun (old, new_) ->
......@@ -1263,7 +1263,7 @@ let regenpwd uuid () =
base ~title ~login_box ~content ~uuid ()
let cast_raw w () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let form_rawballot = post_form ~service:election_cast_post
(fun (name, _) ->
......@@ -1316,7 +1316,7 @@ let cast_raw w () =
base ~title:params.e_name ~login_box ~content ~uuid ~footer ()
let cast_confirmation w hash () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
lwt user = Web_auth_state.get_election_user W.election.e_params.e_uuid in
let params = W.election.e_params in
let name = params.e_name in
......@@ -1378,7 +1378,7 @@ let cast_confirmation w hash () =
base ~title:name ~login_box ~content ~uuid ()
let cast_confirmed w ~result () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let name = params.e_name in
let progress = div ~a:[a_style "text-align:center;margin-bottom:20px;"] [
......@@ -1426,7 +1426,7 @@ let cast_confirmed w ~result () =
base ~title:name ~login_box ~content ~uuid ()
let pretty_ballots w hashes result () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let title = params.e_name ^ " — Accepted ballots" in
let nballots = ref 0 in
......@@ -1480,7 +1480,7 @@ let pretty_ballots w hashes result () =
base ~title ~login_box ~content ~uuid ()
let pretty_records w records () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let uuid = W.election.e_params.e_uuid in
let title = W.election.e_params.e_name ^ " — Records" in
let records = List.map (fun (date, voter) ->
......@@ -1507,7 +1507,7 @@ let pretty_records w records () =
base ~title ~login_box ~content ()
let tally_trustees w trustee_id () =
let module W = (val w : WEB_ELECTION_DATA) in
let module W = (val w : ELECTION_DATA) in
let params = W.election.e_params in
let title =
params.e_name ^ " — Partial decryption #" ^ string_of_int trustee_id
......
......@@ -20,10 +20,10 @@
(**************************************************************************)
open Serializable_t
open Web_signatures
open Signatures
val home : unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val admin : elections:((module WEB_ELECTION_DATA) list * (module WEB_ELECTION_DATA) list * (module WEB_ELECTION_DATA) list * (Uuidm.t * string) list) option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val admin : elections:((module ELECTION_DATA) list * (module ELECTION_DATA) list * (module ELECTION_DATA) list * (Uuidm.t * string) list) option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val new_election_failure : [ `Exists | `Exception of exn ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
......@@ -37,19 +37,19 @@ val election_setup_credential_authority : Uuidm.t -> Web_common.setup_election -
val election_setup_credentials : string -> string -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_trustees : Uuidm.t -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_trustee : string -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_import : Uuidm.t -> Web_common.setup_election -> (module WEB_ELECTION_DATA) list * (module WEB_ELECTION_DATA) list * (module WEB_ELECTION_DATA) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_import : Uuidm.t -> Web_common.setup_election -> (module ELECTION_DATA) list * (module ELECTION_DATA) list * (module ELECTION_DATA) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_home : (module WEB_ELECTION_DATA) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_admin : (module WEB_ELECTION_DATA) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val update_credential : (module WEB_ELECTION_DATA) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_home : (module ELECTION_DATA) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_admin : (module ELECTION_DATA) -> Web_serializable_j.metadata -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val update_credential : (module ELECTION_DATA) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val regenpwd : Uuidm.t -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_raw : (module WEB_ELECTION_DATA) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmation : (module WEB_ELECTION_DATA) -> string -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmed : (module WEB_ELECTION_DATA) -> result:[< `Error of Web_common.error | `Valid of string ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val pretty_ballots : (module WEB_ELECTION_DATA) -> string list -> Yojson.Safe.json result option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val pretty_records : (module WEB_ELECTION_DATA) -> (string * string) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_raw : (module ELECTION_DATA) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmation : (module ELECTION_DATA) -> string -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmed : (module ELECTION_DATA) -> result:[< `Error of Web_common.error | `Valid of string ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val pretty_ballots : (module ELECTION_DATA) -> string list -> Yojson.Safe.json result option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val pretty_records : (module ELECTION_DATA) -> (string * string) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val tally_trustees : (module WEB_ELECTION_DATA) -> int -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val tally_trustees : (module ELECTION_DATA) -> int -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val already_logged_in :
unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment