Commit 2bde5557 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

s/voters/signatures/g

parent fb0af322
...@@ -49,18 +49,18 @@ let load_elections_and_votes dirname = ...@@ -49,18 +49,18 @@ let load_elections_and_votes dirname =
) )
) else Lwt_stream.from_direct (fun () -> None) ) else Lwt_stream.from_direct (fun () -> None)
in in
let voters = let signatures =
let file = data "voters.json" in let file = data "signatures.json" in
if Sys.file_exists file then ( if Sys.file_exists file then (
Lwt_io.lines_of_file file |> Lwt_io.lines_of_file file |>
Lwt_stream.map (fun x -> Lwt_stream.map (fun x ->
let v = Helios_datatypes_j.voter_of_string x in let v = Helios_datatypes_j.signature_of_string x in
v v
) )
) else Lwt_stream.from_direct (fun () -> None) ) else Lwt_stream.from_direct (fun () -> None)
in in
let election_data = { raw; fingerprint; election; public_data } in let election_data = { raw; fingerprint; election; public_data } in
Lwt.return (Some (election_data, ballots, voters)) Lwt.return (Some (election_data, ballots, signatures))
| None -> assert false | None -> assert false
) else Lwt.return None ) else Lwt.return None
) )
......
...@@ -8,7 +8,7 @@ type election_data = { ...@@ -8,7 +8,7 @@ type election_data = {
} }
val load_elections_and_votes : val load_elections_and_votes :
string -> (election_data * Z.t ballot Lwt_stream.t * voter Lwt_stream.t) Lwt_stream.t string -> (election_data * Z.t ballot Lwt_stream.t * signature Lwt_stream.t) Lwt_stream.t
val hash_ballot : Z.t ballot -> string val hash_ballot : Z.t ballot -> string
val hash_user : user -> string val hash_user : user -> string
...@@ -140,10 +140,10 @@ type randomness = { ...@@ -140,10 +140,10 @@ type randomness = {
randomness : string; randomness : string;
} }
type voter = { type signature = {
user : user; user : user;
?hash : string option; ?hash : string option;
} <ocaml field_prefix="voter_"> } <ocaml field_prefix="sig_">
(** {1 Compound datastructures} *) (** {1 Compound datastructures} *)
......
...@@ -25,20 +25,20 @@ let () = ...@@ -25,20 +25,20 @@ let () =
Ocsigen_messages.debug Ocsigen_messages.debug
(fun () -> "Loading elections from " ^ dir ^ "..."); (fun () -> "Loading elections from " ^ dir ^ "...");
Common.load_elections_and_votes dir |> Common.load_elections_and_votes dir |>
Lwt_stream.iter_s (fun (e, ballots, voters) -> Lwt_stream.iter_s (fun (e, ballots, signatures) ->
let uuid = Uuidm.to_string e.Common.election.e_uuid in let uuid = Uuidm.to_string e.Common.election.e_uuid in
Ocsigen_messages.debug Ocsigen_messages.debug
(fun () -> Printf.sprintf "-- loading %s (%s)" uuid e.Common.election.e_short_name); (fun () -> Printf.sprintf "-- loading %s (%s)" uuid e.Common.election.e_short_name);
lwt () = Ocsipersist.add elections_table uuid e in lwt () = Ocsipersist.add elections_table uuid e in
let uuid_underscored = String.map (function '-' -> '_' | c -> c) uuid in let uuid_underscored = String.map (function '-' -> '_' | c -> c) uuid in
let table = Ocsipersist.open_table ("ballots_" ^ uuid_underscored) in let table = Ocsipersist.open_table ("ballots_" ^ uuid_underscored) in
let voters_table = Ocsipersist.open_table ("voters_" ^ uuid_underscored) in let signatures_table = Ocsipersist.open_table ("signatures_" ^ uuid_underscored) in
lwt () = Lwt_stream.iter_s (fun v -> lwt () = Lwt_stream.iter_s (fun v ->
Ocsipersist.add table (Common.hash_ballot v) v Ocsipersist.add table (Common.hash_ballot v) v
) ballots in ) ballots in
lwt () = Lwt_stream.iter_s (fun v -> lwt () = Lwt_stream.iter_s (fun v ->
Ocsipersist.add voters_table (Common.hash_user v.voter_user) v Ocsipersist.add signatures_table (Common.hash_user v.sig_user) v
) voters in ) signatures in
return () return ()
) |> ) |>
Lwt_main.run Lwt_main.run
......
...@@ -75,7 +75,7 @@ let verbose_assert msg it = ...@@ -75,7 +75,7 @@ let verbose_assert msg it =
let r = Lazy.force it in let r = Lazy.force it in
Printf.eprintf " %s\n%!" (if r then "OK" else "failed!") Printf.eprintf " %s\n%!" (if r then "OK" else "failed!")
let verbose_verify_election_test_data (e, ballots, voters, private_data) = let verbose_verify_election_test_data (e, ballots, signatures, private_data) =
Printf.eprintf "Verifying election %S:\n%!" e.election.e_short_name; Printf.eprintf "Verifying election %S:\n%!" e.election.e_short_name;
let {g; p; q; y} = e.election.e_public_key in let {g; p; q; y} = e.election.e_public_key in
let module G = (val ElGamal.make_ff_msubgroup p q g : ElGamal.GROUP with type t = Z.t) in let module G = (val ElGamal.make_ff_msubgroup p q g : ElGamal.GROUP with type t = Z.t) in
...@@ -110,8 +110,8 @@ let verbose_verify_election_test_data (e, ballots, voters, private_data) = ...@@ -110,8 +110,8 @@ let verbose_verify_election_test_data (e, ballots, voters, private_data) =
verbose_assert "result" (lazy (Crypto.verify_result e.election r)); verbose_assert "result" (lazy (Crypto.verify_result e.election r));
| None -> Printf.eprintf " no results available\n%!" | None -> Printf.eprintf " no results available\n%!"
); );
verbose_assert "voter count" (lazy ( verbose_assert "signature count" (lazy (
Array.length voters = Array.length ballots Array.length signatures = Array.length ballots
)); ));
verbose_assert "private keys" (lazy ( verbose_assert "private keys" (lazy (
Array.foralli Array.foralli
...@@ -122,11 +122,11 @@ let verbose_verify_election_test_data (e, ballots, voters, private_data) = ...@@ -122,11 +122,11 @@ let verbose_verify_election_test_data (e, ballots, voters, private_data) =
let load_election_and_verify_it_all dirname = let load_election_and_verify_it_all dirname =
load_elections_and_votes dirname |> load_elections_and_votes dirname |>
Lwt_stream.to_list |> Lwt_main.run |> Lwt_stream.to_list |> Lwt_main.run |>
List.map (fun (e, ballots, voters) -> List.map (fun (e, ballots, signatures) ->
let ballots = Lwt_stream.to_list ballots |> Lwt_main.run |> Array.of_list in let ballots = Lwt_stream.to_list ballots |> Lwt_main.run |> Array.of_list in
let voters = Lwt_stream.to_list voters |> Lwt_main.run |> Array.of_list in let signatures = Lwt_stream.to_list signatures |> Lwt_main.run |> Array.of_list in
let private_data = load_election_private_data dirname (Uuidm.to_string e.election.e_uuid) in let private_data = load_election_private_data dirname (Uuidm.to_string e.election.e_uuid) in
(e, ballots, voters, private_data) (e, ballots, signatures, private_data)
) |> ) |>
List.iter verbose_verify_election_test_data;; List.iter verbose_verify_election_test_data;;
......
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