Commit 1a232819 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move election fingerprint computation to Group

parent e42dd2fd
......@@ -21,6 +21,7 @@
open Serializable_j
open Signatures
open Common
(** Generic group parsing *)
......@@ -52,5 +53,6 @@ let election_params_of_string x =
let module X = struct
module G = (val Group_field.make group : Group_field.GROUP)
let params = {params with e_public_key = y}
let fingerprint = sha256_b64 x
end in
(module X : ELECTION_PARAMS)
......@@ -106,6 +106,7 @@ end
module type ELECTION_PARAMS = sig
module G : GROUP
val params : G.t params
val fingerprint : string
end
(** Monad signature. *)
......
......@@ -48,9 +48,7 @@ module type PARAMS = sig
val do_finalize : bool
val do_decrypt : bool
val ballot_file : string option
val election_fingerprint : string
module G : GROUP
val params : G.t params
include ELECTION_PARAMS
end
......@@ -115,11 +113,8 @@ let parse_args () = begin
(* Load and check election *)
let params, election_fingerprint =
match (load_from_file (fun l ->
Group.election_params_of_string l,
sha256_b64 l
) "election.json") with
let params =
match load_from_file Group.election_params_of_string "election.json" with
| Some [e] -> e
| _ -> failwith "invalid election file"
in
......@@ -129,8 +124,6 @@ let parse_args () = begin
let do_finalize = !do_finalize
let do_decrypt = !do_decrypt
let ballot_file = !ballot_file
let params = params
let election_fingerprint = election_fingerprint
include (val params : ELECTION_PARAMS)
end in
......@@ -175,7 +168,7 @@ module Run (P : PARAMS) : EMPTY = struct
let e = {
e_params = params;
e_pks = Some pks;
e_fingerprint = election_fingerprint;
e_fingerprint = fingerprint;
}
(* Load ballots, if present *)
......
......@@ -51,9 +51,9 @@ end
let make config =
let e_fingerprint = sha256_b64 config.raw_election in
let params = Group.election_params_of_string config.raw_election in
let module P = (val params : ELECTION_PARAMS) in
let e_fingerprint = P.fingerprint in
let e_params = P.params in
let module R : REGISTRATION = struct
......
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