Commit 2400c14d authored by Stephane Glondu's avatar Stephane Glondu

Change of terminology: finalize -> validate

We keep the "finalization" field of the election_dates structure for
now.
parent 0a953f5f
......@@ -95,7 +95,7 @@ head -n2 partial_decryptions.tmp > partial_decryptions.jsons
header "Finalize tally"
belenios-tool finalize
belenios-tool validate
header "Perform final verification"
......
......@@ -82,7 +82,7 @@ mv partial_decryptions.tmp partial_decryptions.jsons
header "Finalize tally"
belenios-tool finalize
belenios-tool validate
header "Perform final verification"
......
......@@ -104,7 +104,7 @@ several authentication mechanisms.
2. Concatenate the `partial_decryption.json` received from each
trustee into a `partial_decryptions.jsons`, in the same order as in
`public_keys.jsons`.
3. Run `belenios-tool finalize`. It will create
3. Run `belenios-tool validate`. It will create
`result.json`. Publish this file, along with the files listed in
the first step above. The whole set will enable universal
verifiability.
......
......@@ -41,7 +41,7 @@ Then, the administrator must:
credential authority;
* (optionally) edit trustees. For good security there should be at
least two trustees; a link is generated for each trustee;
* finalize the election.
* validate the election.
Each "link" above must be sent by the administrator to their intended
recipient. Each link leads to an interface that will help its
......@@ -57,14 +57,14 @@ into:
### Election life cycle
An election starts by being in preparation (or "draft mode"), then
becomes finalized. Then, it is immediately opened and can be closed
becomes validated. Then, it is immediately opened and can be closed
and re-opened at will. When it is closed, the election administrator
can initiate the tallying process. The encrypted tally is then
computed and published. After each trustee has computed his/her share
of the decryption, the administrator triggers the release of the
result.
At any moment, a finalized election can be archived. This releases
At any moment, a validated election can be archived. This releases
some resources on the server and makes the election read-only. In
particular, it is no longer possible to vote in or to tally an
archived election. Be careful, this operation is not revertible.
......
......@@ -149,7 +149,7 @@
<h3>Election result</h3>
Partial decryptions:
<div><textarea id="election_factors" rows="1" cols="80"></textarea></div>
<div><button id="do_finalize" rows="1" cols="80">Finalize</textarea></div>
<div><button id="do_validate" rows="1" cols="80">Validate</textarea></div>
<div><textarea id="election_result" rows="1" cols="80"></textarea></div>
<div><button id="do_verify">Verify</button></div>
</div>
......
......@@ -386,7 +386,7 @@ module Election : CMDLINER_MODULE = struct
let pdk = string_of_file pdk in
print_endline (X.tdecrypt key pdk)
| `Verify -> X.verify ()
| `Finalize ->
| `Validate ->
let factors =
let fname = dir/"partial_decryptions.jsons" in
match load_from_file (fun x -> x) fname with
......@@ -394,7 +394,7 @@ module Election : CMDLINER_MODULE = struct
| None -> failwith "cannot load partial decryptions"
in
let oc = open_out (dir/"result.json") in
output_string oc (X.finalize factors);
output_string oc (X.validate factors);
output_char oc '\n';
close_out oc
end;
......@@ -469,17 +469,17 @@ module Election : CMDLINER_MODULE = struct
Term.(ret (main $ url_t $ optdir_t $ key_t $ pdk_t)),
Term.info "threshold-decrypt" ~doc ~man:decrypt_man
let finalize_cmd =
let doc = "finalizes an election" in
let validate_cmd =
let doc = "validates an election" in
let man = [
`S "DESCRIPTION";
`P "This command reads partial decryptions done by trustees from file $(i,partial_decryptions.jsons), checks them, combines them into the final tally and prints the result to standard output.";
`P "The result structure contains partial decryptions itself, so $(i,partial_decryptions.jsons) can be discarded afterwards.";
] @ common_man in
Term.(ret (pure main $ url_t $ optdir_t $ pure `Finalize)),
Term.info "finalize" ~doc ~man
Term.(ret (pure main $ url_t $ optdir_t $ pure `Validate)),
Term.info "validate" ~doc ~man
let cmds = [vote_cmd; verify_cmd; decrypt_cmd; tdecrypt_cmd; finalize_cmd]
let cmds = [vote_cmd; verify_cmd; decrypt_cmd; tdecrypt_cmd; validate_cmd]
end
......
......@@ -38,7 +38,7 @@ module type S = sig
val vote : string option -> int array array -> string
val decrypt : string -> string
val tdecrypt : string -> string -> string
val finalize : string list -> string
val validate : string list -> string
val verify : unit -> unit
end
......@@ -195,7 +195,7 @@ module Make (P : PARSED_PARAMS) : S = struct
assert (E.check_factor tally pvk factor);
string_of_partial_decryption G.write factor
let finalize factors =
let validate factors =
let factors = List.map (partial_decryption_of_string G.read) factors in
let tally, nballots = Lazy.force encrypted_tally in
let checker = E.check_factor tally in
......
......@@ -12,7 +12,7 @@ module type S = sig
val vote : string option -> int array array -> string
val decrypt : string -> string
val tdecrypt : string -> string -> string
val finalize : string list -> string
val validate : string list -> string
val verify : unit -> unit
end
......
......@@ -251,20 +251,20 @@ module ToolElection = struct
let privkey = get_textarea "election_privkey" in
set_textarea "election_pd" (X.decrypt privkey)
let finalize () =
let validate () =
let module P : PARAMS = struct
let election = get_election ()
include Getters
end in
let module X = (val make (module P : PARAMS) : S) in
let factors = get_textarea "election_factors" |> split_lines in
set_textarea "election_result" (X.finalize factors)
set_textarea "election_result" (X.validate factors)
let cmds = [
"do_encrypt", create_ballot;
"do_verify", verify;
"do_decrypt", decrypt;
"do_finalize", finalize;
"do_validate", validate;
]
end
......
......@@ -274,6 +274,6 @@ let write_file ?uuid x lines =
let default_contact = "Name <user@example.org>"
let default_creation_date = datetime_of_string "\"2018-06-06 00:00:00.000000\""
let default_finalization_date = datetime_of_string "\"2015-10-01 00:00:00.000000\""
let default_validation_date = datetime_of_string "\"2015-10-01 00:00:00.000000\""
let default_tally_date = datetime_of_string "\"2018-06-06 00:00:00.000000\""
let default_archive_date = datetime_of_string "\"2018-06-06 00:00:00.000000\""
......@@ -111,6 +111,6 @@ val write_file : ?uuid:uuid -> string -> string list -> unit Lwt.t
val default_contact : string
val default_creation_date : datetime
val default_finalization_date : datetime
val default_validation_date : datetime
val default_tally_date : datetime
val default_archive_date : datetime
......@@ -53,7 +53,7 @@ let set_election_state x s =
type election_date =
[ `Creation
| `Finalization
| `Validation
| `Tally
| `Archive
]
......@@ -72,7 +72,7 @@ let set_election_date kind uuid d =
let%lwt dates = get_election_dates uuid in
let dates = match kind with
| `Creation -> { dates with e_creation = Some d }
| `Finalization -> { dates with e_finalization = Some d }
| `Validation -> { dates with e_finalization = Some d }
| `Tally -> { dates with e_tally = Some d }
| `Archive -> { dates with e_archive = Some d }
in
......@@ -83,7 +83,7 @@ let get_election_date kind uuid =
let%lwt dates = get_election_dates uuid in
match kind with
| `Creation -> return dates.e_creation
| `Finalization -> return dates.e_finalization
| `Validation -> return dates.e_finalization
| `Tally -> return dates.e_tally
| `Archive -> return dates.e_archive
......
......@@ -35,7 +35,7 @@ val set_election_state : uuid -> election_state -> unit Lwt.t
type election_date =
[ `Creation
| `Finalization
| `Validation
| `Tally
| `Archive
]
......
......@@ -91,7 +91,7 @@ let dump_passwords dir table =
) table
))
let finalize_election uuid se =
let validate_election uuid se =
let uuid_s = raw_string_of_uuid uuid in
(* voters *)
let () =
......@@ -274,7 +274,7 @@ let finalize_election uuid se =
| _ -> return_unit) >>
(* finish *)
Web_persist.set_election_state uuid `Open >>
Web_persist.set_election_date `Finalization uuid (now ())
Web_persist.set_election_date `Validation uuid (now ())
let cleanup_table ?uuid_s table =
let table = Ocsipersist.open_table table in
......@@ -339,14 +339,14 @@ let delete_election uuid =
match date with
| Some x -> return x
| None ->
let%lwt date = Web_persist.get_election_date `Finalization uuid in
let%lwt date = Web_persist.get_election_date `Validation uuid in
match date with
| Some x -> return x
| None ->
let%lwt date = Web_persist.get_election_date `Creation uuid in
match date with
| Some x -> return x
| None -> return default_finalization_date
| None -> return default_validation_date
in
let de_authentication_method = match metadata.e_auth_config with
| Some [{auth_system = "cas"; _}] -> `CAS
......@@ -412,15 +412,15 @@ let () = Any.register ~service:home
Redirection.send admin
)
let get_finalized_elections_by_owner u =
let get_validated_elections_by_owner u =
let%lwt elections, tallied, archived =
Web_persist.get_elections_by_owner u >>=
Lwt_list.fold_left_s (fun accu uuid ->
let%lwt w = find_election uuid in
let%lwt state = Web_persist.get_election_state uuid in
let%lwt date = Web_persist.get_election_date `Finalization uuid in
let%lwt date = Web_persist.get_election_date `Validation uuid in
let date = match date with
| None -> default_finalization_date
| None -> default_validation_date
| Some x -> x
in
let elections, tallied, archived = accu in
......@@ -459,7 +459,7 @@ let () = Html5.register ~service:admin
match site_user with
| None -> return None
| Some u ->
let%lwt elections, tallied, archived = get_finalized_elections_by_owner u in
let%lwt elections, tallied, archived = get_validated_elections_by_owner u in
let%lwt draft_elections =
Ocsipersist.fold_step (fun k v accu ->
let v = draft_election_of_string v in
......@@ -1108,7 +1108,7 @@ let () =
(fun uuid () ->
with_draft_election ~save:false uuid (fun se ->
try%lwt
let%lwt () = finalize_election uuid se in
let%lwt () = validate_election uuid se in
redir_preapply election_admin (uuid, ()) ()
with e ->
T.new_election_failure (`Exception e) () >>= Html5.send
......@@ -1153,7 +1153,7 @@ let () =
Html5.register ~service:election_draft_import
(fun uuid () ->
with_draft_election_ro uuid (fun se ->
let%lwt elections = get_finalized_elections_by_owner se.se_owner in
let%lwt elections = get_validated_elections_by_owner se.se_owner in
T.election_draft_import uuid se elections ()
)
)
......@@ -1195,7 +1195,7 @@ let () =
Html5.register ~service:election_draft_import_trustees
(fun uuid () ->
with_draft_election_ro uuid (fun se ->
let%lwt elections = get_finalized_elections_by_owner se.se_owner in
let%lwt elections = get_validated_elections_by_owner se.se_owner in
T.election_draft_import_trustees uuid se elections ()
)
)
......@@ -2033,7 +2033,7 @@ let () =
)
)
let get_all_finalized_election_dates () =
let get_all_validated_election_dates () =
Lwt_unix.files_of_directory !spool_dir |>
Lwt_stream.filter_map_s
(fun x ->
......@@ -2046,7 +2046,7 @@ let get_all_finalized_election_dates () =
let%lwt state = Web_persist.get_election_state uuid in
match dates with
| Some [x] ->
let state = `Finalized (state, election_dates_of_string x) in
let state = `Validated (state, election_dates_of_string x) in
return @@ Some (uuid, state)
| _ -> return None
with _ -> return None
......@@ -2070,15 +2070,15 @@ let process_election_for_data_policy (uuid, state) =
let t = option_get se.se_creation_date default_creation_date in
if datetime_compare t one_year_ago < 0 then destroy_election uuid se
else return_unit
| `Finalized ((`Open | `Closed | `EncryptedTally _), dates) ->
let t = option_get dates.e_finalization default_finalization_date in
| `Validated ((`Open | `Closed | `EncryptedTally _), dates) ->
let t = option_get dates.e_finalization default_validation_date in
if datetime_compare t one_year_ago < 0 then delete_election uuid
else return_unit
| `Finalized (`Archived, dates) ->
| `Validated (`Archived, dates) ->
let t = option_get dates.e_archive default_archive_date in
if datetime_compare t one_year_ago < 0 then delete_election uuid
else return_unit
| `Finalized (`Tallied _, dates) ->
| `Validated (`Tallied _, dates) ->
let t = option_get dates.e_tally default_tally_date in
if datetime_compare t one_week_ago < 0 then archive_election uuid
else return_unit
......@@ -2088,8 +2088,8 @@ let _ =
let rec loop () =
let () = console (fun () -> "Data policy process started") in
let%lwt draft = get_all_draft_election_dates () in
let%lwt finalized = get_all_finalized_election_dates () in
let elections = draft @ finalized in
let%lwt validated = get_all_validated_election_dates () in
let elections = draft @ validated in
Lwt_list.iter_p process_election_for_data_policy elections >>
let () = console (fun () -> "Data policy process completed") in
Lwt_unix.sleep 3600. >> loop ()
......
......@@ -546,7 +546,7 @@ let election_draft uuid se () =
]
in
let link_confirm = div [
h2 [pcdata "Finalize creation"];
h2 [pcdata "Validate creation"];
a ~service:election_draft_confirm [pcdata "Create election"] uuid;
] in
let form_destroy =
......@@ -1378,7 +1378,7 @@ let election_draft_import_trustees uuid se elections =
election_draft_importer ~service ~title uuid elections
let election_draft_confirm uuid se () =
let title = "Election " ^ se.se_questions.t_name ^ " — Finalize creation" in
let title = "Election " ^ se.se_questions.t_name ^ " — Validate creation" in
let voters = Printf.sprintf "%d voter(s)" (List.length se.se_voters) in
let ready = not (se.se_voters = []) in
let ready, passwords =
......@@ -1463,7 +1463,7 @@ let election_draft_confirm uuid se () =
~service:election_draft_create
(fun () ->
[div
[h2 [pcdata "Finalize creation"];
[h2 [pcdata "Validate creation"];
string_input ~input_type:`Submit ~value:"Create election" ();
pcdata " (Warning: this action is irreversible.)";
]]
......
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