Commit 8ff5c41e authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Remove OCaml-based election template

parent 90668988
minimal.otarget
src/lib/lib.cma
src/web/server.cma
demo/template.byte
demo/demo.byte
open Util
open Serializable_t
(* Setup group *)
module G = Election.DefaultGroup;;
assert (Election.check_finite_field G.group);;
module M = Election.MakeSimpleMonad(G);;
(* Setup trustees *)
module KG = Election.MakeSimpleDistKeyGen(G)(M);;
let public_keys =
let ic = open_in "public_keys.jsons" in
let raw_keys =
let rec loop xs =
match (try Some (input_line ic) with End_of_file -> None) with
| Some x -> loop (x::xs)
| None -> xs
in loop []
in
close_in ic;
let keys = List.map (fun x ->
Serializable_j.trustee_public_key_of_string Serializable_builtin_j.read_number x
) raw_keys |> Array.of_list in
assert (Array.forall KG.check keys);
keys
let y = KG.combine public_keys
(* Setup election *)
let {g; p; q} = G.group
let uuid_of_string x = match Uuidm.of_string x with
| Some y -> y
| None -> invalid_arg "invalid UUID"
let params = {
e_description = "This is a test election.";
e_name = "Test election";
e_public_key = {ffpk_g = g; ffpk_p = p; ffpk_q = q; ffpk_y = y};
e_questions =
[|
{
q_answers = [| "a"; "b"; "c"; "d"; "e" |];
q_min = 0;
q_max = 1;
q_question = "Question 1?";
};
{
q_answers = [| "a"; "b"; "c"; "d"; "e"; "f" |];
q_min = 2;
q_max = 3;
q_question = "Question 2?";
};
{
q_answers = [| "a"; "b"; "c" |];
q_min = 1;
q_max = 1;
q_question = "Question 3?";
};
|];
e_uuid = uuid_of_string "00000000-0000-0000-0000-000000000000";
e_short_name = "test";
};;
let date_of_string x =
Serializable_builtin_j.datetime_of_string ("\"" ^ x ^ "\"")
let metadata =
{
e_voting_starts_at = date_of_string "2013-12-25 08:00:00.000"; (* UTC *)
e_voting_ends_at = date_of_string "2014-01-01 12:00:00.000"; (* UTC *)
e_voters_list = None;
}
;;
(* Save to disk *)
open Serializable_j;;
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