Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

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

Cosmetic changes in threshold trustee setup

parent adaac832
......@@ -20,12 +20,27 @@
(**************************************************************************)
open Js_of_ocaml
open Platform
open Serializable_j
open Signatures
open Common
open Tool_js_common
let set_step i =
with_element "current_step" (fun e ->
e##.innerHTML := Js.string "";
let t = Printf.sprintf "Step %d/3" i in
let t = document##createTextNode (Js.string t) in
Dom.appendChild e t
)
let set_explain str =
with_element "explain" (fun e ->
e##.innerHTML := Js.string "";
let t = document##createTextNode (Js.string str) in
Dom.appendChild e t;
Dom.appendChild e (document##createElement (Js.string "br"));
)
let gen_cert e _ =
let group = get_textarea "group" in
let module G = (val Group.of_string group : GROUP) in
......@@ -33,21 +48,20 @@ let gen_cert e _ =
let module C = Trustees.MakeChannels (G) (DirectRandom) (P) in
let module T = Trustees.MakePedersen (G) (DirectRandom) (P) (C) in
let key, cert = T.step1 () in
let id = sha256_hex cert.s_message in
e##.innerHTML := Js.string "";
let t = document##createTextNode (Js.string (Printf.sprintf "Certificate %s has been generated!" id)) in
Dom.appendChild e t;
set_download "private_key" "text/plain" "private_key.txt" key;
set_element_display "key_helper" "block";
let cert = string_of_cert cert in
set_textarea "data" cert;
Js._false
let proceed step e textarea _ =
let proceed step _ =
let group = get_textarea "group" in
let key =
let r = ref "" in
Js.Opt.iter (Dom_html.CoerceTo.textarea textarea) (fun x -> r := Js.to_string x##.value);
with_element "compute_private_key" (fun e ->
Js.Opt.iter (Dom_html.CoerceTo.input e) (fun x -> r := Js.to_string x##.value)
);
!r
in
let certs = certs_of_string (get_textarea "certs") in
......@@ -59,15 +73,13 @@ let proceed step e textarea _ =
match step with
| 3 ->
let polynomial = T.step3 certs key threshold in
e##.innerHTML := Js.string "";
set_textarea "data" (string_of_polynomial polynomial);
set_textarea "compute_data" (string_of_polynomial polynomial);
Js._false
| 5 ->
let vinput = get_textarea "vinput" in
let vinput = vinput_of_string vinput in
let voutput = T.step5 certs key vinput in
e##.innerHTML := Js.string "";
set_textarea "data" (string_of_voutput G.write voutput);
set_textarea "compute_data" (string_of_voutput G.write voutput);
Js._false
| _ ->
alert "Unexpected state!";
......@@ -83,34 +95,35 @@ let fill_interactivity _ =
set_element_display "data_form" "none";
let t = document##createTextNode (Js.string "Waiting for the election administrator to set the threshold... Reload the page to check progress.") in
Dom.appendChild e t
| 2 | 4 | 6 ->
| 2 | 4 ->
set_step (step / 2);
set_element_display "data_form" "none";
let t = document##createTextNode (Js.string "Waiting for the other trustees... Reload the page to check progress.") in
Dom.appendChild e t
| 7 ->
| 6 | 7 ->
set_step 3;
set_element_display "data_form" "none";
let t = document##createTextNode (Js.string "The key establishment protocol is finished!") in
let t = document##createTextNode (Js.string "Your job in the key establishment protocol is done! Your private key will be needed to decrypt the election result.") in
Dom.appendChild e t
| 1 ->
set_step 1;
let b = document##createElement (Js.string "button") in
let t = document##createTextNode (Js.string "Generate private key") in
b##.onclick := Dom_html.handler (gen_cert e);
Dom.appendChild b t;
Dom.appendChild e b;
| 3 | 5 ->
let div = document##createElement (Js.string "div") in
let t = document##createTextNode (Js.string "Private key: ") in
Dom.appendChild div t;
let textarea = Dom_html.createTextarea document in
textarea##.rows := 1;
textarea##.cols := 25;
Dom.appendChild div textarea;
Dom.appendChild e div;
let b = document##createElement (Js.string "button") in
let t = document##createTextNode (Js.string "Proceed") in
b##.onclick := Dom_html.handler (proceed step e textarea);
Dom.appendChild b t;
Dom.appendChild e b;
let explain = match step with
| 3 -> "Now, all the certificates of the trustees have been generated. Proceed to generate your share of the decryption key."
| 5 -> "Now, all the trustees have generated their secret shares. Proceed to the final checks so that the election can be validated."
| _ -> failwith "impossible step"
in
set_step ((step + 1) / 2);
set_explain explain;
set_element_display "compute_form" "block";
with_element "compute_button" (fun e ->
e##.onclick := Dom_html.handler (proceed step)
);
| _ ->
alert "Unexpected state!"
);
......
......@@ -1263,6 +1263,14 @@ let election_draft_trustee token uuid se () =
let election_draft_threshold_trustee token uuid se () =
let title = "Trustee for election " ^ se.se_questions.t_name in
let header =
div ~a:[a_style "text-align:center;"] [
h2 [pcdata "Collaborative key generation"];
div ~a:[a_id "current_step"] [
pcdata "Step 0/3"
];
]
in
let div_link =
let url = Eliom_uri.make_string_uri ~absolute:true
~service:election_home (uuid, ()) |> rewrite_prefix
......@@ -1327,23 +1335,56 @@ let election_draft_threshold_trustee token uuid se () =
(fun data ->
[
div ~a:[a_id "key_helper"; a_style "display:none;"] [
div [a ~service:home ~a:[a_id "private_key"] [pcdata "Private key"] ()];
b [pcdata "Instructions:"];
ol [
li [pcdata "download your private key using the link above;"];
li [pcdata "submit public data using the button below."];
];
];
div [
div [
pcdata "Data: ";
textarea ~a:[a_id "data"] ~name:data ();
li [
pcdata "Download your ";
a ~service:home ~a:[a_id "private_key"] [pcdata "private key"] ();
pcdata " and save it to a secure location."
];
li [
pcdata "Submit data using the following button: ";
input ~input_type:`Submit ~value:"Submit" string;
pcdata ".";
div [
pcdata "Data: ";
textarea ~a:[a_id "data"] ~name:data ();
];
];
];
div [input ~input_type:`Submit ~value:"Submit" string];
];
]
) (uuid, token)
in
let form_compute =
div ~a:[a_id "compute_form"; a_style "display: none;"] [
b [pcdata "Instructions:"];
ol [
li [
pcdata "Enter your private key: ";
input ~input_type:`Text ~a:[a_id "compute_private_key"] string;
pcdata " ";
button_no_value ~a:[a_id "compute_button"] ~button_type:`Button [
pcdata "Proceed";
];
];
li [
pcdata "Submit data using the following button:";
post_form
~service:election_draft_threshold_trustee_post
(fun data ->
[
input ~input_type:`Submit ~value:"Submit" string;
div [
pcdata "Data: ";
textarea ~a:[a_id "compute_data"] ~name:data ();
];
]
) (uuid, token);
];
];
]
in
let interactivity =
div
~a:[a_id "interactivity"]
......@@ -1356,11 +1397,14 @@ let election_draft_threshold_trustee token uuid se () =
]
in
let content = [
header;
div_link;
br ();
div ~a:[a_id "explain"] [];
inputs;
interactivity;
br ();
form;
form_compute;
]
in
base ~title ~content ()
......
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