Commit 07408321 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add public_keys to ELECTION_PARAMS

parent c22d9c11
......@@ -263,10 +263,11 @@ module MakeElection (P : Crypto_sigs.ELECTION_PARAMS) = struct
let result = Array.mmap log results in
{nb_tallied; encrypted_tally; partial_decryptions; result}
let check_result ys r =
let check_result r =
let {encrypted_tally; partial_decryptions; result; nb_tallied} = r in
check_ciphertext encrypted_tally &&
Array.forall2 (check_factor encrypted_tally) ys partial_decryptions &&
Array.forall2 (check_factor encrypted_tally)
public_keys 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
......
......@@ -45,6 +45,9 @@ module type ELECTION_PARAMS = sig
module G : GROUP
(** The group used for cryptography. *)
val public_keys : G.t array
(** Trustee public keys. *)
val params : G.t Serializable_t.election
(** Other parameters. *)
......@@ -133,7 +136,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 : public_key array -> result -> bool
val check_result : result -> bool
val extract_tally : result -> plaintext
(** Extract the plaintext result of the election. *)
......
......@@ -80,6 +80,10 @@ let verbose_verify_election_test_data (e, ballots, signatures, private_data) =
let {g; p; q; y} = e.election.e_public_key in
let module P = struct
module G = (val Crypto.finite_field ~p ~q ~g : Crypto_sigs.GROUP with type t = Z.t)
let public_keys =
Array.map (fun x ->
x.trustee_public_key.y
) e.public_data.public_keys
let params = Serializable_compat.of_election e.election
let fingerprint = e.fingerprint
end in
......@@ -166,6 +170,10 @@ let random_exponent =
module P = struct
module G = (val Crypto.finite_field ~p ~q ~g : Crypto_sigs.GROUP with type t = Z.t)
let public_keys =
Array.map (fun x ->
x.trustee_public_key.y
) e.public_data.public_keys
let params = Serializable_compat.of_election e.election
let fingerprint = e.fingerprint
end
......@@ -213,5 +221,5 @@ let () =
nresult.nb_tallied nresult.encrypted_tally nresult.partial_decryptions
in
assert (nresult'.result = nresult.result);
assert (Election.check_result ys nresult');
assert (Election.check_result nresult');
;;
......@@ -186,6 +186,9 @@ let () = Eliom_registration.Html5.register
let {g; p; q; y} = election.Common.election.e_public_key in
let module P = struct
module G = (val Crypto.finite_field ~p ~q ~g : Crypto_sigs.GROUP with type t = Z.t)
let public_keys = Array.map (fun x ->
x.trustee_public_key.y
) election.Common.public_data.public_keys
let params = Serializable_compat.of_election election.Common.election
let fingerprint = assert false
end in
......
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