Commit de3b595f authored by Stephane Glondu's avatar Stephane Glondu

Record in trustee public keys whether the server has the private key

parent c3c91857
Pipeline #60102 failed with stages
in 1 minute and 25 seconds
......@@ -398,6 +398,19 @@ let rmdir dir =
let urlize = String.map (function '+' -> '-' | '/' -> '_' | c -> c)
let unurlize = String.map (function '-' -> '+' | '_' -> '/' | c -> c)
let webize_trustee_public_key server pk =
{
web_trustee_pok = pk.trustee_pok;
web_trustee_public_key = pk.trustee_public_key;
web_trustee_server = if server then Some true else None;
}
let unwebize_trustee_public_key pk =
{
trustee_pok = pk.web_trustee_pok;
trustee_public_key = pk.web_trustee_public_key;
}
let default_contact = "Name <user@example.org>"
let default_questions =
......
......@@ -149,6 +149,9 @@ val rmdir : string -> unit Lwt.t
val urlize : string -> string
val unurlize : string -> string
val webize_trustee_public_key : bool -> 'a trustee_public_key -> 'a web_trustee_public_key
val unwebize_trustee_public_key : 'a web_trustee_public_key -> 'a trustee_public_key
val default_contact : string
val default_questions : question array
val default_name : string
......
......@@ -27,6 +27,7 @@ type number <ocaml predef from="Serializable_builtin"> = abstract
type uuid <ocaml predef from="Serializable_builtin"> = abstract
type string_set <ocaml predef from="Serializable_builtin"> = abstract
type datetime <ocaml predef from="Web_serializable_builtin"> = abstract
type proof <ocaml predef from="Serializable"> = abstract
type template <ocaml predef from="Serializable"> = abstract
type cert <ocaml predef from="Serializable"> = abstract
type polynomial <ocaml predef from="Serializable"> = abstract
......@@ -87,6 +88,13 @@ type election_state =
type partial_decryptions = (int * string) list
type decryption_tokens = string list
(* The following is a supertype of trustee_public_key *)
type 'a web_trustee_public_key = {
pok : proof;
public_key : 'a;
?server : bool option;
} <ocaml field_prefix="web_trustee_">
(** {1 Types related to elections being prepared} *)
type draft_voter = {
......
......@@ -92,7 +92,7 @@ let validate_election uuid se =
| [] ->
let%lwt private_key = KG.generate () in
let%lwt public_key = KG.prove private_key in
return (None, [public_key], `KEY private_key)
return (None, [webize_trustee_public_key true public_key], `KEY private_key)
| _ :: _ ->
let private_key =
List.fold_left (fun accu {st_private_key; _} ->
......@@ -109,13 +109,14 @@ let validate_election uuid se =
return (
Some (List.map (fun {st_id; _} -> st_id) se.se_public_keys),
(List.map
(fun {st_public_key; _} ->
(fun {st_public_key; st_private_key; _} ->
if st_public_key = "" then failwith "some public keys are missing";
trustee_public_key_of_string G.read st_public_key
let pk = trustee_public_key_of_string G.read st_public_key in
webize_trustee_public_key (st_private_key <> None) pk
) se.se_public_keys),
private_key)
in
let y = KG.combine (Array.of_list public_keys) in
let y = KG.combine (Array.of_list (List.map unwebize_trustee_public_key public_keys)) in
return (y, trustees, `PK public_keys, private_key)
| Some ts ->
match se.se_threshold_parameters with
......@@ -171,7 +172,7 @@ let validate_election uuid se =
in
let%lwt () =
match pk_or_tp with
| `PK pk -> create_file "public_keys.jsons" (string_of_trustee_public_key G.write) pk
| `PK pk -> create_file "public_keys.jsons" (string_of_web_trustee_public_key G.write) pk
| `TP tp -> create_file "threshold.json" (string_of_threshold_parameters G.write) [tp]
in
let%lwt () = create_file "voters.txt" (fun x -> x.sv_id) se.se_voters 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