Commit f9442ef3 authored by Stephane Glondu's avatar Stephane Glondu

Remove e_pks

This field was most of the time set to None. The only non-None usage was
not really needed.
parent a9e8f543
......@@ -100,7 +100,6 @@ let encryptBallot params cred plaintext () =
let module E = Election.MakeElection (G) (M) in
let e = {
e_params = P.params;
e_pks = None;
e_fingerprint = P.fingerprint;
} in
let sk =
......
......@@ -30,13 +30,11 @@ let check_modulo p x = Z.(geq x zero && lt x p)
(** Parameters *)
let check_election_public_key (type t) g e =
let check_election_public_key (type t) g pks e =
let module G = (val g : GROUP with type t = t) in
let open G in
(* check public key *)
match e.e_pks with
| Some pks -> Array.fold_left ( *~ ) G.one pks =~ e.e_params.e_public_key
| None -> false
Array.fold_left ( *~ ) G.one pks =~ e.e_params.e_public_key
(** Simple monad *)
......@@ -414,13 +412,10 @@ module MakeElection (G : GROUP) (M : RANDOM) = struct
let result = Array.mmap log results in
{num_tallied; encrypted_tally; partial_decryptions; result}
let check_result e r =
let check_result e pks r =
let {encrypted_tally; partial_decryptions; result; num_tallied} = r in
check_ciphertext encrypted_tally &&
(match e.e_pks with
| Some pks ->
Array.forall2 (check_factor encrypted_tally) pks partial_decryptions
| None -> false) &&
Array.forall2 (check_factor encrypted_tally) pks partial_decryptions &&
let dummy = Array.mmap (fun _ -> G.one) encrypted_tally in
let factors = Array.fold_left (fun a b ->
Array.mmap2 ( *~ ) a b.decryption_factors
......
......@@ -26,7 +26,7 @@ open Serializable_t
open Signatures
val check_election_public_key : (module GROUP with type t = 'a) ->
'a election -> bool
'a array -> 'a election -> bool
(** Check election public key. *)
module MakeSimpleMonad (G : GROUP) : sig
......
......@@ -139,9 +139,6 @@ type 'a election = {
e_params : 'a params;
(** Parameters of the election. *)
e_pks : 'a array option;
(** Trustee public keys. *)
e_fingerprint : string;
(** Fingerprint of the election. *)
}
......@@ -241,7 +238,7 @@ module type ELECTION = sig
produce the election result. The first argument is the number of
tallied ballots. May raise [Invalid_argument]. *)
val check_result : t -> result -> bool
val check_result : t -> public_key array -> result -> bool
val extract_tally : result -> plaintext
(** Extract the plaintext result of the election. *)
......
......@@ -91,7 +91,6 @@ module Make (P : PARSED_PARAMS) : S = struct
let e = {
e_params = params;
e_pks = Some pks;
e_fingerprint = fingerprint;
}
......@@ -172,7 +171,7 @@ module Make (P : PARSED_PARAMS) : S = struct
let tally = Lazy.force encrypted_tally in
assert (Array.forall2 (E.check_factor tally) pks factors);
let result = E.combine_factors (M.cardinal ()) tally factors in
assert (E.check_result e result);
assert (E.check_result e pks result);
string_of_result G.write result
let verify () =
......@@ -182,7 +181,7 @@ module Make (P : PARSED_PARAMS) : S = struct
);
(match get_result () with
| Some result ->
assert (E.check_result e (result_of_string G.read result))
assert (E.check_result e pks (result_of_string G.read result))
| None -> print_msg "W: no result to check"
);
print_msg "I: all checks passed"
......
......@@ -82,7 +82,6 @@ let web_election_data (raw_election, web_params) =
module G = P.G
let election = {
e_params = P.params;
e_pks = None;
e_fingerprint = P.fingerprint;
}
include (val web_params : WEB_PARAMS)
......
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