Commit a460d277 authored by Stephane Glondu's avatar Stephane Glondu Committed by Stéphane Glondu

Add the possibility to add a public name to trustees

parent 175a02cf
Pipeline #114890 failed with stage
in 18 minutes and 51 seconds
......@@ -107,6 +107,7 @@ type draft_trustee = {
token : string;
public_key <ocaml mutable> : string;
?private_key : number option;
?comment : string option;
} <ocaml field_prefix="st_">
type draft_threshold_trustee = {
......@@ -117,6 +118,7 @@ type draft_threshold_trustee = {
?polynomial <ocaml mutable> : polynomial option;
?vinput <ocaml mutable> : vinput option;
?voutput <ocaml mutable> : string option;
?comment : string option;
} <ocaml field_prefix="stt_">
type draft_election = {
......
......@@ -46,7 +46,7 @@ let election_draft_voters = create ~path:(Path ["draft"; "voters"]) ~meth:(Get (
let election_draft_voters_add = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voters") ()
let election_draft_voters_remove = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_voters_passwd = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_trustee_add = create_attached_post ~fallback:election_draft ~post_params:(string "id") ()
let election_draft_trustee_add = create_attached_post ~fallback:election_draft ~post_params:(string "id" ** string "comment") ()
let election_draft_trustee_del = create_attached_post ~fallback:election_draft ~post_params:(int "index") ()
let election_draft_credential_authority = create ~path:(Path ["draft"; "credential-authority"]) ~meth:(Get (uuid "uuid")) ()
let election_draft_credentials = create ~path:(Path ["draft"; "credentials"]) ~meth:(Get uuid_and_token) ()
......@@ -62,7 +62,7 @@ let election_draft_threshold_trustees = create ~path:(Path ["draft"; "threshold-
let election_draft_threshold_trustee = create ~path:(Path ["draft"; "threshold-trustee"]) ~meth:(Get uuid_and_token) ()
let election_draft_threshold_trustee_post = create ~path:(Path ["draft"; "submit-threshold-trustee"]) ~meth:(Post (uuid_and_token, string "data")) ()
let election_draft_threshold_set = create_attached_post ~fallback:election_draft_threshold_trustees ~post_params:(int "threshold") ()
let election_draft_threshold_trustee_add = create_attached_post ~fallback:election_draft_threshold_trustees ~post_params:(string "id") ()
let election_draft_threshold_trustee_add = create_attached_post ~fallback:election_draft_threshold_trustees ~post_params:(string "id" ** string "comment") ()
let election_draft_threshold_trustee_del = create_attached_post ~fallback:election_draft_threshold_trustees ~post_params:(int "index") ()
let election_draft_confirm = create ~path:(Path ["draft"; "confirm"]) ~meth:(Get (uuid "uuid")) ()
......
......@@ -111,14 +111,10 @@ let validate_election uuid se =
return (
(List.map (fun {st_id; _} -> st_id) se.se_public_keys),
(List.map
(fun {st_public_key; st_private_key; _} ->
(fun {st_public_key; st_comment; _} ->
if st_public_key = "" then failwith "some public keys are missing";
let pk = trustee_public_key_of_string G.read st_public_key in
let pk =
if st_private_key <> None then
{ pk with trustee_comment = Some "server" }
else pk
in
let pk = { pk with trustee_comment = st_comment } in
`Single pk
) se.se_public_keys),
private_key)
......@@ -129,6 +125,12 @@ let validate_election uuid se =
| None -> failwith "key establishment not finished"
| Some tp ->
let tp = threshold_parameters_of_string G.read tp in
let commented =
List.combine (Array.to_list tp.t_verification_keys) ts
|> List.map (fun (k, t) -> { k with trustee_comment = t.stt_comment })
|> Array.of_list
in
let tp = { tp with t_verification_keys = commented } in
let trustee_names = List.map (fun {stt_id; _} -> stt_id) ts in
let private_keys =
List.map (fun {stt_voutput; _} ->
......@@ -838,13 +840,14 @@ let trustee_add_server se =
let%lwt public_key = K.prove private_key in
let st_public_key = string_of_trustee_public_key G.write public_key in
let st_private_key = Some private_key in
let trustee = {st_id; st_token; st_public_key; st_private_key} in
let st_comment = Some "server" in
let trustee = {st_id; st_token; st_public_key; st_private_key; st_comment} in
se.se_public_keys <- se.se_public_keys @ [trustee];
return_unit
let () =
Any.register ~service:election_draft_trustee_add
(fun uuid st_id ->
(fun uuid (st_id, comment) ->
with_draft_election uuid (fun se ->
let%lwt () =
if List.exists (fun x -> x.st_id = "server") se.se_public_keys then
......@@ -853,7 +856,8 @@ let () =
in
if is_email st_id then (
let%lwt st_token = generate_token () in
let trustee = {st_id; st_token; st_public_key = ""; st_private_key = None} in
let st_comment = Some comment in
let trustee = {st_id; st_token; st_public_key = ""; st_private_key = None; st_comment} in
se.se_public_keys <- se.se_public_keys @ [trustee];
redir_preapply election_draft_trustees uuid ()
) else (
......@@ -1186,6 +1190,7 @@ let () =
let rec loop ts pubs privs accu =
match ts, pubs, privs with
| stt_id :: ts, vo_public_key :: pubs, vo_private_key :: privs ->
let stt_comment = vo_public_key.trustee_comment in
let%lwt stt_token = generate_token () in
let stt_voutput = {vo_public_key; vo_private_key} in
let stt_voutput = Some (string_of_voutput G.write stt_voutput) in
......@@ -1193,6 +1198,7 @@ let () =
stt_id; stt_token; stt_voutput;
stt_step = Some 7; stt_cert = None;
stt_polynomial = None; stt_vinput = None;
stt_comment;
} in
loop ts pubs privs (stt :: accu)
| [], [], [] -> return (List.rev accu)
......@@ -1233,7 +1239,8 @@ let () =
return (st_token, None, public_key)
)
in
return {st_id; st_token; st_public_key; st_private_key})
let st_comment = public_key.trustee_comment in
return {st_id; st_token; st_public_key; st_private_key; st_comment})
in
se.se_public_keys <- ts;
redir_preapply election_draft_trustees uuid ()
......@@ -2139,14 +2146,16 @@ let () =
let () =
Any.register ~service:election_draft_threshold_trustee_add
(fun uuid stt_id ->
(fun uuid (stt_id, comment) ->
with_draft_election uuid (fun se ->
if is_email stt_id then (
let stt_comment = Some comment in
let%lwt stt_token = generate_token () in
let trustee = {
stt_id; stt_token; stt_step = None;
stt_cert = None; stt_polynomial = None;
stt_vinput = None; stt_voutput = None;
stt_comment;
} in
let trustees =
match se.se_threshold_trustees with
......
......@@ -636,10 +636,12 @@ let election_draft_trustees ?token uuid se () =
let form_trustees_add =
post_form
~service:election_draft_trustee_add
(fun name ->
(fun (n_id, n_comment) ->
[
txt "Trustee's e-mail address: ";
input ~input_type:`Text ~name string;
input ~input_type:`Text ~name:n_id string;
txt ", public name: ";
input ~input_type:`Text ~name:n_comment string;
input ~input_type:`Submit ~value:"Add" string;
]
) uuid
......@@ -669,6 +671,11 @@ let election_draft_trustees ?token uuid se () =
td [
txt t.st_id;
];
td [
match t.st_comment with
| None -> txt "(not available)"
| Some x -> txt x
];
td [
if t.st_token <> "" then (
let uri = rewrite_prefix @@ Eliom_uri.make_string_uri
......@@ -702,7 +709,7 @@ let election_draft_trustees ?token uuid se () =
[
tr
[
td ~a:[a_colspan 5]
td ~a:[a_colspan 6]
[
txt "The link that must be sent to trustee ";
txt t.st_id;
......@@ -722,6 +729,7 @@ let election_draft_trustees ?token uuid se () =
table (
tr [
th [txt "Trustee"];
th [txt "Public name"];
th [txt "Mail"];
th [txt "Link"];
th [txt "Done?"];
......@@ -780,10 +788,12 @@ let election_draft_threshold_trustees ?token uuid se () =
if show_add_remove then
post_form
~service:election_draft_threshold_trustee_add
(fun name ->
(fun (n_id, n_comment) ->
[
txt "Trustee's e-mail address: ";
input ~input_type:`Text ~name string;
input ~input_type:`Text ~name:n_id string;
txt ", public name: ";
input ~input_type:`Text ~name:n_comment string;
input ~input_type:`Submit ~value:"Add" string;
]
) uuid
......@@ -826,6 +836,11 @@ let election_draft_threshold_trustees ?token uuid se () =
td [
txt t.stt_id;
];
td [
match t.stt_comment with
| None -> txt "(not available)"
| Some x -> txt x
];
td [
let uri = rewrite_prefix @@
Eliom_uri.make_string_uri
......@@ -852,7 +867,7 @@ let election_draft_threshold_trustees ?token uuid se () =
[
tr
[
td ~a:[a_colspan (if show_add_remove then 5 else 4)]
td ~a:[a_colspan (if show_add_remove then 6 else 5)]
[
txt "The link that must be sent to trustee ";
txt t.stt_id;
......@@ -875,6 +890,7 @@ let election_draft_threshold_trustees ?token uuid se () =
tr (
[
th [txt "Trustee"];
th [txt "Public name"];
th [txt "Mail"];
th [txt "Link"];
th [txt "State"];
......
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