Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 5f7a82bc authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Rename "election" datatype into "params" where appropriate

parent bdf40f94
......@@ -32,7 +32,7 @@ let y = KG.combine public_keys;;
(* Setup election *)
let election = {
let params = {
e_description = "This is a test election.";
e_name = "Test election";
e_public_key = y;
......@@ -73,14 +73,14 @@ let metadata =
module P = struct
module G = G
let params = election
let params = params
let metadata = Some metadata
let public_keys = Lazy.lazy_from_val (
public_keys |> Array.map (fun x -> x.trustee_public_key)
)
let fingerprint =
election |>
Serializable_j.string_of_election Serializable_builtin_j.write_number |>
params |>
Serializable_j.string_of_params Serializable_builtin_j.write_number |>
hashB
end;;
......@@ -145,15 +145,15 @@ let list_save_to filename writer xs =
close_out oc;;
let save_to_disk () =
let election = { election with
let params = { params with
e_public_key = G.({ g; p; q; y })
} in
let ballots = Array.of_list (M.fold_ballots (fun x xs () -> x::xs) [] ()) in
let dir = Printf.sprintf "demo/data/%s" (Uuidm.to_string election.e_uuid) in
let dir = Printf.sprintf "demo/data/%s" (Uuidm.to_string params.e_uuid) in
Unix.mkdir dir 0o755;
let open Serializable_j in
let number = Serializable_builtin_j.write_number in
save_to (dir/"election.json") (write_election write_ff_pubkey) election;
save_to (dir/"election.json") (write_params write_ff_pubkey) params;
save_to (dir/"metadata.json") write_metadata metadata;
list_save_to (dir/"private_keys.jsons") number private_keys;
list_save_to (dir/"public_keys.jsons") (write_trustee_public_key number) public_keys;
......
......@@ -51,15 +51,15 @@ let () = Sys.chdir !dir
(* Load and check election *)
let election, election_fingerprint =
let params, election_fingerprint =
match (load_from_file (fun l ->
Serializable_j.(election_of_string read_ff_pubkey l),
Serializable_j.(params_of_string read_ff_pubkey l),
sha256_b64 l
) "election.json") with
| Some [e] -> e
| _ -> failwith "invalid election file"
let {g; p; q; y} = election.e_public_key
let {g; p; q; y} = params.e_public_key
let () = assert (Election.check_finite_field ~p ~q ~g)
module G = (val Election.finite_field ~g ~p ~q : Election.FF_GROUP)
......@@ -97,7 +97,7 @@ let metadata =
module P = struct
module G = G
let params = { election with e_public_key = y }
let params = { params with e_public_key = y }
let metadata = metadata
let public_keys = lazy (
match public_keys with
......
......@@ -47,7 +47,7 @@ type question = {
question : string;
} <ocaml field_prefix="q_">
type 'a election = {
type 'a params = {
description : string;
name : string;
public_key : 'a;
......
......@@ -56,7 +56,7 @@ type question = {
tally_type : tally_type;
} <ocaml field_prefix="q_">
type 'a election = {
type 'a params = {
cast_url : string;
description : string;
frozen_at : datetime;
......
......@@ -10,7 +10,7 @@ let question q =
let open Serializable_t in
{q_answers; q_min; q_max; q_question}
let election e =
let params e =
let {
e_description; e_name; e_public_key;
e_questions; e_uuid; e_short_name;
......
......@@ -2,7 +2,7 @@
open Serializable_compat_t
val election : 'a election -> 'a Serializable_t.election
val params : 'a params -> 'a Serializable_t.params
val ballot : 'a ballot -> 'a Serializable_t.ballot
val partial_decryption :
'a partial_decryption -> 'a Serializable_t.partial_decryption
......
......@@ -99,7 +99,7 @@ module type ELECTION_PARAMS = sig
(* TODO: public_keys is not needed during election, remove from
here, or at least monadify. *)
val params : G.t Serializable_t.election
val params : G.t Serializable_t.params
(** Parameters of the election. *)
val metadata : Serializable_t.metadata option
......@@ -126,7 +126,7 @@ module type ELECTION = sig
type private_key = Z.t
type public_key = elt
val election_params : elt Serializable_t.election
val election_params : elt Serializable_t.params
(** {2 Ciphertexts} *)
......
......@@ -104,18 +104,18 @@ lwt election_table =
(* TODO: if the election is featured, show it on the home page *)
return accu
) else (
let fn_election = path/"election.json" in
let fn_params = path/"election.json" in
let fn_public_keys = path/"public_keys.jsons" in
lwt b = file_exists fn_election in
lwt b = file_exists fn_params in
if b then (
Ocsigen_messages.debug (fun () ->
"-- registering " ^ subdir
);
lwt raw =
Lwt_io.chars_of_file fn_election |>
Lwt_io.chars_of_file fn_params |>
Lwt_stream.to_string
in
let election = Serializable_j.election_of_string
let params = Serializable_j.params_of_string
Serializable_j.read_ff_pubkey raw
in
let fingerprint = sha256_b64 raw in
......@@ -149,23 +149,23 @@ lwt election_table =
)
in
let election_data = Web_common.({
fn_election;
fn_params;
fingerprint;
election;
params;
fn_public_keys;
public_creds;
featured_p = true;
can_read = Any;
can_vote;
}) in
let {g; p; q; y} = election.e_public_key in
let {g; p; q; y} = params.e_public_key in
let module G = (val
Election.finite_field ~p ~q ~g : Election.FF_GROUP
) in
let module P = struct
module G = G
let public_keys = lazy (assert false)
let params = { election with e_public_key = y }
let params = { params with e_public_key = y }
let fingerprint = fingerprint
let metadata = metadata
end in
......@@ -178,7 +178,7 @@ lwt election_table =
let data = election_data
end in
X.B.inject_creds public_creds >>
let uuid = election.e_uuid in
let uuid = params.e_uuid in
return (EMap.add uuid (module X : Web_common.WEB_ELECTION) accu)
) else return accu
)
......@@ -380,7 +380,7 @@ let () = Eliom_registration.File.register
(if_eligible can_read
(fun uuid election user () ->
let module X = (val election : Web_common.WEB_ELECTION) in
return X.data.Web_common.fn_election
return X.data.Web_common.fn_params
)
)
......
......@@ -157,7 +157,7 @@ let make_booth uuid =
Eliom_uri.make_string_uri ~absolute_path:true ~service ()
)
let preapply_uuid s e = Eliom_service.preapply s e.Web_common.election.e_uuid
let preapply_uuid s e = Eliom_service.preapply s e.Web_common.params.e_uuid
type savable_service =
| Home
......
......@@ -104,9 +104,9 @@ let format_one_featured_election e =
li [
h3 [
a ~service:Services.(preapply_uuid election_index e)
[pcdata e.Web_common.election.e_name] ();
[pcdata e.Web_common.params.e_name] ();
];
p [pcdata e.Web_common.election.e_description];
p [pcdata e.Web_common.params.e_description];
]
let index ~auth_systems ~featured =
......@@ -227,9 +227,9 @@ let election_view ~auth_systems ~election ~user =
]
] in
let content = [
h1 [ pcdata election.Web_common.election.e_name ];
h1 [ pcdata election.Web_common.params.e_name ];
p ~a:[a_style "margin: 1em; padding: 2pt; font-style: italic; border: 1pt solid;"] [
pcdata election.Web_common.election.e_description
pcdata election.Web_common.params.e_description
];
p voting_period;
p permissions;
......@@ -247,7 +247,7 @@ let election_view ~auth_systems ~election ~user =
br ();
audit_info;
] in
base ~auth_systems ~title:election.Web_common.election.e_name ~content
base ~auth_systems ~title:election.Web_common.params.e_name ~content
let election_cast_raw ~election =
let module X = (val election : Web_common.WEB_ELECTION) in
......@@ -259,7 +259,7 @@ let election_cast_raw ~election =
div [textarea ~a:[a_rows 10; a_cols 40] ~name ()];
div [string_input ~input_type:`Submit ~value:"Submit" ()];
]
) election.Web_common.election.e_uuid
) election.Web_common.params.e_uuid
in
let form_upload = post_form ~service:Services.election_cast_post
(fun (_, name) ->
......@@ -271,19 +271,19 @@ let election_cast_raw ~election =
];
div [string_input ~input_type:`Submit ~value:"Submit" ()];
]
) election.Web_common.election.e_uuid
) election.Web_common.params.e_uuid
in
let content = [
h1 [ pcdata election.Web_common.election.e_name ];
h1 [ pcdata election.Web_common.params.e_name ];
h3 [ pcdata "Submit by copy/paste" ];
form_rawballot;
h3 [ pcdata "Submit by file" ];
form_upload;
] in
base ~title:election.Web_common.election.e_name ~content
base ~title:election.Web_common.params.e_name ~content
let ballot_received ~election ~confirm ~user ~can_vote =
let name = election.Web_common.election.e_name in
let name = election.Web_common.params.e_name in
let user_div = match user with
| Some u when can_vote ->
let service = confirm () in
......@@ -295,7 +295,7 @@ let ballot_received ~election ~confirm ~user ~can_vote =
string_input ~input_type:`Submit ~value:"I confirm my vote" ();
pcdata ".";
]
]) election.Web_common.election.e_uuid
]) election.Web_common.params.e_uuid
| Some _ ->
div [
pcdata "You cannot vote in this election!";
......@@ -323,7 +323,7 @@ let ballot_received ~election ~confirm ~user ~can_vote =
base ~title:name ~content
let do_cast_ballot ~election ~result =
let name = election.Web_common.election.e_name in
let name = election.Web_common.params.e_name in
let content = [
h1 [ pcdata name ];
p [
......@@ -359,10 +359,10 @@ let election_update_credential ~election =
];
div [string_input ~input_type:`Submit ~value:"Submit" ()];
]
) election.Web_common.election.e_uuid
) election.Web_common.params.e_uuid
in
let content = [
h1 [ pcdata election.Web_common.election.e_name ];
h1 [ pcdata election.Web_common.params.e_name ];
form;
] in
base ~title:election.Web_common.election.e_name ~content
base ~title:election.Web_common.params.e_name ~content
......@@ -27,9 +27,9 @@ type acl =
module SSet = Set.Make(String)
type election_data = {
fn_election : string;
fn_params : string;
fingerprint : string;
election : ff_pubkey election;
params : ff_pubkey params;
fn_public_keys : string;
public_creds : SSet.t;
featured_p : bool;
......
......@@ -18,9 +18,9 @@ type acl =
module SSet : Set.S with type elt = string
type election_data = {
fn_election : string;
fn_params : string;
fingerprint : string;
election : ff_pubkey election;
params : ff_pubkey params;
fn_public_keys : string;
public_creds : SSet.t;
featured_p : bool;
......
......@@ -32,7 +32,7 @@ let y = KG.combine public_keys
(* Setup election *)
let election = {
let params = {
e_description = "This is a test election.";
e_name = "Test election";
e_public_key = G.({g; p; q; y});
......@@ -81,5 +81,5 @@ let save_to filename writer x =
close_out oc;;
open Serializable_j;;
save_to "election.json" (write_election write_ff_pubkey) election;;
save_to "election.json" (write_params write_ff_pubkey) params;;
save_to "metadata.json" write_metadata metadata;;
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